diff --git a/src/lib.rs b/src/lib.rs index 094d8fe..f4d8b1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -337,6 +337,7 @@ impl Game { } pub fn resolution(&mut self, move_: Move, agents: &[&dyn Agent]) -> CoupResult { + self.players[self.turn].coins -= move_.action.coin_cost(); match move_.action { Income => self.players[self.turn].coins += 1, ForeignAid => self.players[self.turn].coins += 2, diff --git a/src/test.rs b/src/test.rs index dd2e1f9..5683bc4 100644 --- a/src/test.rs +++ b/src/test.rs @@ -291,7 +291,7 @@ fn test_resolution() { let deck = vec![Contessa, Contessa]; let discard = vec![]; let players = vec![ - Player { coins: 2, cards: vec![Duke, Assassin] }, + Player { coins: 7, cards: vec![Duke, Assassin] }, Player { coins: 1, cards: vec![Captain] }, ]; let game = Game { @@ -308,7 +308,7 @@ fn test_resolution() { action: Income, target: None, }, &[&dummy_agent, &dummy_agent]).unwrap(); - assert_eq!(game.players[0].coins, 3); + assert_eq!(game.players[0].coins, 8); } // Test foreign aid @@ -318,7 +318,7 @@ fn test_resolution() { action: ForeignAid, target: None, }, &[&dummy_agent, &dummy_agent]).unwrap(); - assert_eq!(game.players[0].coins, 4); + assert_eq!(game.players[0].coins, 9); } // Test coup / assassinate @@ -330,6 +330,7 @@ fn test_resolution() { }, &[&dummy_agent, &loser_agent]).unwrap(); assert!(game.players[1].cards.is_empty()); assert_eq!(game.discard, vec![Captain]); + assert_eq!(game.players[0].coins, 0); } // Test steal @@ -339,7 +340,7 @@ fn test_resolution() { action: Steal, target: Some(1), }, &[&dummy_agent, &dummy_agent]).unwrap(); - assert_eq!(game.players[0].coins, 3); + assert_eq!(game.players[0].coins, 8); assert_eq!(game.players[1].coins, 0); }