88 case KING: return king_getlocation(gamestate, move); |
88 case KING: return king_getlocation(gamestate, move); |
89 default: return INVALID_MOVE_SYNTAX; |
89 default: return INVALID_MOVE_SYNTAX; |
90 } |
90 } |
91 } |
91 } |
92 |
92 |
|
93 _Bool is_covered(GameState *gamestate,uint8_t row,uint8_t file,uint8_t color) { |
|
94 Move threats[16]; |
|
95 int threatcount = 0; |
|
96 for (uint8_t r = 0 ; r < 8 ; r++) { |
|
97 for (uint8_t f = 0 ; f < 8 ; f++) { |
|
98 if ((gamestate->board[r][f] & COLOR_MASK) == color) { |
|
99 threats[threatcount].piece = gamestate->board[r][f]; |
|
100 threats[threatcount].fromrow = r; |
|
101 threats[threatcount].fromfile = f; |
|
102 threats[threatcount].torow = row; |
|
103 threats[threatcount].tofile = file; |
|
104 threatcount++; |
|
105 } |
|
106 } |
|
107 } |
|
108 |
|
109 for (int i = 0 ; i < threatcount ; i++) { |
|
110 if (validate_move(gamestate, &(threats[i]))) { |
|
111 return 1; |
|
112 } |
|
113 } |
|
114 |
|
115 return 0; |
|
116 } |
93 |
117 |
94 void apply_move(GameState *gamestate, Move *move) { |
118 void apply_move(GameState *gamestate, Move *move) { |
95 uint8_t piece = move->piece & PIECE_MASK; |
119 uint8_t piece = move->piece & PIECE_MASK; |
96 uint8_t color = move->piece & COLOR_MASK; |
120 uint8_t color = move->piece & COLOR_MASK; |
97 |
121 |