cribbage_core/hand/
dealt_cards.rs

1use crate::card::Card;
2use crate::hand::{FourPlayerCribPart, KeptCards, ThreePlayerCribPart, TwoPlayerCribPart};
3
4pub struct TwoPlayerDeal {
5    cards: [Card; 6],
6}
7
8impl TwoPlayerDeal {
9    pub fn new(cards: [Card; 6]) -> TwoPlayerDeal {
10        TwoPlayerDeal { cards }
11    }
12
13    pub fn cards(&self) -> &[Card] {
14        &self.cards
15    }
16
17    pub fn split(self, keep: [Card; 4], crib: [Card; 2]) -> (KeptCards, TwoPlayerCribPart) {
18        // Todo: Make sure cards specified exist in self.cards
19        (KeptCards::new(keep), TwoPlayerCribPart::new(crib))
20    }
21}
22
23pub struct ThreePlayerDeal {
24    cards: [Card; 5],
25}
26
27impl ThreePlayerDeal {
28    pub fn new(cards: [Card; 5]) -> ThreePlayerDeal {
29        ThreePlayerDeal { cards }
30    }
31
32    pub fn cards(&self) -> &[Card] {
33        &self.cards
34    }
35
36    pub fn split(self, keep: [Card; 4], crib: Card) -> (KeptCards, ThreePlayerCribPart) {
37        (KeptCards::new(keep), ThreePlayerCribPart::new(crib))
38    }
39}
40
41pub struct FourPlayerDeal {
42    cards: [Card; 5],
43}
44
45impl FourPlayerDeal {
46    pub fn new(cards: [Card; 5]) -> FourPlayerDeal {
47        FourPlayerDeal { cards }
48    }
49
50    pub fn cards(&self) -> &[Card] {
51        &self.cards
52    }
53
54    pub fn split(self, keep: [Card; 4], crib: Card) -> (KeptCards, FourPlayerCribPart) {
55        (KeptCards::new(keep), FourPlayerCribPart::new(crib))
56    }
57}