TrapEvent
A trap did something the party can perceive: it fired, or was found, or was dealt with.
Full documentation: TrapEvent. Wire type: trap.
Default visibility: player
Message codes: exploration.trap.found, exploration.trap.removed, exploration.trap.safe, exploration.trap.sprung
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 trap did something the party can perceive: it fired, or was found, or was dealt with.\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 damage and saves follow in the same result as\nkernel events.\n\nA trap the party doesn't know about that fails to fire produces no event here.\nOnly its die goes into the referee-visibility\n`DetectionRolledEvent`, so an\nuneventful step looks like a step on safe ground.\n\nWhat a find is worth depends on the kind of trap. A found room trap never springs,\nat its area's edge or at one of its doors: the party walks around the known pit and\nstands clear of the known blade, so it rolls no die and emits nothing further. A\nfound treasure trap still rolls its 2-in-6 on every\n`TakeTreasure` until a thief takes it out\nwith `RemoveTreasureTrap`, because\nfinding a treasure trap is not defeating it. That is why `exploration.trap.safe`, a\nknown trap's trigger resolving without springing, appears on a cache alone.",
"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: 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 wire discriminator, `trap`."
},
"trap_ref": {
"title": "Trap Ref",
"type": "string",
"description": "Which trap this is, as `\"<dungeon id>:<level number>:<area or feature id>\"`. The session\nrecords the same reference as found, sprung, or removed, so a trap is reported once and\nstays dealt with."
},
"character_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Character Id",
"description": "The member who set it off, found it, or removed it, or `None` when the trap fired on the\nparty as a whole."
},
"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 its own 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"
}