Skip to content

Commit

Permalink
Fixed movement bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapsyloffer committed Sep 3, 2024
1 parent 295249a commit cbfb83f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/move_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,20 @@ pub async fn do_move(game_hodler: &GameHodler, url: &String, move_p: &MovementAc
.set_state(b4_a.get_state());
} else {
//Insert previous move in the game hodler.
game_hodler.moves.lock().unwrap().insert(String::from(url), (move_p.clone(), move_a.clone()));
game_hodler.moves.lock().unwrap().insert(String::from(url), (move_p.clone(), move_a.clone()));
game.next_turn();

//AI CODE
//TODO: Get rid of.
if game.get_players().0 == "ChumBucketAI" && game.get_turn() == Tile::Black {
let (ai_p, ai_a) = ai_move(game, Tile::White);
game_hodler.moves.lock().unwrap().insert(String::from(url), (ai_p.clone(), ai_a.clone()));
game.next_turn();
}
if game.get_players().1 == "ChumBucketAI" && game.get_turn() == Tile::White {
let (ai_p, ai_a) = ai_move(game, Tile::White);
game_hodler.moves.lock().unwrap().insert(String::from(url), (ai_p.clone(), ai_a.clone()));
game.next_turn();
}

for board in game.get_boards() {
Expand All @@ -122,8 +124,7 @@ pub async fn do_move(game_hodler: &GameHodler, url: &String, move_p: &MovementAc
break;
}
}

game.next_turn();
println!("{}", game.display());
}
}

Expand Down

0 comments on commit cbfb83f

Please sign in to comment.