This commit is contained in:
Henri Bourcereau 2024-03-30 16:10:53 +01:00
parent 6a0dc9395a
commit 2139de2fcd
4 changed files with 31 additions and 99 deletions

View file

@ -44,7 +44,7 @@ impl Bot {
}
}
pub fn consume(&mut self, event: &GameEvent) -> Option<GameEvent> {
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
self.game.consume(event);
// println!("bot game {:?}", self.game);
// println!("bot player_id {:?}", self.player_id);
@ -98,13 +98,13 @@ mod tests {
#[test]
fn test_consume() {
let mut bot = Bot::new(Color::Black);
let mut event = bot.consume(&GameEvent::BeginGame { goes_first: 2 });
let mut event = bot.handle_event(&GameEvent::BeginGame { goes_first: 2 });
assert_eq!(event, Some(GameEvent::Roll { player_id: 2 }));
event = bot.consume(&GameEvent::BeginGame { goes_first: 1 });
event = bot.handle_event(&GameEvent::BeginGame { goes_first: 1 });
assert_eq!(event, None);
event = bot.consume(&GameEvent::RollResult {
bot.handle_event(&GameEvent::RollResult {
player_id: 2,
dice: Dice { values: (2, 3) },
});