Skip to content

FlagSetEvent

A session flag was written.

Full documentation: FlagSetEvent. Wire type: flag_set.

Default visibility: referee

Message codes: session.flag.set

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 session flag was written.\n\nEmitted by the referee's `SetFlag`. Flags are\nwhere the session records state. An adventure's triggers and gates can depend on a flag\nthrough a `FlagEqualsCondition`, and you can\nstore anything else you need there.\n\nIt has referee visibility, because flags record the game's state, not events in the\nstory the players see.",
  "properties": {
    "code": {
      "default": "session.flag.set",
      "title": "Code",
      "type": "string",
      "description": "The message code, always `session.flag.set`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "referee",
      "description": "Referee visibility: flags are bookkeeping that the players don't see."
    },
    "event_type": {
      "const": "flag_set",
      "default": "flag_set",
      "title": "Event Type",
      "type": "string",
      "description": "The event type, `flag_set`, which identifies this class in serialized form."
    },
    "key": {
      "title": "Key",
      "type": "string",
      "description": "Which flag was written."
    },
    "value": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "boolean"
        }
      ],
      "title": "Value",
      "description": "What it was set to. Writing an existing key replaces its value."
    }
  },
  "required": [
    "key",
    "value"
  ],
  "title": "FlagSetEvent",
  "type": "object"
}