Skip to content

OpenDoor

Open an unstuck, unlocked door on one side of the party's cell (takes no game time).

Full documentation: OpenDoor. Wire type: open_door.

Legal session modes: exploring

JSON Schema

{
  "$defs": {
    "Direction": {
      "description": "The four grid directions the party faces and moves in.\n\nYou use these for the way `MoveParty` steps, the side of a\ncell `OpenDoor` works on, and the way a transition turns the\nparty on arrival. There is no up or down. A\n`TransitionSpec` moves the party between levels.\n\nThe values are lowercase strings, like `\"north\"`, and they appear in commands, events, and saves.",
      "enum": [
        "north",
        "east",
        "south",
        "west"
      ],
      "title": "Direction",
      "type": "string"
    }
  },
  "description": "Open an unstuck, unlocked door on one side of the party's cell (takes no game time).\n\nThe party must be exploring a dungeon (see\n`EnterDungeon`). A closed door blocks\n`MoveParty`, so open it first and then step\nthrough. The session refuses a command at an undiscovered secret door exactly as it\nrefuses one at a blank wall, so a refusal never reveals a hidden door. To open a stuck\ndoor, use `ForceDoor`. To open a locked one, use\n`PickLock` first.\n\nA room trap that triggers on `open` belongs to the area on either side of the door.\nOpening the door gives each such trap a 2-in-6 chance to spring on the first living\nmember in marching order, unless the party has already found the trap.\n\nModes:\n    `exploring`\n\nRejections:\n    - `session.command.wrong_mode` - the session is not exploring a dungeon.\n    - `exploration.door.no_door` - no known door on that side of the cell\n      (undiscovered secret doors included).\n    - `exploration.door.already_open` - the door already stands open.\n    - `exploration.door.locked` - the door is still locked. Pick the lock with\n      `PickLock` first.\n    - `exploration.door.stuck` - the door is stuck. Force it with\n      `ForceDoor`.\n    - `exploration.door.gate_refused` - the door has an authored\n      condition (`GateSpec`) the party doesn't\n      meet. The rejection includes the gate's authored refusal text. The session checks\n      the gate after every other check, so this code means the gate is the only obstacle.\n\nEvents:\n    `ItemConsumedEvent` first when\n    the gate takes an item as a toll, then\n    `DoorEvent` with code\n    `exploration.door.opened`, which includes the gate's success text when its author\n    wrote one. A door trap's spring check then produces a\n    `DetectionRolledEvent` and a\n    `TrapEvent`, and a trap that springs\n    resolves at once: a\n    `SavingThrowRolledEvent` when\n    it allows a save,\n    `DamageDealtEvent` and\n    `HitPointsReportedEvent` for\n    damage, `EffectAttachedEvent` and\n    `ConditionGainedEvent` for a\n    condition it inflicts, and\n    `DeathEvent` when it kills outright.\n\nExamples:\n    ```python\n    from osrlib.core.alignment import Alignment\n    from osrlib.core.character import CHARACTER_CREATION_STREAM, create_character\n    from osrlib.core.rng import RngStreams\n    from osrlib.core.ruleset import Ruleset\n    from osrlib.crawl.adventure import Adventure, TownSpec\n    from osrlib.crawl.commands import EnterDungeon, MoveParty, OpenDoor\n    from osrlib.crawl.dungeon import Direction, DoorSpec, DungeonSpec, Edge, EdgeKind, LevelSpec, edge_key\n    from osrlib.crawl.party import Party\n    from osrlib.crawl.session import GameSession\n    from osrlib.messages import format_message\n\n    stream = RngStreams(master_seed=7).get(CHARACTER_CREATION_STREAM)\n    hero = create_character(\n        name=\"Hild\", class_id=\"fighter\", alignment=Alignment.LAWFUL, ruleset=Ruleset(), stream=stream\n    ).character\n    door = Edge(kind=EdgeKind.DOOR, door=DoorSpec())\n    level = LevelSpec(number=1, width=2, height=1, entrance=(0, 0), edges={edge_key((0, 0), Direction.EAST): door})\n    crypt = DungeonSpec(id=\"crypt\", name=\"The Old Crypt\", levels=(level,))\n    adventure = Adventure(name=\"A First Delve\", town=TownSpec(name=\"Threshold\"), dungeons=(crypt,))\n    session = GameSession.new(Party(members=[hero]), adventure, seed=7)\n    session.execute(EnterDungeon(dungeon_id=\"crypt\"))\n\n    # The closed door blocks the way east until the party opens it.\n    print(session.execute(MoveParty(direction=Direction.EAST)).rejections[0].code)\n    # exploration.move.blocked\n\n    result = session.execute(OpenDoor(direction=Direction.EAST))\n    print([format_message(event) for event in result.events])\n    # ['The door east of (0, 0) opens.']\n    print(session.execute(MoveParty(direction=Direction.EAST)).accepted)\n    # True\n    ```",
  "properties": {
    "command_type": {
      "const": "open_door",
      "default": "open_door",
      "title": "Command Type",
      "type": "string",
      "description": "The name that identifies the command class in serialized data. Each command class fixes\nit to a distinct snake_case string, like `\"move_party\"` or `\"open_door\"`, and constructing\nthe class sets it, so you never pass it yourself.\n`parse_command` and the\n`AnyCommand` union use it to rebuild the right class\nfrom a serialized mapping. A class's value never changes between releases."
    },
    "source": {
      "anyOf": [
        {
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Source",
      "description": "Who or what issued the command on whose behalf: an authored trigger or quest id, or the\nname of one of your game's systems. The engine never reads it, so a command with a\n`source` does exactly what the same command without one does. The session logs and\nreplays it with the command, so the log alone shows why something happened. Leave it\n`None` when there's nothing to record. An empty string fails validation when the command\nis constructed."
    },
    "direction": {
      "$ref": "#/$defs/Direction",
      "description": "Which side of the party's cell the door is on. Read the cell's sides from\n`ExploredLevelView.edges`: you can name any\nside whose edge has kind `door`. An undiscovered secret door shows as a wall until a\n`secret_doors` `Search` finds it."
    }
  },
  "required": [
    "direction"
  ],
  "title": "OpenDoor",
  "type": "object"
}