From a226d72e51eecb768b13600303f73483118d9104 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 10 Jun 2026 01:48:28 -0400 Subject: feat: implemented janky object interaction model --- internal/world/room.go | 55 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) (limited to 'internal/world/room.go') diff --git a/internal/world/room.go b/internal/world/room.go index a92a428..6c2d0e3 100644 --- a/internal/world/room.go +++ b/internal/world/room.go @@ -1,5 +1,7 @@ package world +import "gopkg.in/yaml.v3" + type ExitDir string const ( @@ -41,13 +43,50 @@ type SpawnDef struct { RespawnTicks int `yaml:"respawn_ticks"` } +type ExitDef struct { + Room int `yaml:"room"` + Condition *ExitCondition `yaml:"condition"` + BlockedMessage string `yaml:"blocked_message"` +} + +func (e *ExitDef) UnmarshalYAML(value *yaml.Node) error { + if value.Kind == yaml.ScalarNode { + var n int + if err := value.Decode(&n); err != nil { + return err + } + e.Room = n + return nil + } + type raw ExitDef + return value.Decode((*raw)(e)) +} + +type ExitCondition struct { + Flag string `yaml:"flag"` + Value any `yaml:"value"` + Not bool `yaml:"not"` +} + type Room struct { - ID int `yaml:"id"` - Name string `yaml:"name"` - Description string `yaml:"description"` - MapSymbol string `yaml:"map_symbol"` - Exits map[ExitDir]int `yaml:"exits"` - Objects []string `yaml:"objects"` - Spawns []SpawnDef `yaml:"spawns"` - Mobs []string `yaml:"mobs"` + ID int `yaml:"id"` + Name string `yaml:"name"` + Description string `yaml:"description"` + MapSymbol string `yaml:"map_symbol"` + Exits map[ExitDir]ExitDef `yaml:"exits"` + Objects []RoomObject `yaml:"objects"` + Spawns []SpawnDef `yaml:"spawns"` + Mobs []string `yaml:"mobs"` + OnEnter []EnterStep `yaml:"on_enter"` +} + +type EnterStep struct { + Message string `yaml:"message"` + Condition *ExitCondition `yaml:"condition"` +} + +type RoomObject struct { + ID string `yaml:"id"` + WanderRooms []int `yaml:"wander_rooms"` + WanderInterval int `yaml:"wander_interval"` } -- cgit v1.2.3