DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

079466e0e3c187fdd2be25787ad148ef7e50bc99 — Jonni Liljamo 1 year, 7 months ago 43cecde
feat(client): check for player buys
2 files changed, 9 insertions(+), 1 deletions(-)

M client/src/game_status/parser.rs
M client/src/plugins/game/supply/mod.rs
M client/src/game_status/parser.rs => client/src/game_status/parser.rs +6 -1
@@ 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());

M client/src/plugins/game/supply/mod.rs => client/src/plugins/game/supply/mod.rs +3 -0
@@ 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;