fix: correct self-destruct mutual KO handling
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
This commit is contained in:
@@ -220,6 +220,15 @@ func (f *FightC) buildNoteUseSkillOutboundInfo() info.NoteUseSkillOutboundInfo {
|
||||
return result
|
||||
}
|
||||
|
||||
// normalizeMutualKO intentionally does not revive either side.
|
||||
// Effects that need "survive at 1 HP" on mutual KO must cap damage in their
|
||||
// own implementation instead of relying on a generic round fallback.
|
||||
func normalizeMutualKO(attackerPet, defenderPet *info.BattlePetEntity) {
|
||||
if attackerPet == nil || defenderPet == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FightC) roundOpponentInput(attacker *input.Input) *input.Input {
|
||||
if attacker == nil {
|
||||
return nil
|
||||
@@ -423,8 +432,8 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
return true
|
||||
})
|
||||
|
||||
if defenderPet != nil && attackerPet != nil && defenderPet.Info.Hp <= 0 && attackerPet.Info.Hp <= 0 { //先手方死亡,触发反同归于尽
|
||||
attackerPet.Info.Hp = 1
|
||||
if defenderPet != nil && attackerPet != nil && defenderPet.Info.Hp <= 0 && attackerPet.Info.Hp <= 0 {
|
||||
normalizeMutualKO(attackerPet, defenderPet)
|
||||
}
|
||||
if defenderPet != nil && defenderPet.Info.Hp <= 0 {
|
||||
|
||||
|
||||
32
logic/service/fight/fightc_test.go
Normal file
32
logic/service/fight/fightc_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package fight
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
fightinfo "blazing/logic/service/fight/info"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
func TestNormalizeMutualKODoesNotReviveAttacker(t *testing.T) {
|
||||
attacker := fightinfo.CreateBattlePetEntity(model.PetInfo{
|
||||
ID: 1,
|
||||
Hp: 0,
|
||||
MaxHp: 100,
|
||||
CatchTime: 101,
|
||||
})
|
||||
defender := fightinfo.CreateBattlePetEntity(model.PetInfo{
|
||||
ID: 2,
|
||||
Hp: 0,
|
||||
MaxHp: 100,
|
||||
CatchTime: 202,
|
||||
})
|
||||
|
||||
normalizeMutualKO(attacker, defender)
|
||||
|
||||
if attacker.Info.Hp != 0 {
|
||||
t.Fatalf("expected attacker to remain defeated on mutual KO, got hp=%d", attacker.Info.Hp)
|
||||
}
|
||||
if defender.Info.Hp != 0 {
|
||||
t.Fatalf("expected defender to remain defeated on mutual KO, got hp=%d", defender.Info.Hp)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user