Skip to content

Commit 0267891

Browse files
committed
remove spell-npc relationships and spell prices
1 parent c1e3a11 commit 0267891

11 files changed

Lines changed: 14 additions & 439 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 8.0.0 (Unreleased)
4+
5+
- Remove `npc_spell` table.
6+
- Remove spell teacher relations from API models (`Npc.teaches`, `Spell.taught_by`).
7+
- Remove spell purchase price (`spell.price`) from parser, schema and models.
8+
- Remove spell-offer generation from `Module:ItemPrices/spelldata`.
9+
310
## 7.0.3 (2025-07-28)
411

512
- Fix SQL generation not working on Docker due to not having the `CONCAT` SQLite extension.

docs/schema.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ The generated database has the following tables.
3737
| `npcofferbuy` | Contains all the NPCs’ buy offers. |
3838
| `npcoffersell` | Contains all the NPCs’ sell offers. |
3939
| `npcrace` | Contains all the NPCs’ races. |
40-
| `npcspell` | Contains all the spells NPCs teach. |
4140
| `outfit` | Contains information for all outfits. |
4241
| `outfitimage` | Contains images for all outfits. |
4342
| `outfitquest` | Contains outfit and addon rewards for quests. |
@@ -801,29 +800,6 @@ npc_race
801800
| name | ``TEXT`` | The name of the race. |
802801
+--------+-------------+-------------------------------------+
803802
804-
npc_spell
805-
~~~~~~~~~
806-
+----------+-------------+--------------------------------------------+
807-
| Column | Type | Description |
808-
+==========+=============+============================================+
809-
| npc_id | ``INTEGER`` | The id of the NPC that teaches this spell. |
810-
+----------+-------------+--------------------------------------------+
811-
| spell_id | ``INTEGER`` | The id of the spell this NPC teaches. |
812-
+----------+-------------+--------------------------------------------+
813-
| knight | ``BOOLEAN`` | Whether this NPC teaches this spell to |
814-
| | | knights. |
815-
+----------+-------------+--------------------------------------------+
816-
| sorcerer | ``BOOLEAN`` | Whether this NPC teaches this spell to |
817-
| | | sorcerers. |
818-
+----------+-------------+--------------------------------------------+
819-
| druid | ``BOOLEAN`` | Whether this NPC teaches this spell to |
820-
| | | druids. |
821-
+----------+-------------+--------------------------------------------+
822-
| paladin | ``BOOLEAN`` | Whether this NPC teaches this spell to |
823-
| | | paladins. |
824-
+----------+-------------+--------------------------------------------+
825-
826-
827803
outfit
828804
~~~~~~
829805
+-------------+-------------+------------------------------------------------------------+
@@ -1011,9 +987,6 @@ spell
1011987
| | | a promotion or not. ``0`` or |
1012988
| | | ``1``. |
1013989
+--------------------------+-------------+-------------------------------------------------------+
1014-
| price | ``INTEGER`` | Price in gold coins of this spell |
1015-
| | | |
1016-
+--------------------------+-------------+-------------------------------------------------------+
1017990
| cooldown | ``INTEGER`` | The individual cooldown in seconds of this spell |
1018991
| | | |
1019992
+--------------------------+-------------+-------------------------------------------------------+

tests/models/test_npc.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from tibiawikisql.models import Npc
66
from tibiawikisql.schema import ItemTable, NpcBuyingTable, NpcDestinationTable, NpcJobTable, NpcRaceTable, \
7-
NpcSellingTable, NpcSpellTable, \
7+
NpcSellingTable, \
88
NpcTable, \
99
SpellTable
1010

@@ -13,7 +13,6 @@ class TestNpc(unittest.TestCase):
1313
def setUp(self):
1414
self.conn = sqlite3.connect(":memory:")
1515
self.conn.executescript(NpcTable.get_create_table_statement())
16-
self.conn.executescript(NpcSpellTable.get_create_table_statement())
1716
self.conn.executescript(NpcJobTable.get_create_table_statement())
1817
self.conn.executescript(NpcRaceTable.get_create_table_statement())
1918
self.conn.executescript(NpcBuyingTable.get_create_table_statement())
@@ -58,18 +57,14 @@ def test_npc_with_spells(self):
5857
level=14,
5958
mana=120,
6059
soul=1,
61-
price=300,
6260
is_premium=False,
6361
is_promotion=False,
6462
status="active",
6563
timestamp=datetime.datetime.fromisoformat("2024-07-29T16:37:09+00:00"),
6664
)
67-
NpcSpellTable.insert(self.conn, npc_id=1, spell_id=1, druid=True)
6865

6966
npc = Npc.get_one_by_field(self.conn, "name", "Azalea")
7067

7168
self.assertIsInstance(npc, Npc)
7269
self.assertEqual(5, len(npc.jobs))
7370
self.assertEqual("Human", npc.race)
74-
self.assertEqual(1, len(npc.teaches))
75-
self.assertEqual("Food (Spell)", npc.teaches[0].spell_title)

tests/test_generation.py

Lines changed: 0 additions & 124 deletions
This file was deleted.

tibiawikisql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__copyright__ = "Copyright 2025 Allan Galarza"
55

