fix: 炸弹比较先比张数再比牌值

This commit is contained in:
wtz
2026-02-22 22:50:45 +08:00
parent a0a0c0ff5e
commit 546a176a9f
2 changed files with 23 additions and 1 deletions

View File

@@ -256,6 +256,12 @@ func (cl *CardLogic) CanPlay(cards []models.Card, lastPlay *models.PlayRecord) b
if cardType == models.CardTypeBomb {
if lastPlay.CardType == models.CardTypeBomb {
// 先比张数,张数多的赢;张数相同再比牌值
myCount := cl.getBombCount(cards)
lastCount := cl.getBombCount(lastPlay.Cards)
if myCount != lastCount {
return myCount > lastCount
}
return cl.getMainValue(cards) > cl.getMainValue(lastPlay.Cards)
}
if lastPlay.CardType == models.CardTypeRocket {
@@ -310,6 +316,17 @@ func (cl *CardLogic) getMainValue(cards []models.Card) int {
}
}
return maxValue
return maxValue
}
func (cl *CardLogic) getBombCount(cards []models.Card) int {
counts := cl.getValueCounts(cards)
for _, c := range counts {
if c >= 3 {
return c
}
}
return 0
}
type GameManager struct {