Skip to content

Commit 3ca5d66

Browse files
committed
test: cover overmax combat hp clamp
1 parent 0b40554 commit 3ca5d66

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

internal/worldruntime/combat_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,30 @@ func TestApplyBootstrapStaticActorNormalAttackClampsFormulaDamageToMinimumOne(t
9999
}
100100
}
101101

102+
func TestApplyBootstrapStaticActorNormalAttackClampsOverMaxRuntimeHPBeforeDamage(t *testing.T) {
103+
const profile = "practice_overmax_wolf"
104+
if !RegisterStaticActorCombatProfile(profile, StaticActorCombatProfileDefaults{
105+
MaxHP: 20,
106+
AttackValue: 7,
107+
DefenseValue: 3,
108+
RespawnDelay: PracticeMobBootstrapRespawnDelay,
109+
}) {
110+
t.Fatalf("expected %q profile registration with formula stats to succeed", profile)
111+
}
112+
t.Cleanup(func() { UnregisterStaticActorCombatProfileForTest(profile) })
113+
114+
nextHP, hpPercent, ok := ApplyBootstrapStaticActorNormalAttack(profile, 25)
115+
if !ok {
116+
t.Fatal("expected registered formula profile normal attack to support over-max runtime HP by clamping first")
117+
}
118+
if nextHP != 16 {
119+
t.Fatalf("expected over-max runtime HP to clamp to max HP before 4 damage, got next HP %d", nextHP)
120+
}
121+
if hpPercent != 80 {
122+
t.Fatalf("expected over-max runtime HP attack to report 80 percent after clamp and damage, got %d", hpPercent)
123+
}
124+
}
125+
102126
func TestBootstrapStaticActorRespawnDelayReturnsTrainingDummyBootstrapDelay(t *testing.T) {
103127
delay, ok := BootstrapStaticActorRespawnDelay(StaticActorCombatKindTrainingDummy)
104128
if !ok {

0 commit comments

Comments
 (0)