Skip to content

DoorEvent

A door changed state, named by the cell it borders and the side it sits on.

Full documentation: DoorEvent. Wire type: door.

Default visibility: player

Message codes: exploration.door.closed, exploration.door.forced, exploration.door.opened, exploration.door.stuck, exploration.door.swung_shut, exploration.door.unlocked, exploration.door.wedged

JSON Schema

{
  "$defs": {
    "Visibility": {
      "description": "Who is allowed to see an event.\n\nEvery event has one of these two values, and the split exists because B/X keeps some rolls behind the\nreferee's screen. Filter a log on it before you show anything to a player, or call\n`GameSession.view`, which builds the player's and the referee's\nviews for you. A narrator playing referee reads both.\n\nThe values are the lowercase strings and they serialize into every event, so a renamed value is a\n`schema_version` bump.\n\nExamples:\n    ```python\n    from osrlib.core.events import DamageDealtEvent, HitPointsReportedEvent, Visibility\n\n    log = [\n        DamageDealtEvent(target_id=\"monster-0001\", amount=5),\n        HitPointsReportedEvent(target_id=\"monster-0001\", current_hp=2, max_hp=7),\n    ]\n    shown = [event.code for event in log if event.visibility is Visibility.PLAYER]\n    assert shown == [\"combat.damage.dealt\"]  # the goblin's remaining hit points stay hidden\n    ```",
      "enum": [
        "player",
        "referee"
      ],
      "title": "Visibility",
      "type": "string"
    }
  },
  "description": "A door changed state, named by the cell it borders and the side it sits on.\n\nEmitted by the door commands,\n`OpenDoor`,\n`CloseDoor`,\n`ForceDoor`,\n`PickLock`, and\n`WedgeDoor`, and by the commands that leave a\ncell or a level, because doors the party opened swing shut behind it. A referee's\n`SetDoorState` emits it too, at referee\nvisibility, since a door set open from behind the screen isn't something the\nparty watched happen.\n\nA door belongs to the edge between two cells, so the same door can be named from\neither side. Redraw from `x`, `y`, and `direction` rather than tracking door\nidentity yourself.",
  "properties": {
    "code": {
      "title": "Code",
      "type": "string",
      "description": "What happened, as two or more lowercase segments separated by dots and namespaced by subsystem, like\n`combat.attack.hit`. This is what you branch on and what\n`format_message` looks up. Anything else raises a validation error."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "player",
      "description": "Player visibility by default. The referee's `SetDoorState` overrides it to referee."
    },
    "event_type": {
      "const": "door",
      "default": "door",
      "title": "Event Type",
      "type": "string",
      "description": "The wire discriminator, `door`."
    },
    "x": {
      "title": "X",
      "type": "integer",
      "description": "The column of the cell the door edge is named from."
    },
    "y": {
      "title": "Y",
      "type": "integer",
      "description": "The row of the cell the door edge is named from."
    },
    "direction": {
      "title": "Direction",
      "type": "string",
      "description": "Which side of that cell the door is on, as a lowercase\n`Direction` value."
    },
    "character_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Character Id",
      "description": "The member who acted, for a force, a stuck attempt, or a picked lock, and `None` when the party\nacted as one or when nobody did, as with a door swinging shut."
    },
    "narrative": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Narrative",
      "description": "The success text the author wrote on the door's gate, when opening it satisfied one, else\n`None`. Content rather than engine prose: the event still has its code and its facts, and the\ndefault formatter appends this line after the templated one."
    }
  },
  "required": [
    "code",
    "x",
    "y",
    "direction"
  ],
  "title": "DoorEvent",
  "type": "object"
}