aboutsummaryrefslogtreecommitdiff
path: root/src/board.c
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-04-10 20:51:51 +0300
committereug-vs <eugene@eug-vs.xyz>2022-04-10 20:51:51 +0300
commit6c88febbe0cff8960bc6f2e0bcdfc89777a5f72b (patch)
tree3c6062bc33b4affcc9f9f765e621e71f4493eda7 /src/board.c
parent8c3124e919d9f8e7118fb05f4341c12e54b68c72 (diff)
downloadcarcassonne-engine-c-6c88febbe0cff8960bc6f2e0bcdfc89777a5f72b.tar.gz
feat: support separator (+) feature
Diffstat (limited to 'src/board.c')
-rw-r--r--src/board.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/board.c b/src/board.c
index 92420ed..cc16e06 100644
--- a/src/board.c
+++ b/src/board.c
@@ -58,11 +58,10 @@ void traverse_structure(int group, int index, BoardUnit* board) {
int new_unit = index + NEIGHBOR_INCREMENTS[i];
if (board[new_unit].feature == board[index].feature && board[new_unit].structure_group == 0) {
traverse_structure(group, new_unit, board);
- }
- else if (board[new_unit].feature == '*' && board[new_unit].structure_group != board[index].structure_group) {
+ } else if (board[new_unit].feature == ANY && board[new_unit].structure_group != board[index].structure_group) {
board[new_unit].feature = board[index].feature;
traverse_structure(group, new_unit, board);
- board[new_unit].feature = '*';
+ board[new_unit].feature = ANY;
}
}
}
@@ -72,7 +71,12 @@ void refresh_structure_groups(BoardUnit* board) {
int structure_group = 1;
for (int i = 0; i < BOARD_UNITS; i++) {
- if (board[i].structure_group == 0 && board[i].feature != EMPTY && board[i].feature != 'F') {
+ if (
+ board[i].structure_group == 0
+ && board[i].feature != EMPTY
+ && board[i].feature != SEPARATOR
+ && board[i].feature != 'F'
+ ) {
traverse_structure(structure_group, i, board);
structure_group += 1;
}