Skip to content

Spell

tibiawikisql.models.spell

Classes:

Name Description
SpellTeacher

An NPC that teaches the spell.

Spell

Represents a Spell.

SpellTeacher pydantic-model

Bases: BaseModel

An NPC that teaches the spell.

Note that even if the spell can be learned by multiple vocations, an NPC might only teach it to a specific vocation.

Show JSON schema:
{
  "description": "An NPC that teaches the spell.\n\nNote that even if the spell can be learned by multiple vocations, an NPC might only teach it to a specific vocation.",
  "properties": {
    "npc_id": {
      "title": "Npc Id",
      "type": "integer"
    },
    "npc_title": {
      "title": "Npc Title",
      "type": "string"
    },
    "npc_city": {
      "title": "Npc City",
      "type": "string"
    },
    "knight": {
      "title": "Knight",
      "type": "boolean"
    },
    "paladin": {
      "title": "Paladin",
      "type": "boolean"
    },
    "druid": {
      "title": "Druid",
      "type": "boolean"
    },
    "sorcerer": {
      "title": "Sorcerer",
      "type": "boolean"
    },
    "monk": {
      "title": "Monk",
      "type": "boolean"
    }
  },
  "required": [
    "npc_id",
    "npc_title",
    "npc_city",
    "knight",
    "paladin",
    "druid",
    "sorcerer",
    "monk"
  ],
  "title": "SpellTeacher",
  "type": "object"
}

Fields:

npc_id pydantic-field
npc_id: int

The article ID of the NPC that teaches it.

npc_title pydantic-field
npc_title: str

The title of the NPC that teaches it.

npc_city pydantic-field
npc_city: str

The city where the NPC is located.

knight pydantic-field
knight: bool

If the NPC teaches the spell to knights.

paladin pydantic-field
paladin: bool

If the NPC teaches the spell to paladins.

druid pydantic-field
druid: bool

If the NPC teaches the spell to druids.

sorcerer pydantic-field
sorcerer: bool

If the NPC teaches the spell to sorcerers.

monk pydantic-field
monk: bool

If the NPC teaches the spell to monks.

Spell pydantic-model

Bases: WikiEntry, WithVersion, WithStatus, WithImage, RowModel

Represents a Spell.

Show JSON schema:
{
  "$defs": {
    "SpellTeacher": {
      "description": "An NPC that teaches the spell.\n\nNote that even if the spell can be learned by multiple vocations, an NPC might only teach it to a specific vocation.",
      "properties": {
        "npc_id": {
          "title": "Npc Id",
          "type": "integer"
        },
        "npc_title": {
          "title": "Npc Title",
          "type": "string"
        },
        "npc_city": {
          "title": "Npc City",
          "type": "string"
        },
        "knight": {
          "title": "Knight",
          "type": "boolean"
        },
        "paladin": {
          "title": "Paladin",
          "type": "boolean"
        },
        "druid": {
          "title": "Druid",
          "type": "boolean"
        },
        "sorcerer": {
          "title": "Sorcerer",
          "type": "boolean"
        },
        "monk": {
          "title": "Monk",
          "type": "boolean"
        }
      },
      "required": [
        "npc_id",
        "npc_title",
        "npc_city",
        "knight",
        "paladin",
        "druid",
        "sorcerer",
        "monk"
      ],
      "title": "SpellTeacher",
      "type": "object"
    }
  },
  "description": "Represents a Spell.",
  "properties": {
    "image": {
      "anyOf": [
        {
          "format": "binary",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Image"
    },
    "status": {
      "title": "Status",
      "type": "string"
    },
    "version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Version"
    },
    "article_id": {
      "title": "Article Id",
      "type": "integer"
    },
    "title": {
      "title": "Title",
      "type": "string"
    },
    "timestamp": {
      "format": "date-time",
      "title": "Timestamp",
      "type": "string"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "words": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Words"
    },
    "effect": {
      "title": "Effect",
      "type": "string"
    },
    "spell_type": {
      "title": "Spell Type",
      "type": "string"
    },
    "group_spell": {
      "title": "Group Spell",
      "type": "string"
    },
    "group_secondary": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Group Secondary"
    },
    "group_rune": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Group Rune"
    },
    "element": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Element"
    },
    "mana": {
      "title": "Mana",
      "type": "integer"
    },
    "soul": {
      "title": "Soul",
      "type": "integer"
    },
    "price": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Price"
    },
    "cooldown": {
      "title": "Cooldown",
      "type": "integer"
    },
    "cooldown2": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Cooldown2"
    },
    "cooldown3": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Cooldown3"
    },
    "cooldown_group": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Cooldown Group"
    },
    "cooldown_group_secondary": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Cooldown Group Secondary"
    },
    "level": {
      "title": "Level",
      "type": "integer"
    },
    "is_premium": {
      "title": "Is Premium",
      "type": "boolean"
    },
    "is_promotion": {
      "title": "Is Promotion",
      "type": "boolean"
    },
    "is_wheel_spell": {
      "title": "Is Wheel Spell",
      "type": "boolean"
    },
    "is_passive": {
      "title": "Is Passive",
      "type": "boolean"
    },
    "knight": {
      "default": false,
      "title": "Knight",
      "type": "boolean"
    },
    "paladin": {
      "default": false,
      "title": "Paladin",
      "type": "boolean"
    },
    "druid": {
      "default": false,
      "title": "Druid",
      "type": "boolean"
    },
    "sorcerer": {
      "default": false,
      "title": "Sorcerer",
      "type": "boolean"
    },
    "monk": {
      "default": false,
      "title": "Monk",
      "type": "boolean"
    },
    "taught_by": {
      "items": {
        "$ref": "#/$defs/SpellTeacher"
      },
      "title": "Taught By",
      "type": "array"
    }
  },
  "required": [
    "status",
    "version",
    "article_id",
    "title",
    "timestamp",
    "name",
    "effect",
    "spell_type",
    "group_spell",
    "mana",
    "soul",
    "cooldown",
    "cooldown2",
    "cooldown3",
    "level",
    "is_premium",
    "is_promotion",
    "is_wheel_spell",
    "is_passive"
  ],
  "title": "Spell",
  "type": "object"
}

