fix: clear monster taunt when warrior is dead

This commit is contained in:
2026-03-24 10:27:38 +09:00
parent e13e1e7a7d
commit 4db3ba1fc5
2 changed files with 22 additions and 0 deletions

View File

@@ -91,6 +91,9 @@ func MonsterAI(m *entity.Monster, players []*entity.Player, turnNumber int) (tar
return i, false
}
}
// No living warrior found — clear taunt
m.TauntTarget = false
m.TauntTurns = 0
}
if rand.Float64() < 0.3 {
minHP := int(^uint(0) >> 1)

View File

@@ -46,6 +46,25 @@ func TestAoENoCoopBonus(t *testing.T) {
}
}
func TestMonsterAITauntDeadWarrior(t *testing.T) {
warrior := entity.NewPlayer("Tank", entity.ClassWarrior)
warrior.TakeDamage(warrior.HP) // kill warrior
mage := entity.NewPlayer("Mage", entity.ClassMage)
m := &entity.Monster{Name: "Orc", HP: 50, ATK: 10, DEF: 5, TauntTarget: true, TauntTurns: 2}
idx, isAoE := MonsterAI(m, []*entity.Player{warrior, mage}, 1)
if isAoE {
t.Error("should not AoE")
}
if idx != 1 {
t.Errorf("expected target mage at index 1, got %d", idx)
}
if m.TauntTarget {
t.Error("TauntTarget should be cleared when warrior is dead")
}
}
func TestFleeChance(t *testing.T) {
successes := 0
for i := 0; i < 100; i++ {