/*
* This file is part of laurelin_client
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
use serde::{Deserialize, Serialize};
use serde_repr::Deserialize_repr;
use super::user::User;
mod forming;
pub use forming::*;
mod my_games;
pub use my_games::*;
mod join;
pub use join::*;
mod create;
pub use create::*;
mod create_action;
pub use create_action::*;
mod details;
pub use details::*;
#[derive(Deserialize, Serialize, Clone)]
pub enum Command {
/// draw N amount of cards from deck
Draw { amount: u32 },
/// discard card from hand in slot N
Discard { index: u32 },
/// shuffle discard pile to deck
ShuffleDiscardToDeck { seed: u32 },
}
#[derive(Deserialize, Clone)]
pub struct Action {
pub id: String,
pub created_at: String,
pub updated_at: String,
pub game_id: String,
pub invoker: String,
pub target: String,
pub command: Command,
}
#[derive(Debug, Deserialize_repr, Clone, PartialEq)]
#[repr(u8)]
pub enum GameState {
Forming = 0,
InProgress= 1,
Finished = 2,
Cancelled = 3,
}
#[derive(Deserialize, Clone)]
pub struct Game {
pub id: String,
pub created_at: String,
pub updated_at: String,
pub ended_at: String,
pub host_id: String,
pub host: Option<User>,
pub guest_id: String,
pub guest: Option<User>,
pub state: GameState,
pub turn: u8,
pub actions: Option<Vec<Action>>,
}