diff options
| author | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
| commit | abd612c15799f604e671e83dc7c410ed2b44185f (patch) | |
| tree | 0597ca92350de73aac2a7cf26b2f2d6595dac0cc /AGENTS.md | |
| parent | 2725e2927a1595c7b100d942d1f14146252adeb7 (diff) | |
| download | thehouseoficarus-abd612c15799f604e671e83dc7c410ed2b44185f.tar.gz | |
slop refactor
Diffstat (limited to 'AGENTS.md')
| -rw-r--r-- | AGENTS.md | 87 |
1 files changed, 46 insertions, 41 deletions
@@ -22,34 +22,39 @@ Dependencies: `gopkg.in/yaml.v3`, `github.com/gorilla/websocket`. ``` cmd/mud/main.go Entry point — config loading, multi-listener, tick subscriber registration internal/ - config/ YAML config (telnet, telnet_tls, http, https listeners, color targets) - net/ Conn interface (tcpConn, wsConn), Hub, Session, session states, IAC echo - game/ Game struct, HandleSession state machine, command registry, all game logic - hacking/ Minigame interface + 3 implementations (Wumpus, Mastermind, Liar's Dice) - action/ Behavior structs (GatherConfig, TalkConfig, UseConfig), SuccessChance - player/ Player struct, skills, inventory, bank, equipment, accounts, XP, validation - world/ World, RoomDef, MobDef, MobInstance, ObjState, ground items, wandering - combat/ Combat state tracking, classic formulas (HitChance, MaxHit, AttackRoll) - object/ ItemDef, ObjectDef, ItemStore, ObjectStore, EquipSlot, WeaponType, ItemStats - engine/ Tick scheduler — configurable ms interval, subscriber pattern, ToTicks() - color/ xterm-256 color system with auto ANSI downgrade, gradients, inline tags + behavior/ YAML behavior definitions (GatherConfig, TalkConfig, UseConfig, Condition) + combat/ Tracker struct + classic formulas (HitChance, MaxHit, AttackRoll) + config/ YAML config (telnet, telnet_tls, http, https listeners, color targets) + color/ xterm-256 color system with auto ANSI downgrade, gradients, inline tags + engine/ Tick scheduler — configurable ms interval, subscriber pattern, ToTicks() + game/ Game orchestrator (embedded Deps), state machine, command dispatch + hacking/ Minigame interface + 3 implementations (Wumpus, Mastermind, Liar's Dice) + item/ ItemDef, ItemStore, EquipSlot, WeaponType, ItemStats (was part of object/) + net/ Conn interface (tcpConn, wsConn), Hub, Session, session states, IAC echo + object/ ObjectDef, ObjectStore, UseInteraction, SafespotConfig (room objects only) + player/ Player struct, skills, inventory, bank, equipment, accounts, XP, validation + ui/ Pure renderers (progress bars, Unicode tables) — independent of game state + validate/ Startup integrity checks (duplicate IDs, references, orphan rooms) + world/ World, RoomDef, MobDef, MobInstance, MobStore, ObjState, ground items ``` -`internal/game/` is organized by file name prefix for easy navigation: +`internal/game/` is organized by file prefix: -| Prefix | Purpose | Count | -|---|---|---| -| `game.go`, `cmd_registry.go`, `tick.go` | Core state machine, command dispatch, tick callbacks | 3 | -| `core_*.go` | Infrastructure — types, utils, login, production engine, skill XP, flags, courses, equipment, stations, messages, startup validation | 13 | -| `action_*.go` | Tick-based action lifecycles — gather, firemaking, talk, use, search, thieving, farming, agility, scavenging, assassin, fletching, cleaning, room scripts, targeting | 16 | -| `cmd_*.go` | Command handlers — one file per command or command group | 49 | -| `sys_*.go` | Game subsystems — technology, science, combat (death + aggro), assassin tasks, buffs, construction, hazards, labor (task mobs), safespots | 8 | -| `ui_*.go` | Display/output — color, prompt, table, map, help, hit-line formatting, XP drops | 6 | -| `flagstore.go`, `safespot_manager.go`, `command_queue.go` | Extracted state managers with their own mutexes | 3 | -| `hacking/` | Hacking sub-package — Minigame interface, TerminalDef, CalcXP, WumpusGame, MastermindGame, LiarsDiceGame | 4 | - -**To add a new command:** create `cmd_<name>.go` with the handler, add one line to `cmd_registry.go`. -**To add a new skill:** create `action_<skill>.go` with `start*`/`advance*` methods dispatched from `action.go`. +| Prefix | Purpose | +|---|---| +| `game.go`, `cmd_registry.go`, `tick.go` | Core state machine, command dispatch, tick callbacks | +| `core_*.go` | Infrastructure — types, utils, login, skill XP, flags, courses, stations | +| `act_*.go` | Tick-based action lifecycles — gather, firemaking, talk, use, search, farming, agility, etc. | +| `cmd_*.go` | Command handlers — one file per command or command group | +| `sys_*.go` | Game subsystems — technology, science, combat/death/aggro, buffs, construction, hazards, labor | +| `render_*.go` | Session-coupled rendering — colour resolution, prompt, map, combat, help, XP drops | +| `production_*.go` | Unified production engine + menu/selection UI (split from `core_production.go`) | +| `combat_*.go` | Player-side attack and mob-side/hit-resolution logic (split from `cmd_attack.go`) | +| `look_*.go` | Room/entity/target display helpers (split from `cmd_look.go`) | +| `flagstore.go`, `safespot_manager.go`, `command_queue.go` | Extracted state managers with own mutexes | +| `validate_source.go` | Adapter that populates the `validate.Source` from Game stores | + +The Game struct embeds a `Deps` struct (World, ItemStore, ObjectStore, MobStore, AccountStore, CraftIndex, CourseStore, Ticks, ColorConfig, DataDir) to make injected dependencies explicit while keeping `g.World`, `g.ItemStore` etc. working unchanged. ## Key Conventions @@ -70,7 +75,7 @@ internal/ **Concurrency.** Every state-bearing package uses its own `sync.Mutex`: - `world.World` — groundItems, objStates, seeded, objMoves - `world.MobStore` — defs, instances -- `action.Store` — cache +- `behavior.Store` — cache - `engine.Engine` — subscribers - `Game` — charsMu (loggedInChars map), enterMu (enterSeqs map) - `net.Hub` — sessions, rooms maps (protects `Add`/`Remove`/`EnterRoom`/`LeaveRoom`/`AllSessions`/`PlayersInRoom` from concurrent access across accept/session/tick goroutines) @@ -90,17 +95,17 @@ The pattern is: lock, snapshot/unmarshal, unlock, then process. The engine creat ## Room Scripting - **`on_enter` steps** fire when a player enters. Each has a `message` + optional `condition`. A step may also have a `delay` (ticks) and/or `set_flags`/`set_player_flags`. If any surviving step is timed (has a delay or sets a flag) the sequence runs as a scheduled **cutscene** (driven by `EnterSeqTick`); otherwise messages print synchronously. Step conditions are snapshotted once at entry. A cutscene persists `Player.CutsceneRoom` and **resumes on reconnect** if interrupted; plain on_enter never runs on login. -- **Conditional descriptions** (`descriptions: [{text, condition}]`) on rooms and objects pick the first variant whose condition passes (per-looker), else the base `description`. For an **object**, if it has `descriptions` and none match, the object is **absent** for that player (`look` falls through). Objects also support `aliases: [...]` for extra names. `look` lists candidates when multiple distinct objects match. +- **Conditional descriptions** (`description: [{text, condition}]`) on rooms and objects pick the first variant whose condition passes (per-looker), else the first entry with no condition. Accepts either a plain string or a list. For an **object**, if it has a `description` list and no variant matches, the object is **absent** for that player (`look` falls through). Objects also support `aliases: [...]` for extra names. `look` lists candidates when multiple distinct objects match. - **Exits** support `set_flags`/`set_player_flags`, applied only on a successful traverse. ## Data Files ``` -data/rooms/<id>.yaml Room definitions (exits, objects, mobs, item_spawns, on_enter, descriptions) +data/rooms/<id>.yaml Room definitions (exits, objects, mobs, item_spawns, on_enter, description) data/rooms/player_housing/ Player house rooms data/items/<id>.yaml Item definitions (stats, equip_slot, tool_type, craft, burn_ticks, search_table, etc.) data/mobs/<id>.yaml Mob definitions (combat stats, drops, behavior, steal config; kind: task for worksites) -data/objects/<id>.yaml Object definitions (name, aliases, behavior, hidden, inroom_description, descriptions, removal_item) +data/objects/<id>.yaml Object definitions (name, aliases, behavior, hidden, inroom_description, description, removal_item) data/objects/unique/ Room-specific one-off objects, prefixed with the room number (e.g. unique/1001_sign.yaml) data/drops/<id>.yaml Shared drop tables (weighted item lists, sub-table references) data/hazards/<id>.yaml Shared room hazard definitions (attack_type, attack, max_hit, speed, messages, required_item) @@ -192,7 +197,7 @@ Queue feedback is suppressed by default via the `queue_silently` option. ## Action System -Actions that interact with objects/mobs route through `startAction()` in `action.go`: +Actions that interact with objects/mobs route through `startAction()` in `act.go`: 1. Normalizes verb via `verbAliases` map (mine/chop/fish/cut → gather, talk/speak/ask → talk) 2. Multiple object types → "That's ambiguous, which one?" 3. Searches object instances in room (numbered targeting via `N.name`) @@ -203,7 +208,7 @@ Actions that interact with objects/mobs route through `startAction()` in `action The `verbSkill` map maps verb → skill name for default target resolution: - mine → mining, chop/cut → woodcutting, fish → fishing -### Action Types (from action_state.go) +### Action Types (from act_state.go) | ActionType | Trigger | Type | |---|---|---| @@ -246,16 +251,16 @@ The `verbSkill` map maps verb → skill name for default target resolution: | Action | File | Description | |---|---|---| -| burn/stoke | `action_burn.go` | 3-phase firemaking: drop log → try → skill check → create fire. Stoke adds logs. | -| search | `action_search.go` | Search items with search_table, consumes one, rolls on drop table | +| burn/stoke | `act_burn.go` | 3-phase firemaking: drop log → try → skill check → create fire. Stoke adds logs. | +| search | `act_search.go` | Search items with search_table, consumes one, rolls on drop table | | cook/smelt/smith/craft/mix | `production_core.go` | Unified recipe-driven production — station checks, timed loops, success/fail, XP, byproducts | -| fletch | `action_fletch.go` | Background fletching — instant or timed, stackable output | -| clean | `action_clean.go` | Background herb cleaning via recipe matching | -| steal | `action_steal.go` | Thieving — pickpocket, stall stealing, guard watching, sneak mode | -| agility | `action_agility.go` | 3-phase obstacle traversal with fail chance, course lap tracking | -| farm | `action_farm.go` | Planting, growth stages (500-tick), watering, disease, harvesting | -| identify | `action_identify.go` | Scavenging — scrap → junk at altars | -| finishing blow | `action_finishing_blow.go` | Assassin special item on mob at 1 HP | +| fletch | `act_fletch.go` | Background fletching — instant or timed, stackable output | +| clean | `act_clean.go` | Background herb cleaning via recipe matching | +| steal | `act_steal.go` | Thieving — pickpocket, stall stealing, guard watching, sneak mode | +| agility | `act_agility.go` | 3-phase obstacle traversal with fail chance, course lap tracking | +| farm | `act_farm.go` | Planting, growth stages (500-tick), watering, disease, harvesting | +| identify | `act_identify.go` | Scavenging — scrap → junk at altars | +| finishing blow | `act_finishing_blow.go` | Assassin special item on mob at 1 HP | ### GatherConfig Fields @@ -489,7 +494,7 @@ Prompt variables: `%h` (HP), `%H` (max HP), `%b` (battery), `%B` (max battery), | `StateHacking` | Jacked into a terminal running a minigame | | `StateDangerConfirm` | Confirming `[Y/n]` entry into a hazardous room | -## ItemDef Fields (object/item.go) +## ItemDef Fields (item/item.go) | Field | Description | |---|---| |
