diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-31 22:36:17 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-31 22:36:17 +0300 |
commit | 33d4ede846df55578bcdbe9ce5907e0b6d6e304b (patch) | |
tree | f4849c0a09867211cdc60c663d59182e492f7660 /src/board.h | |
parent | c5418464d57de2b71a91ddfbb4c42df25a743da9 (diff) | |
download | carcassonne-engine-c-33d4ede846df55578bcdbe9ce5907e0b6d6e304b.tar.gz |
refactor: merge structures into board
Diffstat (limited to 'src/board.h')
-rw-r--r-- | src/board.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/board.h b/src/board.h index 117d5b2..dc1995a 100644 --- a/src/board.h +++ b/src/board.h @@ -1,14 +1,14 @@ #define BOARD_WIDTH 7 -#define BOARD_ROW_BYTES ((BOARD_WIDTH * 2) + 1) -#define BOARD_BYTES BOARD_ROW_BYTES * BOARD_ROW_BYTES +#define BOARD_ROW_UNITS ((BOARD_WIDTH * 2) + 1) +#define BOARD_UNITS BOARD_ROW_UNITS * BOARD_ROW_UNITS char EMPTY = ' '; int neighbor_increments[] = { - - BOARD_ROW_BYTES, + - BOARD_ROW_UNITS, 1, - BOARD_ROW_BYTES, + BOARD_ROW_UNITS, - 1 }; @@ -20,19 +20,25 @@ typedef struct { int shield; } Tile; +typedef struct { + char feature; + int meeple; + int structure_group; +} BoardUnit; + /* board */ -void initialize_board(char* board); -void print_board(char* board); -void write_board(char* board, char* filename); -void read_board(char* board, char* filename); +void initialize_board(BoardUnit* board); +void print_board(BoardUnit* board); +void write_board(BoardUnit* board, char* filename); +void read_board(BoardUnit* board, char* filename); /* moves */ -int is_allowed_placement(Tile tile, int index, char* board); +int is_allowed_placement(Tile tile, int index, BoardUnit* board); int translate_coordinate(int index); int is_center_index(int index); -int place_tile(Tile tile, int index, char* board, int force); +int place_tile(Tile tile, int index, BoardUnit* board, int force); /* structures */ -void traverse_structure(char id, int index, char* board, char* structures); -void create_structure_mask(char* board, char* structures); -int evaluate_structure(int index, char* board, char* structures); +void traverse_structure(int group, int index, BoardUnit* board); +void refresh_structure_groups(BoardUnit* board); +int evaluate_structure(int index, BoardUnit* board); |