Fix a bunch of bugs.
This commit is contained in:
+20
-6
@@ -671,15 +671,19 @@ func (g *Game) runBattle() (*BattleResult, *PendingBattleDecision) {
|
||||
}
|
||||
}
|
||||
|
||||
// hurt fires Hurt effects on a pet that was damaged and survived.
|
||||
// hurt fires Hurt effects on a pet that took damage. It fires even when the
|
||||
// hit was fatal — the Lizard drops its Bee even when killed in one shot —
|
||||
// except for self-buffs marked SurviveOnly (Peacock, Gorilla), which need
|
||||
// the pet to live on.
|
||||
hurt := func(seat int, u *BattleUnit) {
|
||||
if !u.Alive() {
|
||||
return
|
||||
}
|
||||
alive := u.Alive()
|
||||
for _, e := range u.effects() {
|
||||
if e.Trigger != TriggerHurt || !allowed(e, u) {
|
||||
continue
|
||||
}
|
||||
if !alive && e.SurviveOnly {
|
||||
continue
|
||||
}
|
||||
if !spend(seat, e, u.Card.Name) {
|
||||
continue
|
||||
}
|
||||
@@ -787,6 +791,10 @@ func (g *Game) runBattle() (*BattleResult, *PendingBattleDecision) {
|
||||
emitPrevent(target, tu.Card.Name, prev)
|
||||
}
|
||||
if died {
|
||||
// Hurt still fires on a fatal hit (Lizard's Bee), before the faint.
|
||||
if dealt > 0 {
|
||||
hurt(target, tu)
|
||||
}
|
||||
faint(target, tu)
|
||||
sides[target].unit = nil
|
||||
return true
|
||||
@@ -994,8 +1002,10 @@ func (g *Game) runBattle() (*BattleResult, *PendingBattleDecision) {
|
||||
// when its own side is already out (Crocodile's last-pet volley).
|
||||
anyDeath := false
|
||||
for _, q := range plays {
|
||||
// Effects sourced from a specific unit fizzle if it's gone.
|
||||
if q.unit != nil && sides[q.seat].unit != q.unit {
|
||||
// Effects sourced from a specific unit fizzle if it's gone — unless
|
||||
// they're posthumous (the Manatee still adds its Apples after rocking
|
||||
// itself to death).
|
||||
if q.unit != nil && sides[q.seat].unit != q.unit && !q.effect.Posthumous {
|
||||
continue
|
||||
}
|
||||
if q.unit != nil && !allowed(q.effect, q.unit) {
|
||||
@@ -1293,6 +1303,10 @@ func (g *Game) runBattle() (*BattleResult, *PendingBattleDecision) {
|
||||
dealt := []int{dealtA, dealtB}
|
||||
for seat, u := range []*BattleUnit{ua, ub} {
|
||||
if !u.Alive() {
|
||||
// Hurt still fires on a fatal clash (Lizard's Bee), before the faint.
|
||||
if dealt[seat] > 0 {
|
||||
hurt(seat, u)
|
||||
}
|
||||
faint(seat, u)
|
||||
sides[seat].unit = nil
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user