DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

f4d2db42d104217fd3e486455a2576a2fc17a7c5 — skye 1 year, 7 months ago 0bac8c5
feat(client): more checks when clicking a supply
1 files changed, 12 insertions(+), 4 deletions(-)

M client/src/plugins/game/supply/mod.rs
M client/src/plugins/game/supply/mod.rs => client/src/plugins/game/supply/mod.rs +12 -4
@@ 9,7 9,7 @@
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

use crate::{plugins::GameActionCreateCallEvent, api::game::{Action, Command}, Global};
use crate::{plugins::GameActionCreateCallEvent, api::game::{Action, Command}, Global, game_status::PlayerState};

use super::{
    card::{visual_card_kind, VisualCard, VisualCardBundle, ClickedCard},


@@ 108,11 108,19 @@ fn handle_clicked_supply_pile(

    commands.entity(entity).remove::<ClickedCard>();

    if game_data.game_status.as_ref().unwrap()
        .players.get(&global.user.as_ref().unwrap().id)
            .unwrap().currency < card.card.cost {
    let player = game_data.game_status.as_ref().unwrap()
        .players.get(&global.user.as_ref().unwrap().id).unwrap();

    if player.state != PlayerState::BuyPhase {
        // we ain't buying rn
        return;
    } else if player.currency < card.card.cost {
        // not enough currency
        return;
    } else if game_data.game_status.as_ref().unwrap()
        .supply_piles.get(card_kind.0).unwrap().amount <= 0 {
        // no cards in supply
        return;
    }

    gac_ev_w.send(GameActionCreateCallEvent {