From 4db3ba1fc5b428eeb9b3a04cd98881a3be79c870 Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Tue, 24 Mar 2026 10:27:38 +0900 Subject: [PATCH] fix: clear monster taunt when warrior is dead --- combat/combat.go | 3 +++ combat/combat_test.go | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/combat/combat.go b/combat/combat.go index e759acb..b928854 100644 --- a/combat/combat.go +++ b/combat/combat.go @@ -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) diff --git a/combat/combat_test.go b/combat/combat_test.go index f56e75b..388c1af 100644 --- a/combat/combat_test.go +++ b/combat/combat_test.go @@ -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++ {