-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic.h
83 lines (70 loc) · 1.96 KB
/
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* ____________________________________________________
|_| == Logic Header == |_|
| You can find here all data struture and function |
| prototype of the logical part of Cruxxade-2600. |
| |
|_ <=========> _|
|_|________________________________________________|_|
\ ,__,
\ (oo)____
(__) )\
||--|| *
*/
#ifndef LOGIC
#define LOGIC
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define UP 0
#define DOWN 1
#define R_UP 2
#define L_DOWN 3
#define R_DOWN 4
#define L_UP 5
#define TRUE 1
#define FALSE 0
//Début Structure de Donnée
typedef struct {
int boardSize;
char name[2][10];
int gameMode;
int closedHex;
}Param;
typedef enum{
JUMP, DUPLICATE, INVALIDE
} move;
typedef enum{
PLAYER_1=0, PLAYER_2=1, EMPTY,CLOSED
} case_value;
typedef struct{
int x;
int y;
} vect;
typedef struct hexa{
case_value val;
struct hexa* neighbords[6];
} hexa;
typedef struct {
int size;
hexa** grid;
} T_board;
typedef struct list{
vect pos;
struct list* next;
}Hexa_list;
//Fin Strucutre de Donnée
//Début Prototype
move ValidMove(vect start, vect end, T_board board);
int AllocBoard(T_board* board); //return 0 if sucess ; Neg value otherwise
void FreeBoard(T_board* board);
int InitNewGameboard(int size, T_board* board);
int IsAlive(vect pos, T_board board);
void playMove(T_board* board, move mvt, Hexa_list **alivePlAct, vect start, vect end, int player, int *score);
void AppendList(Hexa_list** init, vect val);
void SupprEltList(Hexa_list** init, unsigned int indice);
void UpdateAlive(T_board board, int player, Hexa_list **Alive, int *playableToken);
void UpdateScore(int *score, Param param);
void PlaceToken(Param param, T_board *board, Hexa_list **Alive);
void FreeHexaList(Hexa_list **Alive);
//Fin Prototype
#endif