mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-07 13:15:53 +02:00
Added ritual and concentration spell indicators.
This commit is contained in:
@@ -75,7 +75,7 @@ def create_spells_pdf(character, basename, flatten=False):
|
||||
cantrip_fields = (f'Spells 10{i}' for i in (14, 16, 17, 18, 19, 20, 21, 22))
|
||||
cantrips = (spl for spl in character.spells if spl.level == 0)
|
||||
for spell, field_name in zip(cantrips, cantrip_fields):
|
||||
fields.append((field_name, spell.name))
|
||||
fields.append((field_name, str(spell)))
|
||||
# Spells for each level
|
||||
field_numbers = {
|
||||
1: (1015, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, ),
|
||||
@@ -104,7 +104,7 @@ def create_spells_pdf(character, basename, flatten=False):
|
||||
field_names = tuple(f'Spells {i}' for i in field_numbers[level])
|
||||
prep_names = tuple(f'Check Box {i}' for i in prep_numbers[level])
|
||||
for spell, field, chk_field in zip(spells, field_names, prep_names):
|
||||
fields.append((field, spell.name))
|
||||
fields.append((field, str(spell)))
|
||||
is_prepared = any([isinstance(spell, Spl) for Spl in character.spells_prepared])
|
||||
fields.append((chk_field, is_prepared))
|
||||
# # Uncomment to post field names instead:
|
||||
|
||||
+10
-1
@@ -25,11 +25,19 @@ class Spell():
|
||||
casting_range = "60 ft"
|
||||
components = ("V", "S")
|
||||
duration = "instantaneous"
|
||||
concentration = False
|
||||
ritual = False
|
||||
magic_school = ""
|
||||
classes = ()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
s = self.name
|
||||
# Indicate if this is a ritual or a concentration
|
||||
indicators = [('R', self.ritual), ('C', self.concentration)]
|
||||
indicators = tuple(letter for letter, is_active in indicators if is_active)
|
||||
if len(indicators):
|
||||
s += f' ({", ".join(indicators)})'
|
||||
return s
|
||||
|
||||
def __repr__(self):
|
||||
return f'<{self.name}>'
|
||||
@@ -1704,6 +1712,7 @@ class DetectMagic(Spell):
|
||||
casting_range = "Self (30 feet)"
|
||||
components = ("V", "S")
|
||||
duration = "Concentration, Up to 10 minutes"
|
||||
ritual = True
|
||||
magic_school = "Divination"
|
||||
classes = ('Bard', 'Cleric', 'Druid', 'Paladin', 'Ranger', 'Sorceror', 'Wizard', )
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,3 +14,14 @@ class TestSpells(TestCase):
|
||||
self.assertEqual(NewSpell.name, 'Hello world')
|
||||
spell = NewSpell()
|
||||
print(spell, spell.__class__, type(spell))
|
||||
|
||||
def test_spell_str(self):
|
||||
spell = Spell()
|
||||
spell.name = "My spell"
|
||||
self.assertEqual(str(spell), 'My spell')
|
||||
# Try with a ritual
|
||||
spell.ritual = True
|
||||
self.assertEqual(str(spell), 'My spell (R)')
|
||||
# Try with a ritual and a concentration
|
||||
spell.concentration = True
|
||||
self.assertEqual(str(spell), 'My spell (R, C)')
|
||||
|
||||
Reference in New Issue
Block a user