From 079466e0e3c187fdd2be25787ad148ef7e50bc99 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 16 May 2023 15:21:49 +0300 Subject: [PATCH] feat(client): check for player buys --- client/src/game_status/parser.rs | 7 ++++++- client/src/plugins/game/supply/mod.rs | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/game_status/parser.rs b/client/src/game_status/parser.rs index b3d9a21..dcf535c 100644 --- a/client/src/game_status/parser.rs +++ b/client/src/game_status/parser.rs @@ -117,10 +117,15 @@ fn parse_action(action: &Action, game: &Game, game_status: &mut GameStatus) { // pile should not be empty assert!(pile.amount > 0); - pile.amount -= 1; + + // player should have buys + assert!(target.buys > 0); // player should have enough assert!(*for_cost <= target.currency); + + pile.amount -= 1; + target.buys -= 1; target.currency -= for_cost; target.discard.push(pile.card.clone()); diff --git a/client/src/plugins/game/supply/mod.rs b/client/src/plugins/game/supply/mod.rs index 64f946f..1172696 100644 --- a/client/src/plugins/game/supply/mod.rs +++ b/client/src/plugins/game/supply/mod.rs @@ -149,6 +149,9 @@ fn handle_clicked_supply_pile( if player.state != PlayerState::BuyPhase { // we ain't buying rn return; + } else if player.buys == 0 { + // not enough buys + return; } else if player.currency < card.card.cost { // not enough currency return; -- 2.44.1