Fields:

name pydantic-field
name: str

The name of the spell.

words pydantic-field
words: str | None = None

The spell's invocation words.

effect pydantic-field
effect: str

The effects of casting the spell.

spell_type pydantic-field
spell_type: str

The spell's type.

group_spell pydantic-field
group_spell: str

The spell's group.

group_secondary pydantic-field
group_secondary: str | None = None

The spell's secondary group.

group_rune pydantic-field
group_rune: str | None = None

The group of the rune created by this spell.

element pydantic-field
element: str | None = None

The element of the damage made by the spell.

mana pydantic-field
mana: int

The mana cost of the spell.

soul pydantic-field
soul: int

The soul cost of the spell.

price pydantic-field
price: int | None = None

The gold cost of the spell.

cooldown pydantic-field
cooldown: int

The spell's individual cooldown in seconds.

cooldown2 pydantic-field
cooldown2: int | None

The spell's individual cooldown for the level 2 perk of the Wheel of Destiny.

cooldown3 pydantic-field
cooldown3: int | None

The spell's individual cooldown for the level 3 perk of the Wheel of Destiny.

cooldown_group pydantic-field
cooldown_group: int | None = None

The spell's group cooldown in seconds. The time you have to wait before casting another spell in the same group.

cooldown_group_secondary pydantic-field
cooldown_group_secondary: int | None = None

The spell's secondary group cooldown.

level pydantic-field
level: int

The level required to use the spell.

is_premium pydantic-field
is_premium: bool

Whether the spell is premium only or not.

is_promotion pydantic-field
is_promotion: bool

Whether you need to be promoted to buy or cast this spell.

is_wheel_spell pydantic-field
is_wheel_spell: bool

Whether this spell is acquired through the Wheel of Destiny.

is_passive pydantic-field
is_passive: bool

Whether this spell is triggered automatically without casting.

knight pydantic-field
knight: bool = False

Whether the spell can be used by knights or not.

paladin pydantic-field
paladin: bool = False

Whether the spell can be used by paladins or not.

druid pydantic-field
druid: bool = False

Whether the spell can be used by druids or not.

sorcerer pydantic-field
sorcerer: bool = False

Whether the spell can be used by sorcerers or not.

monk pydantic-field
monk: bool = False

Whether the spell can be used by monks or not.

taught_by pydantic-field
taught_by: list[SpellTeacher]

NPCs that teach this spell.

get_one_by_field classmethod
get_one_by_field(
    conn: Connection | Cursor,
    field: str,
    value: Any,
    use_like: bool = False,
) -> Self | None

Get a single element matching the field's value.

Parameters:

Name Type Description Default
conn Connection | Cursor

A connection or cursor of the database.

required
field str

The field to filter with.

required
value Any

The value to look for.

required
use_like bool

Whether to use LIKE as a comparator instead of =.

False

Returns:

Type Description
Self | None

The object found, or None if no entries match.

Raises:

Type Description
ValueError

The specified field doesn't exist in the table.

Source code in tibiawikisql/models/spell.py
@classmethod
def get_one_by_field(cls, conn: Connection | Cursor, field: str, value: Any, use_like: bool = False) -> Self | None:
    spell: Self = super().get_one_by_field(conn, field, value, use_like)
    if spell is None:
        return spell
    spell.taught_by = [SpellTeacher(**dict(r)) for r in NpcSpellTable.get_by_spell_id(conn, spell.article_id)]
    return spell