/* * This file is part of laurelin_client * Copyright (C) 2023 Jonni Liljamo * * Licensed under GPL-3.0-only. * See LICENSE for licensing information. */ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::api::game::{Action, Command, Game}; mod parser; #[derive(Deserialize, Serialize, Clone)] pub struct CardAction { pub target: String, pub command: Command, pub seed: u64, } #[derive(Deserialize, Serialize, Clone)] pub struct Card { pub name: String, /// short details shown on the card, e.g. Draw 2 pub short_details: Vec, /// longer explanations of features of the card pub long_details: Vec, pub cost: i16, /// if set, use this? //vp_cost: Option, pub actions: Vec, } /// a supply pile holds an amount of some card pub struct SupplyPile { /// the card type that the supply pile holds pub card: Card, /// the amount of cards currently in the pile pub amount: usize, } #[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq)] pub enum PlayerState { /// e.g. not their turn Idle, /// play phase, playing cards PlayPhase, /// buy phase, buying cards BuyPhase, } pub struct PlayerStatus { pub display_name: String, pub state: PlayerState, pub plays: i16, pub buys: i16, pub currency: i16, pub vp: i16, pub hand: Vec, pub deck: Vec, pub discard: Vec, } /// constructed from a vector of [`Action`]s pub struct GameStatus { /// a modifiable Actions Vector, will be modified when parsing actions, /// used for showing the log pub actions: Vec, pub supply_piles: Vec, /// player ids mapped to statuses pub players: HashMap, } impl GameStatus { pub fn new(game: &Game) -> Self { match parser::parse(game) { Ok(res) => res, Err(_) => panic!("parsing actions failed"), } } }