Skip to content

SpellDeclaredEvent

Somebody declared a spell, before anyone knows who acts first.

Full documentation: SpellDeclaredEvent. Wire type: spell_declared.

Default visibility: player

Message codes: battle.spell.declared

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": "Somebody declared a spell, before anyone knows who acts first.\n\nEmitted by `ResolveBattleRound` for\neach caster who declared one, party member or NPC alike, at the start of the round.\n\nIn B/X, spells are declared before initiative is rolled. A caster who takes damage\nbefore their turn loses the spell, and the other side knows what is coming. A lost\nspell arrives later in the round as a\n`SpellDisruptedEvent`.",
  "properties": {
    "code": {
      "default": "battle.spell.declared",
      "title": "Code",
      "type": "string",
      "description": "The message code, always `battle.spell.declared`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "player",
      "description": "Player visibility: a declaration is made out loud."
    },
    "event_type": {
      "const": "spell_declared",
      "default": "spell_declared",
      "title": "Event Type",
      "type": "string",
      "description": "The event type, `spell_declared`, which identifies this class in serialized form."
    },
    "caster_id": {
      "title": "Caster Id",
      "type": "string",
      "description": "Who is casting: a party member's id, or an NPC adventurer's."
    },
    "spell_id": {
      "title": "Spell Id",
      "type": "string",
      "description": "Which spell was declared, as its catalog id."
    },
    "reversed": {
      "default": false,
      "title": "Reversed",
      "type": "boolean",
      "description": "Whether the reversed form was declared, for a spell that has one."
    }
  },
  "required": [
    "caster_id",
    "spell_id"
  ],
  "title": "SpellDeclaredEvent",
  "type": "object"
}