aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_course.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/core_course.go')
-rw-r--r--internal/game/core_course.go60
1 files changed, 15 insertions, 45 deletions
diff --git a/internal/game/core_course.go b/internal/game/core_course.go
index 031eff5..6394b99 100644
--- a/internal/game/core_course.go
+++ b/internal/game/core_course.go
@@ -21,21 +21,17 @@ type ObstaclePhase struct {
}
// ObstacleDef is the YAML representation of a single agility obstacle.
-// Two equivalent forms are supported:
-// - Legacy: Messages (exactly 3) + TicksPerPhase + fail at phase index 1.
-// - Preferred: Phases, an explicit ordered list with per-phase delays and
-// an optional fail_check flag (at most one phase should carry it).
+// Phases is the ordered list of advancement steps, each with a per-phase
+// delay and an optional fail_check flag (at most one phase should carry it).
type ObstacleDef struct {
- RoomID int `yaml:"room_id"`
- Verb string `yaml:"verb"`
- XP int `yaml:"xp"`
- FailDamage [2]int `yaml:"fail_damage"`
- FailChance *float64 `yaml:"fail_chance,omitempty"`
- TicksPerPhase float64 `yaml:"ticks_per_phase"`
- Messages []string `yaml:"messages"`
- Phases []ObstaclePhase `yaml:"phases"`
- ExitDir string `yaml:"exit_dir"`
- OnFailRoom int `yaml:"on_fail,omitempty"`
+ RoomID int `yaml:"room_id"`
+ Verb string `yaml:"verb"`
+ XP int `yaml:"xp"`
+ FailDamage [2]int `yaml:"fail_damage"`
+ FailChance *float64 `yaml:"fail_chance,omitempty"`
+ Phases []ObstaclePhase `yaml:"phases"`
+ ExitDir string `yaml:"exit_dir"`
+ OnFailRoom int `yaml:"on_fail,omitempty"`
}
type CourseConfig struct {
@@ -140,33 +136,13 @@ func (cs *CourseStore) GetObstacle(roomID int) *ObstacleInfo {
}
// resolvePhases converts an ObstacleDef into a normalized PhaseInfo list.
-// Preferred form: explicit Phases. Legacy form: Messages with a shared
-// TicksPerPhase and the failure check at the middle (index 1) phase.
func resolvePhases(obs ObstacleDef) []PhaseInfo {
- if len(obs.Phases) > 0 {
- phases := make([]PhaseInfo, 0, len(obs.Phases))
- for _, p := range obs.Phases {
- phases = append(phases, PhaseInfo{
- Message: p.Message,
- Delay: p.Delay,
- FailCheck: p.FailCheck,
- })
- }
- return phases
- }
- msgs := obs.Messages
- phases := make([]PhaseInfo, 0, len(msgs))
- for i, m := range msgs {
- var delay float64
- if i == 0 {
- delay = 0
- } else {
- delay = obs.TicksPerPhase
- }
+ phases := make([]PhaseInfo, 0, len(obs.Phases))
+ for _, p := range obs.Phases {
phases = append(phases, PhaseInfo{
- Message: m,
- Delay: delay,
- FailCheck: i == 1,
+ Message: p.Message,
+ Delay: p.Delay,
+ FailCheck: p.FailCheck,
})
}
return phases
@@ -197,12 +173,6 @@ func (cs *CourseStore) resolveExitTarget(roomID int, dir string) int {
return 0
}
switch x := v.(type) {
- case int:
- return x
- case int64:
- return int(x)
- case float64:
- return int(x)
case map[string]any:
if r, ok := x["room"]; ok {
switch y := r.(type) {