Skip to content

PrepareSpells

Choose the spells a caster memorizes, replacing what they had memorized (six turns).

Full documentation: PrepareSpells. Wire type: prepare_spells.

Legal session modes: exploring, town

JSON Schema

{
  "$defs": {
    "MemorizedSpell": {
      "description": "One spell a caster has ready to cast: which spell, and in which form.\n\nConstruct one for each slot you want filled, and pass them to\n`memorize_spells` or to the\n`PrepareSpells` command. Read them back from a\ncharacter's `memorized_spells`, in the order they were prepared. Which copy goes depends on\nthe order: casting spends the first copy that matches, and\n`forget_excess_memorized`, which\n`drain_levels` calls, removes the last ones first.\n\nA copy has only a spell id and a form. What the spell can do comes from the template you get\nwith `SpellCatalog.get`.\n\nExamples:\n    ```python\n    from osrlib.core.spells import MemorizedSpell\n\n    prepared = [MemorizedSpell(spell_id=\"magic_missile\"), MemorizedSpell(spell_id=\"light_mu\", reversed=True)]\n    assert prepared[1].reversed  # this copy casts *darkness*, not *light*\n    ```",
      "properties": {
        "spell_id": {
          "minLength": 1,
          "title": "Spell Id",
          "type": "string",
          "description": "The spell's id, like `\"magic_missile\"`.\n\nFor the built-in ids, iterate `load_spells``().spells` or see\n[the spell id index](https://mmacy.github.io/osrlib-python/reference/content-ids/spells/)."
        },
        "reversed": {
          "default": false,
          "title": "Reversed",
          "type": "boolean",
          "description": "True when this copy is prepared as the spell's reversed form.\n\nOnly an arcane caster sets it, because in the SRD an arcane caster chooses the form when the\nspell is memorized. A divine caster memorizes the normal form and chooses the form when casting,\nso a divine caster's copies are always False, and\n`memorize_spells` rejects a copy marked True."
        }
      },
      "required": [
        "spell_id"
      ],
      "title": "MemorizedSpell",
      "type": "object"
    }
  },
  "description": "Choose the spells a caster memorizes, replacing what they had memorized (six turns).\n\nIt's legal in town and while exploring. The caster must have slept since their last\npreparation: a `night` or `day` `Rest` that a\nwandering encounter didn't interrupt. In a new session the party hasn't slept yet, so a\ncaster's first preparation comes after a rest. The selections replace the memorized list rather\nthan adding to it. Cast what the caster memorized with\n`CastSpell` outside battle, or with a `cast`\n`BattleDeclaration` in one.\nThe `CastSpell` example shows a caster resting, preparing, and casting.\n\nModes:\n    `town`, `exploring`\n\nRejections:\n    - `session.command.wrong_mode` - an encounter or battle is underway, or the\n      session has ended.\n    - `session.command.unknown_member` - `character_id` matches no party member.\n    - `session.command.member_incapacitated` - the member can't act.\n    - `magic.memorize.needs_sleep` - the party hasn't slept since this caster's last\n      preparation.\n    - `magic.memorize.not_a_caster` - the member's class casts no spells.\n    - `magic.memorize.unknown_spell` - a selection matches no spell in the session's\n      catalog.\n    - `magic.memorize.wrong_list` - a selection isn't on the caster's spell list.\n    - `magic.memorize.divine_reverses_at_cast` - a selection for a divine caster is\n      reversed. A divine caster chooses the reversed form when casting instead.\n    - `magic.memorize.not_in_book` - an arcane caster's selection isn't in their\n      spell book.\n    - `magic.memorize.not_reversible` - a reversed selection has no reversed\n      form.\n    - `magic.memorize.slots_exceeded` - the selections at some spell level outnumber\n      the caster's slots at that level.\n\nEvents:\n    `SpellsMemorizedEvent` with the\n    memorized list. Six turns pass, with each turn's usual events.",
  "properties": {
    "command_type": {
      "const": "prepare_spells",
      "default": "prepare_spells",
      "title": "Command Type",
      "type": "string",
      "description": "The name that identifies the command class in serialized data. Each command class fixes\nit to a distinct snake_case string, like `\"move_party\"` or `\"open_door\"`, and constructing\nthe class sets it, so you never pass it yourself.\n`parse_command` and the\n`AnyCommand` union use it to rebuild the right class\nfrom a serialized mapping. A class's value never changes between releases."
    },
    "source": {
      "anyOf": [
        {
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Source",
      "description": "Who or what issued the command on whose behalf: an authored trigger or quest id, or the\nname of one of your game's systems. The engine never reads it, so a command with a\n`source` does exactly what the same command without one does. The session logs and\nreplays it with the command, so the log alone shows why something happened. Leave it\n`None` when there's nothing to record. An empty string fails validation when the command\nis constructed."
    },
    "character_id": {
      "title": "Character Id",
      "type": "string",
      "description": "The caster, by `MemberView.id`. The party has to\nhave slept since this caster's last preparation, so send a `night` or `day`\n`Rest` first."
    },
    "selections": {
      "default": [],
      "items": {
        "$ref": "#/$defs/MemorizedSpell"
      },
      "title": "Selections",
      "type": "array",
      "description": "The spells to memorize. They replace the caster's current list rather than adding to it.\nEach `MemorizedSpell` has a spell id and, for an\narcane caster, whether the copy is the reversed form of a reversible spell. Repeat a spell\nto memorize more than one copy of it. The number at each spell level has to fit the\ncaster's slots at that level, and an empty tuple clears the list. The caster's current\nlist is in\n`MemberView.memorized_spells`."
    }
  },
  "required": [
    "character_id"
  ],
  "title": "PrepareSpells",
  "type": "object"
}