diff --git a/game/src/lib.rs b/game/src/lib.rs index 076b20f..956fa93 100644 --- a/game/src/lib.rs +++ b/game/src/lib.rs @@ -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 diff --git a/www/js/game.js b/www/js/game.js index a80e477..bc0e99d 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -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) { diff --git a/www/js/interface.js b/www/js/interface.js index 7b0ed4f..3eb9785 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -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"); + } } }