Fix bugs around AI opponents.
This commit is contained in:
@@ -1290,11 +1290,14 @@ func (g *Game) runBattle() *BattleResult {
|
||||
}
|
||||
}
|
||||
|
||||
// A single side still holding a pet in play wins; anything else
|
||||
// (everyone out, or a stalemate with pets on both sides) is a draw.
|
||||
// A single side that can still field a pet wins; anything else (everyone
|
||||
// out, or a stalemate with pets on both sides) is a draw. We test canField,
|
||||
// not unit, because the loop can break the instant one side runs out while
|
||||
// the other's current pet has just fainted — that side still has pets left
|
||||
// in its stack (it simply wasn't refilled) and is the rightful winner.
|
||||
winner := -1
|
||||
for seat, s := range sides {
|
||||
if s.unit != nil {
|
||||
if s.canField() {
|
||||
if winner >= 0 {
|
||||
winner = -1 // stalemate / >2-player safety
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user