Skip to main content

api/dto/
plays.rs

1use serde::{Deserialize, Serialize};
2
3use super::{CardDTO, CardIdDTO, PlayerDTO};
4
5/// A tuple representing a single play in the game: the player and the card they played.
6pub type PlayDTO = (PlayerDTO, CardDTO);
7
8/// Represents the possible actions a player can take during a turn.
9#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
10pub enum PlayActionDTO {
11    /// The specified player plays a card.
12    Play(PlayerDTO),
13
14    /// The specified player calls "Go".
15    Go(PlayerDTO),
16
17    /// The pone's hand is being scored.
18    ScorePone,
19}
20
21/// Represents the current state of plays during a round for API clients.
22#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
23pub struct PlaysDTO {
24    /// The action that the next player is expected to take.
25    pub next_action: PlayActionDTO,
26
27    /// The list of legal card IDs that the current user can play.
28    /// Will be empty if the next action is on the opponent.
29    pub legal_plays: Vec<CardIdDTO>,
30
31    /// The plays made so far in the current round.
32    pub current: Vec<PlayDTO>,
33
34    /// The plays made in previous rounds.
35    pub previous: Vec<PlayDTO>,
36
37    /// The running total of points in the current play sequence.
38    pub running_total: u8,
39}