-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameLogic.h
executable file
·95 lines (78 loc) · 1.93 KB
/
GameLogic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* \file GameLogic.h
* A Documented file.
*/
#ifndef GAMELOGIC_H
#define GAMELOGIC_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#include "UI.h"
//#include "Common.h"
#include "AI.h"
#include "Sound.h"
#include "Network.h"
#include "NetHandler.h"
#define WAIT_TIMEOUT -1
#define WAIT_OK 0
#define WAIT_QUIT 1
/**
* Control struct.
* Contains the players and the user interface.
*/
typedef struct
{
Player * player;
Player * enemy;
UI * ui;
} GameLogic;
/**
* Constructor
*@param ui the user interface
*@return a GameLogic instance
*/
GameLogic * GL_makeGame(UI * ui);
/**
* Destructor
*@param game
*/
void GL_destructGame(GameLogic * game);
/**
* Enables the user to place a ship.
* @param shipIndex
* @param game a GameLogic struct
* @return false if the user fails to set his ships and wants to return to the main menu
*/
bool GL_setShip(int shipIndex, GameLogic * game);
/**
* Controls the sequence of getting shot coordinates from the user.
* @param game a GameLogic struct
* @param [out] myShots the required shots
* @return false if all the possible shots has been fired
*/
bool GL_getShots(GameLogic * game, Grids * myShots);
/**
* Executes the single player game.
* @param ui the user interface
*/
void GL_singlePlayerGame(UI * ui);
/**
* Executes the multiplayer game.
* @param ui the user interface
* @param nh a nethandler object
*/
void GL_multiPlayerGame(UI * ui, NH * nh);
/**
* Waits for a given flag.
* Also listens to the user: does he want to quit?
* @param ui the user interface
* @param nh a nethandler object
* @param flag a pointer to the flag to listen
*/
int GL_waitForFlag(UI * ui, NH * nh, bool * flag, int timeout);
void GL_leaveGame(NH * nh, UI * ui, GameLogic * game);
bool GL_startTurn(NH * nh, UI * ui, int turn, bool master);
THREAD(mainFunc, arg);
#endif