Skip to content

SpellBookUpdatedEvent

A new spell has gone into an arcane caster's book.

Full documentation: SpellBookUpdatedEvent. Wire type: spell_book_updated.

Default visibility: player

Message codes: magic.book.added

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 new spell has gone into an arcane caster's book.\n\n`add_spell_to_book` emits this. A spell in the book is one the caster\nmay prepare. Getting it there is a separate matter from preparing it, which reports as\n`SpellsMemorizedEvent`.",
  "properties": {
    "code": {
      "default": "magic.book.added",
      "title": "Code",
      "type": "string",
      "description": "Fixed at `magic.book.added`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "player",
      "description": "Player visibility: the book belongs to the player."
    },
    "event_type": {
      "const": "spell_book_updated",
      "default": "spell_book_updated",
      "title": "Event Type",
      "type": "string",
      "description": "The wire name for this event type."
    },
    "caster_id": {
      "title": "Caster Id",
      "type": "string",
      "description": "The entity id of the caster whose book gained the spell."
    },
    "spell_id": {
      "title": "Spell Id",
      "type": "string",
      "description": "The spell's content id."
    }
  },
  "required": [
    "caster_id",
    "spell_id"
  ],
  "title": "SpellBookUpdatedEvent",
  "type": "object"
}