GameState
Inherits JSON::Serializable < Reference < Object
Constants
Maximum remembered-fact entries to keep in the journal.
Maximum log entries to keep (for context window efficiency)
Constructors
Instance methods
Add a companion. If one with the same name already exists, update its description rather than creating a duplicate (keeps the name stable).
Add item to inventory (stacks if same type exists). Rejects blank names and non-positive quantities so tool/marker misuse cannot create invariant-violating inventory entries.
Record a remembered fact in the journal (maintains max size). Case-insensitive de-duplication keeps the journal from filling with the same fact the DM re-remembers on later turns.
Find an inventory item by name (case-insensitive)
Consistency checks used to stress-test the game under autopilot. Returns a list of human-readable invariant violations; an empty array means the state is internally consistent. This is the deterministic backbone of the stress test — it catches state bugs regardless of what the AI narrated.
Move the player to a new room. Rejects blank names so tool/marker misuse cannot leave current_room empty (an invariant violation). Returns a human-readable result; the caller is responsible for logging.
Remove item from inventory. Quantity must be positive so a negative value cannot silently increase a stack (existing.quantity -= quantity).
Replace this state's fields with those from another (used by load-game so the GameLoop can keep its existing state reference while swapping content).
Update a companion's name and/or description (e.g. a true name is revealed). Refuses renames that would collide with a different existing companion, which would otherwise leave a case-insensitive duplicate in the list.