cribbage_core/hand/
crib_part.rs1use crate::card::Card;
2use crate::hand::CribCards;
3
4pub struct TwoPlayerCribPart {
5 cards: [Card; 2],
6}
7
8impl TwoPlayerCribPart {
9 pub(in crate::hand) fn new(cards: [Card; 2]) -> TwoPlayerCribPart {
10 TwoPlayerCribPart { cards }
11 }
12
13 pub fn cards(&self) -> &[Card] {
14 &self.cards
15 }
16
17 #[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_pass_by_value))]
18 pub fn combine(self, other: TwoPlayerCribPart) -> CribCards {
19 CribCards::new([self.cards[0], self.cards[1], other.cards[0], other.cards[1]])
20 }
21}
22
23pub struct ThreePlayerCribPart {
24 card: Card,
25}
26
27impl ThreePlayerCribPart {
28 pub(in crate::hand) fn new(card: Card) -> ThreePlayerCribPart {
29 ThreePlayerCribPart { card }
30 }
31
32 #[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_pass_by_value))]
33 pub fn combine(
34 self,
35 other1: ThreePlayerCribPart,
36 other2: ThreePlayerCribPart,
37 starter: Card,
38 ) -> CribCards {
39 CribCards::new([self.card, other1.card, other2.card, starter])
40 }
41}
42
43pub struct FourPlayerCribPart {
44 card: Card,
45}
46
47impl FourPlayerCribPart {
48 pub(in crate::hand) fn new(card: Card) -> FourPlayerCribPart {
49 FourPlayerCribPart { card }
50 }
51
52 #[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_pass_by_value))]
53 pub fn combine(
54 self,
55 other1: FourPlayerCribPart,
56 other2: FourPlayerCribPart,
57 other3: FourPlayerCribPart,
58 ) -> CribCards {
59 CribCards::new([self.card, other1.card, other2.card, other3.card])
60 }
61}