mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-18 20:23:27 +02:00
When resolving +1 weapons, replaced check for inheritance from Weapon
with check for *improved_version* method. Fixes https://github.com/canismarko/dungeon-sheets/issues/112
This commit is contained in:
@@ -2,7 +2,7 @@ from unittest import TestCase
|
||||
|
||||
|
||||
from dungeonsheets.content_registry import ContentRegistry
|
||||
from dungeonsheets import monsters
|
||||
from dungeonsheets import monsters, weapons
|
||||
|
||||
|
||||
class TestContentRegistry(TestCase):
|
||||
@@ -62,3 +62,20 @@ class TestContentRegistry(TestCase):
|
||||
# Direct access
|
||||
self.assertEqual(creg.findattr("my_attr", valid_classes=[int]), test_module.my_attr)
|
||||
|
||||
def test_findattr_magic_weapon(self):
|
||||
creg = ContentRegistry()
|
||||
creg.add_module(weapons)
|
||||
# First test with a non-magical weapon
|
||||
shortsword = creg.findattr("shortsword")
|
||||
self.assertIs(shortsword, weapons.Shortsword)
|
||||
# Now test with a magical weapon
|
||||
magic_shortsword = creg.findattr("shortsword + 1")
|
||||
self.assertTrue(issubclass(magic_shortsword, weapons.Shortsword),
|
||||
"Improved version is not subclass of base.")
|
||||
self.assertEqual(magic_shortsword.attack_bonus, 1)
|
||||
self.assertEqual(magic_shortsword.damage_bonus, 1)
|
||||
# Make sure some other item that can't be "improved" still works
|
||||
creg = ContentRegistry()
|
||||
creg.add_module(monsters)
|
||||
lich = creg.findattr("lich+1")
|
||||
self.assertIs(lich, monsters.Lich)
|
||||
|
||||
@@ -2,7 +2,7 @@ import unittest
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from dungeonsheets import make_sheets, character, monsters
|
||||
from dungeonsheets import make_sheets, character, monsters, random_tables
|
||||
|
||||
|
||||
EG_DIR = Path(__file__).parent.parent.resolve() / "examples"
|
||||
@@ -283,7 +283,7 @@ class TexCreatorTestCase(unittest.TestCase):
|
||||
|
||||
def test_random_tables_tex(self):
|
||||
tex = make_sheets.create_random_tables_content(
|
||||
tables=[random_tables.ConjureAnimals],
|
||||
suffix="tex",
|
||||
conjure_animals=True,
|
||||
)
|
||||
self.assertIn(r"\subsection*{Conjure Animals}", tex)
|
||||
|
||||
Reference in New Issue
Block a user