TrapEvent
A trap sprang, was found, was removed, resisted removal, or was known and didn't spring.
Full documentation: TrapEvent. Wire type: trap.
Default visibility: player
Message codes: exploration.trap.found, exploration.trap.removal_failed, exploration.trap.removed, exploration.trap.safe, exploration.trap.sprung
JSON Schema
{
"$defs": {
"Visibility": {
"description": "Who may see an event: the players, or only the referee.\n\nEvery event has one of these values, because in B/X the referee makes some rolls behind a screen. Filter\na log on it before you show anything to a player, or call\n`GameSession.view`, which builds the players' view and the referee's\nview for you. A narrator that plays the referee reads every event.\n\nA serialized event contains the lowercase value. The values stay fixed within a `schema_version`, the version\nstamp of the saved format.\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 trap sprang, was found, was removed, resisted removal, or was known and didn't spring.\n\nEmitted by the commands that can set a trap off or look for one:\n`MoveParty`,\n`UseStairs` and\n`EnterDungeon`, which run the arrival cell's\nentry checks the same way a step does,\n`OpenDoor` and\n`ForceDoor`,\n`Search`,\n`TakeTreasure`,\n`InspectTreasure`, and\n`RemoveTreasureTrap`. A trap that\nfires resolves at once, so its saves and damage follow in the same result as\nkernel events.\n\nA trap the party doesn't know about that fails to fire emits no `TrapEvent`. Its die\ngoes only into the referee-visibility\n`DetectionRolledEvent`, so to the players\nan uneventful step looks like a step on safe ground.\n\nWhat finding a trap does depends on the kind of trap. A found room trap never springs,\nwhether the party enters its area or opens one of its doors: the party walks around\nthe known pit and stands clear of the known blade, so the engine rolls no die for it\nand emits nothing more. A found treasure trap still gets its 2-in-6 roll when the\nparty takes the treasure with `TakeTreasure`,\nunless a thief has removed it with\n`RemoveTreasureTrap`, because finding a\ntreasure trap doesn't disarm it. That is why `exploration.trap.safe`, a known trap\ngetting its chance and not springing, appears only for a treasure cache.\n\nA thief who fails to remove a treasure trap springs it, unless\n`Ruleset.failed_trap_removal_springs`\nis off. With the flag off, the failure emits `exploration.trap.removal_failed` and the trap\nstays armed and found.",
"properties": {
"code": {
"title": "Code",
"type": "string",
"description": "What happened, like `combat.attack.hit`: two or more lowercase parts separated by dots. The first part is\nthe area of the rules the event comes from, like `combat` or `magic`.\n\nBranch on it, and pass the event to `format_message` to turn it into English.\nBuilding an event with a code in any other format raises a pydantic `ValidationError`."
},
"visibility": {
"$ref": "#/$defs/Visibility",
"default": "player",
"description": "Player visibility: the party feels the trap go off, or sees the one it found."
},
"event_type": {
"const": "trap",
"default": "trap",
"title": "Event Type",
"type": "string",
"description": "The event type, `trap`, which identifies this class in serialized form."
},
"trap_ref": {
"title": "Trap Ref",
"type": "string",
"description": "Which trap this is, as `\"<dungeon id>:<level number>:<area or feature id>\"`. The session\nstores the same reference in its lists of found, sprung, and removed traps, so a trap that has\nsprung or been removed stays that way."
},
"character_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Character Id",
"description": "The member the event is about. For `exploration.trap.sprung` and `exploration.trap.safe`,\nit's the member who set the trap off: the one who forced the door, reached into the cache, or\ntried to remove the trap. For a trap that springs when the party enters its area or opens its\ndoor with `OpenDoor`, it's the first living member in\nmarching order. It's set even when the trap hits the whole party. For\n`exploration.trap.removed` and `exploration.trap.removal_failed`, and for a treasure trap\nfound with `InspectTreasure`, it's the thief who\ntried. For a room trap found with `Search`, it's the member\nwho searched."
},
"direction": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Direction",
"description": "The direction of the door a room trap was found through, from the searched cell, as a\n`Direction` value. Set for that find alone: it is `None` on a\nroom trap found inside the searched area, on a treasure trap found on a cache, and on every code but\n`exploration.trap.found`."
}
},
"required": [
"code",
"trap_ref"
],
"title": "TrapEvent",
"type": "object"
}