Skip to content

Commit 06c902c

Browse files
committed
test: cover built-in combat profile override guards
1 parent 3ca5d66 commit 06c902c

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

internal/worldruntime/combat_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,32 @@ func TestRegisterStaticActorCombatProfileRejectsDuplicateName(t *testing.T) {
611611
}
612612
}
613613

614+
func TestRegisterStaticActorCombatProfileRejectsBuiltInOverride(t *testing.T) {
615+
for _, profile := range []string{StaticActorCombatKindTrainingDummy, StaticActorCombatProfilePracticeMob} {
616+
t.Run(profile, func(t *testing.T) {
617+
before, ok := BootstrapStaticActorCombatProfileDefaults(profile)
618+
if !ok {
619+
t.Fatalf("expected built-in profile %q defaults to resolve before override attempt", profile)
620+
}
621+
if RegisterStaticActorCombatProfile(profile, StaticActorCombatProfileDefaults{
622+
MaxHP: 99,
623+
DamagePerNormalAttack: 9,
624+
RespawnDelay: TrainingDummyBootstrapRespawnDelay,
625+
}) {
626+
t.Fatalf("expected built-in profile %q override to fail closed", profile)
627+
}
628+
UnregisterStaticActorCombatProfileForTest(profile)
629+
after, ok := BootstrapStaticActorCombatProfileDefaults(profile)
630+
if !ok {
631+
t.Fatalf("expected built-in profile %q defaults to remain available after rejected override", profile)
632+
}
633+
if after.MaxHP != before.MaxHP || after.DamagePerNormalAttack != before.DamagePerNormalAttack || after.AttackValue != before.AttackValue || after.DefenseValue != before.DefenseValue || after.Level != before.Level || after.Rank != before.Rank || after.RespawnDelay != before.RespawnDelay || !after.DeathReward.Empty() {
634+
t.Fatalf("expected rejected built-in override to preserve defaults for %q, before=%+v after=%+v", profile, before, after)
635+
}
636+
})
637+
}
638+
}
639+
614640
func TestBootstrapStaticActorCurrentHPSupportsTrainingDummyCombatProfile(t *testing.T) {
615641
currentHP, ok := BootstrapStaticActorCurrentHP(StaticActorCombatProfileTrainingDummy)
616642
if !ok {

0 commit comments

Comments
 (0)