Skip to content

EffectAttachedEvent

An effect has started on a creature, an item, or a location.

Full documentation: EffectAttachedEvent. Wire type: effect_attached.

Default visibility: referee

Message codes: effects.effect.attached

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": "An effect has started on a creature, an item, or a location.\n\nAn effect is a lasting change the rules make, like a spell's *sleep* or a troll's regeneration, which an\n`EffectsLedger` tracks until it ends.\n`EffectsLedger.attach` reports this first, before any condition the\neffect gives. Keep the `effect_id` if you plan to end the effect early with\n`EffectsLedger.release`.",
  "properties": {
    "code": {
      "default": "effects.effect.attached",
      "title": "Code",
      "type": "string",
      "description": "Fixed at `effects.effect.attached`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "referee",
      "description": "Referee visibility: this is the ledger's record. The players notice the condition the effect gives, which\na separate event reports."
    },
    "event_type": {
      "const": "effect_attached",
      "default": "effect_attached",
      "title": "Event Type",
      "type": "string",
      "description": "The fixed string that identifies this event class in a serialized event."
    },
    "effect_id": {
      "title": "Effect Id",
      "type": "string",
      "description": "The id the ledger gave the effect, like `effect-0001`."
    },
    "kind": {
      "title": "Kind",
      "type": "string",
      "description": "The effect's kind, from its definition, like `\"sleep\"`, `\"regeneration\"`, or `\"light\"`."
    },
    "target_ref": {
      "title": "Target Ref",
      "type": "string",
      "description": "What the effect is attached to: an entity id for a creature, or a location string for an effect in a\nplace."
    },
    "expires_round": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Expires Round",
      "description": "The round the effect is due to end, counted from the start of the game clock, like\n`GameClock.rounds`. `None` when the effect has no duration or is\npermanent."
    }
  },
  "required": [
    "effect_id",
    "kind",
    "target_ref"
  ],
  "title": "EffectAttachedEvent",
  "type": "object"
}