aboutsummaryrefslogtreecommitdiff
path: root/internal/world/room.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-10 01:48:28 -0400
committerhistoria <[not public]>2026-06-10 01:48:28 -0400
commita226d72e51eecb768b13600303f73483118d9104 (patch)
tree458d15ef049732c15dacc591a830d3beddbedfde /internal/world/room.go
parent6a0f3d7a252de4b1741cfe5e1c561412c602becc (diff)
downloadthehouseoficarus-a226d72e51eecb768b13600303f73483118d9104.tar.gz
feat: implemented janky object interaction model
Diffstat (limited to 'internal/world/room.go')
-rw-r--r--internal/world/room.go55
1 files changed, 47 insertions, 8 deletions
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"`
}