modes:pair:footstool: refactored for better playability

Full footstools only proc on equivalence, otherwise high cards must
proc some form of footstool to get a half footstool.
This commit is contained in:
2026-04-05 04:39:20 +01:00
committed by oreodave
parent 072159399d
commit 3168ce1ef0

View File

@@ -48,11 +48,26 @@ impl Hand for Pair {
matches!(self.0, Card::PlayingCard(_)) matches!(self.0, Card::PlayingCard(_))
} }
fn footstool(&self, other: &Self) -> Footstool { fn footstool(&self, b: &Self) -> Footstool {
// A pair footstools the other <=> the highest cards of both footstool match self.cmp(b) {
// each other => we can rely on the footstool implementation of Single // There is no footstool if self is beaten by other.
// for this. Ordering::Less => Footstool::None,
Single(self.1).footstool(&Single(other.1)) // We can only full footstool if we have equivalent pairs.
Ordering::Equal => Footstool::Full,
// Half footstools can proc if self.1 footstools other.1 (full or
// half).
Ordering::Greater => {
// By construction, Pair::1 is always a playing card so we may
// safely unwrap here.
let s1 = Single::new(self.1).unwrap();
let s2 = Single::new(b.1).unwrap();
if s1.footstool(&s2) != Footstool::None {
Footstool::Half
} else {
Footstool::None
}
}
}
} }
} }