summaryrefslogtreecommitdiff
path: root/src/session.rs
blob: 4797c5c3bcb285ca39bef9ed8c4a97b80b97d364 (plain)
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
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use tokio::sync::broadcast;

pub struct Session {
    pub steam_name: String,
    pub seats: HashMap<String, Seat>,
    pub update_tx: broadcast::Sender<PlayUpdate>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum HandObject {
    CustomDeck(CustomDeck),
}

// TODO: These fields will be used in the future. When they are, the dead_code lint should no longer
//       be suppressed.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[allow(dead_code)]
pub struct CustomDeck {
    /// The path/URL of the face cardsheet.
    face: String,
    /// The path/URL of the back cardsheet or card back.
    back: String,
    /// If each card has a unique card back (via a cardsheet).
    unique_back: bool,
    /// The number of columns on the cardsheet.
    width: f64,
    /// The number of rows on the cardsheet.
    height: f64,
    /// The number of cards on the cardsheet.
    number: f64,
    /// Whether the cards are horizontal, instead of vertical.
    sideways: bool,
    /// Whether the card back should be used as the hidden image (instead of the last slot of the
    /// `face` image).
    back_is_hidden: bool,
    /// ID of the custom card within the deck.
    card_id: f64,
}

pub struct Seat {
    pub hand: Vec<HandObject>,
}

#[derive(Clone)]
pub enum PlayUpdate {
    HandUpdate(String, Vec<HandObject>),
}

impl Session {
    pub fn new(steam_name: String) -> Self {
        let (update_tx, _) = broadcast::channel(10);

        Session {
            steam_name,
            seats: HashMap::new(),
            update_tx,
        }
    }
}