66
__license__ = "Apache 2.0"
7-
__version__ = "7.0.3"
7+
__version__ = "8.0.0"

tibiawikisql/generation.py

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sqlite3
99
from collections import defaultdict
1010
import platform
11-
from typing import Any, TYPE_CHECKING, TypeVar
11+
from typing import TYPE_CHECKING, TypeVar
1212

1313
import click
1414
import requests
@@ -432,82 +432,6 @@ def fetch_images(conn: sqlite3.Connection) -> None:
432432
save_maps(conn)
433433

434434

435-
def parse_spell_data(lua_content: str) -> list[tuple[str, str, bool, bool, bool, bool, bool]]:
436-
data = lua.execute(lua_content)
437-
offers = []
438-
for name, table in list(data.items()):
439-
spell_title = name
440-
spell_vocations = list(table["vocation"].values())
441-
for npc, vocation in table["sellers"].items():
442-
if isinstance(vocation, bool):
443-
npc_vocations = spell_vocations[:]
444-
elif isinstance(vocation, str):
445-
npc_vocations = [vocation]
446-
else:
447-
npc_vocations = list(vocation.values())
448-
offers.append((
449-
npc,
450-
spell_title,
451-
"Knight" in npc_vocations,
452-
"Paladin" in npc_vocations,
453-
"Druid" in npc_vocations,
454-
"Sorcerer" in npc_vocations,
455-
"Monk" in npc_vocations,
456-
))
457-
return offers
458-
459-
460-
def generate_spell_offers(conn: sqlite3.Connection, data_store: dict[str, Any]) -> None:
461-
"""Fetch and save the spell offers from the spell data module.
462-
463-
Args:
464-
conn: A connection to the database.
465-
data_store: The data store containing information about generated articles.
466-
467-
"""
468-
if "npcs_map" not in data_store or "spells_map" not in data_store:
469-
return
470-
article = wiki_client.get_article("Module:ItemPrices/spelldata")
471-
spell_offers = parse_spell_data(article.content)
472-
rows = []
473-
not_found_store = defaultdict(set)
474-
with (
475-
timed() as t,
476-
progress_bar(spell_offers, len(spell_offers), "Processing spell offers") as bar,
477-
):
478-
for npc, spell, knight, paladin, druid, sorcerer, monk in bar:
479-
spell_id = data_store["spells_map"].get(spell.lower())
480-
if spell_id is None:
481-
not_found_store["spell"].add(spell)
482-
continue
483-
npc_id = data_store["npcs_map"].get(npc.lower())
484-
if npc_id is None:
485-
not_found_store["npc"].add(npc)
486-
continue
487-
rows.append((
488-
npc_id,
489-
spell_id,
490-
knight,
491-
sorcerer,
492-
paladin,
493-
druid,
494-
monk,
495-
))
496-
with conn:
497-
conn.execute("DELETE FROM npc_spell")
498-
conn.executemany(
499-
"INSERT INTO npc_spell(npc_id, spell_id, knight, sorcerer, paladin, druid, monk) VALUES(?, ?, ?, ?, ?, ?, ?)",
500-
rows)
501-
if not_found_store["spell"]:
502-
unknonw_spells = not_found_store["spell"]
503-
click.echo(f"{Fore.RED}Could not parse offers for {len(unknonw_spells):,} spell.{Style.RESET_ALL}")
504-
click.echo(f"\t-> {Fore.RED}{f'{Style.RESET_ALL},{Fore.RED}'.join(unknonw_spells)}{Style.RESET_ALL}")
505-
if not_found_store["npc"]:
506-
unknown_npcs = not_found_store["npc"]
507-
click.echo(f"{Fore.RED}Could not parse offers of {len(unknown_npcs):,} npcs.{Style.RESET_ALL}")
508-
click.echo(f"\t-> {Fore.RED}{f'{Style.RESET_ALL},{Fore.RED}'.join(unknown_npcs)}{Style.RESET_ALL}")
509-
510-
511435
def generate_item_offers(conn: sqlite3.Connection, data_store):
512436
if "npcs_map" not in data_store or "items_map" not in data_store:
513437
return
@@ -670,7 +594,6 @@ def generate(conn, skip_images, skip_deprecated):
670594
RashidPositionTable.insert(conn, **position.model_dump())
671595

672596
generate_item_offers(conn, data_store)
673-
generate_spell_offers(conn, data_store)
674597
generate_loot_statistics(conn, data_store)
675598

676599
if not skip_images:

tibiawikisql/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from tibiawikisql.models.imbuement import Imbuement, ImbuementMaterial
88
from tibiawikisql.models.item import Book, Item, ItemAttribute, ItemStoreOffer, Key
99
from tibiawikisql.models.mount import Mount
10-
from tibiawikisql.models.npc import Npc, NpcDestination, NpcOffer, NpcSpell, RashidPosition
10+
from tibiawikisql.models.npc import Npc, NpcDestination, NpcOffer, RashidPosition
1111
from tibiawikisql.models.outfit import Outfit, OutfitImage, OutfitQuest
1212
from tibiawikisql.models.quest import Quest, QuestDanger, QuestReward
1313
from tibiawikisql.models.spell import Spell

0 commit comments

Comments
 (0)