package world import ( "gopkg.in/yaml.v3" "thirdcollapse/internal/action" ) type ExitDir string const ( North ExitDir = "north" South ExitDir = "south" East ExitDir = "east" West ExitDir = "west" Up ExitDir = "up" Down ExitDir = "down" ) var ExitAliases = map[string]ExitDir{ "n": North, "s": South, "e": East, "w": West, "u": Up, "d": Down, } var OppositeExit = map[ExitDir]ExitDir{ North: South, South: North, East: West, West: East, Up: Down, Down: Up, } var ExitOrder = []ExitDir{ "northwest", North, "northeast", East, "southeast", South, "southwest", West, Up, Down, } type SpawnDef struct { ItemID string `yaml:"item_id"` Quantity int `yaml:"quantity"` RespawnTicks int `yaml:"respawn_ticks"` } type ExitDef struct { Room int `yaml:"room"` Condition *action.Condition `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 Room struct { 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 *action.Condition `yaml:"condition"` } type RoomObject struct { ID string `yaml:"id"` WanderRooms []int `yaml:"wander_rooms"` WanderInterval int `yaml:"wander_interval"` }