fix: 炸弹比较先比张数再比牌值
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user