1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::dto::{CardIdDTO, PlayerDTO};
6
7#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
12pub enum PeggingKindDTO {
13 #[doc(hidden)]
14 Fifteens,
15
16 #[doc(hidden)]
17 Pairs,
18
19 #[doc(hidden)]
20 Runs,
21
22 #[doc(hidden)]
23 Flush,
24
25 #[doc(hidden)]
26 LastCard,
27
28 #[doc(hidden)]
29 ThirtyOne,
30
31 #[doc(hidden)]
32 HisHeels,
33
34 #[doc(hidden)]
35 Nobs,
36}
37
38impl std::fmt::Display for PeggingKindDTO {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 match &self {
41 PeggingKindDTO::Fifteens => "Fifteens",
42 PeggingKindDTO::Pairs => "Pairs",
43 PeggingKindDTO::Runs => "Runs",
44 PeggingKindDTO::Flush => "Flush",
45 PeggingKindDTO::LastCard => "Last Card",
46 PeggingKindDTO::ThirtyOne => "Thirty One",
47 PeggingKindDTO::HisHeels => "His Heels",
48 PeggingKindDTO::Nobs => "Nobs",
49 }
50 .fmt(f)
51 }
52}
53
54#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
56pub struct PeggingSummaryDTO {
57 pub points: usize,
59
60 pub breakdown: Vec<Vec<CardIdDTO>>,
62}
63
64pub type PeggingBreakdownDTO = HashMap<PeggingKindDTO, PeggingSummaryDTO>;
66
67#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
71pub struct PeggingDTO {
72 pub recipient: Option<PlayerDTO>,
74
75 pub breakdown: PeggingBreakdownDTO,
77}
78
79impl PeggingDTO {
80 pub fn new(recipient: PlayerDTO) -> Self {
82 Self {
83 recipient: Some(recipient),
84 breakdown: HashMap::default(),
85 }
86 }
87}