Fix handling of drops when checking moves.
This commit is contained in:
parent
d47bef97f0
commit
923a47cf69
@ -189,7 +189,9 @@ impl Game {
|
||||
** Add drops to player moves.
|
||||
*/
|
||||
for i in 0..6 {
|
||||
plays.append(&mut self.get_drops(&Piece::new(i, current_player)));
|
||||
if self.pool[current_player as usize][i] > 0 {
|
||||
plays.append(&mut self.get_drops(&Piece::new(i as u8, current_player)));
|
||||
}
|
||||
}
|
||||
|
||||
plays
|
||||
|
@ -315,7 +315,7 @@ GAME.Game = class {
|
||||
|
||||
// Search for valid board moves.
|
||||
for(let piece of this.board.pieces) {
|
||||
if(piece !== null && piece.player == (this.turn & 1)) {
|
||||
if(piece !== null && piece.player == player) {
|
||||
for(let move of this.movement_tiles(piece, piece.tile)) {
|
||||
if(move.valid) { moves += 1; }
|
||||
}
|
||||
@ -328,14 +328,18 @@ GAME.Game = class {
|
||||
|
||||
// Search for valid pool placements.
|
||||
for(let i = 0; i < this.pools[player].pieces.length; ++i) {
|
||||
for(let move of this.placement_tiles(i, player)) {
|
||||
if(move.valid) { moves += 1; }
|
||||
if(this.pools[player].pieces[i] > 0) {
|
||||
for(let move of this.placement_tiles(i, player)) {
|
||||
if(move.valid) { moves += 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(moves == 0) {
|
||||
this.state.code = GAME.Const.State.Checkmate;
|
||||
}
|
||||
|
||||
console.log(moves);
|
||||
}
|
||||
|
||||
process(play) {
|
||||
|
@ -549,7 +549,7 @@ const INTERFACE = {
|
||||
let background_scale = 0.94;
|
||||
|
||||
// Get background color
|
||||
if(is_check) {
|
||||
if(is_check || GAME_DATA.state.code == GAME.Const.State.Checkmate) {
|
||||
background_color = INTERFACE.Color.HintCheck;
|
||||
}
|
||||
switch(hover_state) {
|
||||
@ -765,15 +765,20 @@ const INTERFACE = {
|
||||
}
|
||||
}
|
||||
|
||||
if(GAME_DATA.state.code == GAME.Const.State.Resign) {
|
||||
ctx.fillStyle = INTERFACE.Color.HintCheck;
|
||||
message = LANG("resign");
|
||||
} else if(GAME_DATA.state.check != 0 || GAME_DATA.state.code == GAME.Const.State.Checkmate) {
|
||||
ctx.fillStyle = INTERFACE.Color.HintCheck;
|
||||
if(GAME_DATA.state.code == GAME.Const.State.Checkmate) {
|
||||
switch(GAME_DATA.state.code) {
|
||||
case GAME.Const.State.Resign: {
|
||||
ctx.fillStyle = INTERFACE.Color.HintCheck;
|
||||
message = LANG("resign");
|
||||
} break;
|
||||
case GAME.Const.State.Checkmate: {
|
||||
ctx.fillStyle = INTERFACE.Color.HintCheck;
|
||||
message = LANG("checkmate");
|
||||
} else {
|
||||
message = LANG("check");
|
||||
} break;
|
||||
default: {
|
||||
if(GAME_DATA.state.check != 0) {
|
||||
ctx.fillStyle = INTERFACE.Color.HintCheck;
|
||||
message = LANG("check");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user