blob: b9df6864884a751b0939f63de68c42477981d605 (
plain)
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
|
#include "meeple.h"
void refresh_meeple_map(BoardUnit* board, int* meeple_map) {
for (int i = 0; i < MAX_STRUCTURES * PLAYERS; i++) meeple_map[i] = 0;
for (int i = 0; i < BOARD_UNITS; i++) {
if (board[i].meeple) {
meeple_map[board[i].structure_group * PLAYERS + (board[i].meeple - 1)]++;
}
}
}
int is_allowed_meeple(int meeple, int index, BoardUnit* board, int* meeple_map) {
if (board[index].meeple
|| board[index].feature == 'F'
|| board[index].feature == ANY
|| board[index].feature == SEPARATOR
) return 0;
int dominator = get_structure_dominator(board[index].structure_group, meeple_map);
return dominator == meeple || dominator == 0;
}
int get_structure_dominator(int structure_group, int* meeple_map) {
int dominator = 0;
int dominator_meeples = 0;
for (int player = 0; player < PLAYERS; player++) {
int meeples = meeple_map[structure_group * PLAYERS + player];
if (meeples > dominator_meeples) {
dominator_meeples = meeples;
dominator = player + 1;
}
}
return dominator;
}
|