fixed scoring bug
multiplier in scoring needs to increase by *100 for each item within the hand type, because ranks are 2-14
This commit is contained in:
parent
f217a95e19
commit
f527c6eb07
19
scoring.go
19
scoring.go
|
@ -54,14 +54,14 @@ func (ph *PokerHand) calculateScore() {
|
|||
if ph.Hand.containsStraightFlush() {
|
||||
ph.Type = StraightFlush
|
||||
ph.Score = ScoreStraightFlush
|
||||
ph.Score += 1000 * ph.Hand.HighestRank().Score()
|
||||
ph.Score += ph.Hand.HighestRank().Score()
|
||||
return
|
||||
}
|
||||
|
||||
if ph.Hand.containsFourOfAKind() {
|
||||
ph.Type = FourOfAKind
|
||||
ph.Score = ScoreFourOfAKind
|
||||
ph.Score += 1000 * ph.Hand.fourOfAKindRank().Score()
|
||||
ph.Score += 10000 * ph.Hand.fourOfAKindRank().Score()
|
||||
ph.Score += 100 * ph.Hand.fourOfAKindKicker().Score()
|
||||
return
|
||||
}
|
||||
|
@ -69,8 +69,7 @@ func (ph *PokerHand) calculateScore() {
|
|||
if ph.Hand.containsFullHouse() {
|
||||
ph.Type = FullHouse
|
||||
ph.Score = ScoreFullHouse
|
||||
// FIXME write a good test for this
|
||||
ph.Score += 1000 * ph.Hand.fullHouseTripsRank().Score()
|
||||
ph.Score += 10000 * ph.Hand.fullHouseTripsRank().Score()
|
||||
ph.Score += 100 * ph.Hand.fullHousePairRank().Score()
|
||||
return
|
||||
}
|
||||
|
@ -110,27 +109,27 @@ func (ph *PokerHand) calculateScore() {
|
|||
if ph.Hand.containsThreeOfAKind() {
|
||||
ph.Type = ThreeOfAKind
|
||||
ph.Score = ScoreThreeOfAKind
|
||||
ph.Score += 1000 * ph.Hand.threeOfAKindTripsRank().Score()
|
||||
ph.Score += 10000 * ph.Hand.threeOfAKindTripsRank().Score()
|
||||
ph.Score += 100 * ph.Hand.threeOfAKindFirstKicker().Score()
|
||||
ph.Score += 10 * ph.Hand.threeOfAKindSecondKicker().Score()
|
||||
ph.Score += ph.Hand.threeOfAKindSecondKicker().Score()
|
||||
return
|
||||
}
|
||||
|
||||
if ph.Hand.containsTwoPair() {
|
||||
ph.Type = TwoPair
|
||||
ph.Score = ScoreTwoPair
|
||||
ph.Score += 1000 * ph.Hand.twoPairBiggestPair().Score()
|
||||
ph.Score += 10000 * ph.Hand.twoPairBiggestPair().Score()
|
||||
ph.Score += 100 * ph.Hand.twoPairSmallestPair().Score()
|
||||
ph.Score += 10 * ph.Hand.twoPairKicker().Score()
|
||||
ph.Score += ph.Hand.twoPairKicker().Score()
|
||||
return
|
||||
}
|
||||
|
||||
if ph.Hand.containsPair() {
|
||||
ph.Type = Pair
|
||||
ph.Score = ScorePair
|
||||
ph.Score += 1000 * ph.Hand.pairRank().Score()
|
||||
ph.Score += 10000 * ph.Hand.pairRank().Score()
|
||||
ph.Score += 100 * ph.Hand.pairFirstKicker().Score()
|
||||
ph.Score += 10 * ph.Hand.pairSecondKicker().Score()
|
||||
ph.Score += ph.Hand.pairSecondKicker().Score()
|
||||
ph.Score += ph.Hand.pairThirdKicker().Score()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ func TestHandDescripionBug(t *testing.T) {
|
|||
assert.Equal(t, weirdOne.Description(), "two pair, tens and sevens with a nine")
|
||||
|
||||
scoreShouldBe := ScoreTwoPair
|
||||
scoreShouldBe += 1000 * TEN.Score()
|
||||
scoreShouldBe += 10000 * TEN.Score()
|
||||
scoreShouldBe += 100 * SEVEN.Score()
|
||||
scoreShouldBe += 10 * NINE.Score()
|
||||
scoreShouldBe += NINE.Score()
|
||||
assert.Equal(t, weirdOne.Score, scoreShouldBe)
|
||||
|
||||
cards := weirdOne.Hand
|
||||
|
|
Loading…
Reference in New Issue