Impliment PartialOrd for TwoPair
This commit is contained in:
18
src/hand.rs
18
src/hand.rs
@@ -72,7 +72,23 @@ impl PartialOrd for PokerHand {
|
||||
|
||||
self.cards.partial_cmp(&other.cards)
|
||||
}
|
||||
HandType::TwoPair => todo!(),
|
||||
HandType::TwoPair => {
|
||||
let selfpairs: Vec<(&CardValue, &u8)> =
|
||||
selfmap.iter().filter(|&p| *p.1 == 2).collect();
|
||||
let otherpairs: Vec<(&CardValue, &u8)> =
|
||||
othermap.iter().filter(|&p| *p.1 == 2).collect();
|
||||
|
||||
for i in 0..1 {
|
||||
let pairvalue = selfpairs[i].0;
|
||||
let otherpairvalue = otherpairs[i].0;
|
||||
|
||||
if pairvalue != otherpairvalue {
|
||||
return pairvalue.partial_cmp(otherpairvalue);
|
||||
}
|
||||
}
|
||||
|
||||
self.cards.partial_cmp(&other.cards)
|
||||
}
|
||||
HandType::ThreeOfAKind => todo!(),
|
||||
HandType::Straight => todo!(),
|
||||
HandType::Flush => todo!(),
|
||||
|
||||
Reference in New Issue
Block a user