DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

b8b314f7e702f8f57223594ab73eba35d1a4ef64 — Jonni Liljamo 1 year, 5 months ago 5eb6874
feat(client): take card cost into account
3 files changed, 8 insertions(+), 4 deletions(-)

M client/src/api/game/mod.rs
M client/src/game_status/mod.rs
M client/src/game_status/parser.rs
M client/src/api/game/mod.rs => client/src/api/game/mod.rs +1 -1
@@ 35,7 35,7 @@ pub use details::*;
pub enum Command {
    InitSupplyPile { card: Card, amount: usize },
    /// take a card from pile N
    TakeFromPile { index: usize },
    TakeFromPile { index: usize, for_cost: i16 },
    /// draw N amount of cards from deck
    Draw { amount: usize },
    /// discard card from hand in slot N

M client/src/game_status/mod.rs => client/src/game_status/mod.rs +2 -2
@@ 28,7 28,7 @@ pub struct Card {
    pub short_details: Vec<String>,
    /// longer explanations of features of the card
    pub long_details: Vec<String>,
    pub cost: u32,
    pub cost: i16,
    /// if set, use this?
    //vp_cost: Option<u32>,
    pub actions: Vec<CardAction>,


@@ 42,7 42,7 @@ pub struct SupplyPile {
    pub amount: usize,
}

#[derive(Deserialize, Serialize, Clone, Copy)]
#[derive(Deserialize, Serialize, Clone, Copy, PartialEq)]
pub enum PlayerState {
    /// e.g. not their turn
    Idle,

M client/src/game_status/parser.rs => client/src/game_status/parser.rs +5 -1
@@ 79,7 79,7 @@ pub fn parse(game: &Game) -> Result<GameStatus, ()> {

                game_status.supply_piles.push(pile);
            }
            Command::TakeFromPile { index } => {
            Command::TakeFromPile { index, for_cost } => {
                // index should be within range
                assert!(*index <= game_status.supply_piles.len());
                let pile = &mut game_status.supply_piles.get_mut(*index)


@@ 89,6 89,10 @@ pub fn parse(game: &Game) -> Result<GameStatus, ()> {
                assert!(pile.amount > 0);
                pile.amount = pile.amount - 1;

                // player should have enough
                assert!(*for_cost <= target.currency);
                target.currency = target.currency - for_cost;

                target.discard.push(pile.card.clone());
            }
            Command::Draw { amount } => {