-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_logic.h
64 lines (47 loc) · 1.46 KB
/
server_logic.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
#ifndef SERVER_LOGIC_H
#define SERVER_LOGIC_H
#include <stdint.h>
#define QUEUE_LOGIC_STATE 1
#define GAME_LOGIC_STATE 2
#define BOARD_LOGIC_STATE 3
#define GAME_MAP_WIDTH 15
#define GAME_MAP_HEIGHT 15
#define TILE_SIZE 2.0f
#define GAME_OBJECTS_ON_MAP 3
#define SCORE_INCREASE 20
typedef struct
{
float x;
float y;
} CoordinateTuple;
void initGameServerLogic(int32_t win_score_required);
/* queue operations */
void initQueue(int32_t max_player_count);
void deleteQueue();
struct QueueStatus *getCurrentQueueStatus();
int32_t addPlayerToQueue(char *player_username);
int32_t markPlayerReady(int32_t player_id);
int32_t removePlayerFromQueue(int32_t player_id);
/* game operations */
void initGameMapLocations(int32_t width, int32_t height);
void deleteGameMapLocations();
struct InitialLocations *getCurrentMapLocations();
void initGameState(int32_t player_count);
void deleteGameState();
struct GameState *getCurrentGameState();
void handlePlayerMove(int32_t player_id, char *pressed_key);
/* board operations */
void initScoreboard();
void deleteScoreboard();
struct Scoreboard *getCurrentScoreboard();
/* common */
void transitionToGameState();
void transitionToBoardState();
int32_t getCurrentState();
/* internal only functions */
void handleObjectCollection(int32_t player_id);
void handleGameOver();
void read_map_from_file(const char *filename);
void getTileCenter(int32_t row, int32_t col, float *x, float *y);
int32_t canMoveToCoordinate(float x, float y);
#endif