DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 7fcf86f66ff88a38f8fe1baed9943528e4fa08cb deck-builder/client/src/api/game/mod.rs -rw-r--r-- 1.2 KiB
7fcf86f6 — skye fix: rename docker function in api dev-launch.sh 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * 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 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)]
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(Deserialize)]
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: u8,
    pub turn: u8,
    pub actions: Option<Vec<Action>>,
}