Actually charge for move resolutions

This commit is contained in:
Dane Johnson 2022-05-20 12:01:30 -05:00
parent 1c8ffb151c
commit b41e4fa052
2 changed files with 6 additions and 4 deletions

View File

@ -337,6 +337,7 @@ impl Game {
}
pub fn resolution(&mut self, move_: Move, agents: &[&dyn Agent]) -> CoupResult<Phase> {
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,

View File

@ -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);
}