diff --git a/src/components/board.rs b/src/components/board.rs index aef3a7c..3ee4443 100644 --- a/src/components/board.rs +++ b/src/components/board.rs @@ -43,15 +43,12 @@ pub fn BoardCreator( // Subsequent turns - allow placing trap or moving player let player_pos = find_player(¤t_board); if let Some((player_row, player_col)) = player_pos { - if is_adjacent(player_row, player_col, row, col) { - if row == 0 { - // Reached top row - game can be finished - current_board.grid[row][col] = CellContent::Player; - board.set(current_board); + if player_row == 0 || is_adjacent(player_row, player_col, row, col) { + if row == usize::MAX { // Special case for final move finished.set(true); } else { - current_board.grid[row][col] = CellContent::Player; current_board.grid[player_row][player_col] = CellContent::Empty; + current_board.grid[row][col] = CellContent::Player; board.set(current_board); current_turn.update(|t| *t += 1); } @@ -65,6 +62,25 @@ pub fn BoardCreator( view! {
+ {move || { + let player_pos = find_player(&board.get()); + if let Some((row, _)) = player_pos { + if row == 0 { + view! { + + }.into_any() + } else { + view! {
}.into_any() + } + } else { + view! {
}.into_any() + } + }}