60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package gameserver
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
"gac-hkrpg-go/internal/common"
|
|
)
|
|
|
|
func TestPeakConfigDoesNotUseSameNumberedMazeCountdown(t *testing.T) {
|
|
chdirRepositoryRoot(t)
|
|
data := getChallengeData()
|
|
checked := false
|
|
for key, stage := range data.Peak {
|
|
id, _ := strconv.ParseUint(key, 10, 32)
|
|
if data.Countdowns[uint32(id)] == 0 || len(data.Stages[stage.EventID].Monsters) == 0 {
|
|
continue
|
|
}
|
|
s := &Session{}
|
|
if err := setPeakBattleConfig(s, []uint32{1}, uint32(id), stage.EventID, stage.Buffs); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if s.ChallengeBattleConfig.BattleType != common.BattleTypeAA {
|
|
t.Fatal("Peak was classified by a Maze ID")
|
|
}
|
|
if s.ChallengeBattleConfig.CycleCount == data.Countdowns[uint32(id)] {
|
|
t.Fatal("Peak inherited the same-numbered Maze countdown")
|
|
}
|
|
checked = true
|
|
}
|
|
if !checked {
|
|
t.Fatal("fixture has no overlapping Peak/Maze IDs")
|
|
}
|
|
}
|
|
|
|
func TestPeakLimitsKeepNormalAndHardBossSeparate(t *testing.T) {
|
|
r := peakBattleRules{TurnLimits: map[string]uint32{
|
|
"ChallengePeak_Mob_Turn_Limit": 9,
|
|
"ChallengePeak_Boss_Turn_Limit": 7,
|
|
"ChallengePeak_HardBoss_Turn_Limit": 3,
|
|
}}
|
|
for _, tc := range []struct {
|
|
stage PeakStageData
|
|
event, want uint32
|
|
}{
|
|
{PeakStageData{}, 100, 9},
|
|
{PeakStageData{IsBoss: true, HardEventID: 101}, 100, 7},
|
|
{PeakStageData{IsBoss: true, HardEventID: 101}, 101, 3},
|
|
} {
|
|
got, err := r.limit(tc.stage, tc.event)
|
|
if err != nil || got != tc.want {
|
|
t.Fatalf("limit=%d want=%d err=%v", got, tc.want, err)
|
|
}
|
|
}
|
|
delete(r.TurnLimits, "ChallengePeak_HardBoss_Turn_Limit")
|
|
if _, err := r.limit(PeakStageData{IsBoss: true, HardEventID: 101}, 101); err == nil {
|
|
t.Fatal("missing native limit silently fell back")
|
|
}
|
|
}
|