@@ 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 {