Skip to content

Commit 3c0d42a

Browse files
committed
added 'feature_type' model field to ClassFeature
1 parent 1b12291 commit 3c0d42a

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2.1 on 2025-09-26 10:46
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0061_characterclass_desc_alter_abilitydescription_desc_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='classfeature',
15+
name='feature_type',
16+
field=models.CharField(choices=[('CORE_TRAITS_TABLE', 'CORE_TRAITS_TABLE'), ('CLASS_FEATURE', 'CLASS_FEATURE'), ('CLASS_TABLE_DATA', 'CLASS_TABLE_DATA'), ('PROFICIENCIES', 'PROFICIENCIES'), ('PROFICIENCY_BONUS', 'PROFICIENCY_BONUS'), ('SPELL_SLOTS', 'SPELL_SLOTS')], default='CLASS_FEATURE', help_text='The type that best represents this Class Feature', max_length=32),
17+
),
18+
]

api_v2/models/characterclass.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,21 @@ class ClassFeature(HasName, HasDescription, FromDocument):
5050

5151
parent = models.ForeignKey('CharacterClass', on_delete=models.CASCADE, related_name="features")
5252

53-
# Infer the type of this feature based on the `key`
54-
@property
55-
def feature_type(self) -> str:
56-
if "core-traits" in self.key: return "CORE_TRAITS_TABLE"
57-
if "proficiency-bonus" in self.key: return "PROFICIENCY_BONUS"
58-
if "proficiencies" in self.key: return "PROFICIENCIES"
59-
if "equipment" in self.key: return "STARTING_EQUIPMENT"
60-
if "_slots-" in self.key: return "SPELL_SLOTS"
61-
if "_spells-known" in self.key: return "SPELLS_KNOWN"
62-
if "_cantrips-known" in self.key: return "CANTRIPS_KNOWN"
63-
return "CLASS_FEATURE" # <- base-case
53+
FEATURE_TYPES = [
54+
('CORE_TRAITS_TABLE', 'CORE_TRAITS_TABLE'),
55+
('CLASS_LEVEL_FEATURE', 'CLASS_LEVEL_FEATURE'),
56+
('CLASS_TABLE_DATA', 'CLASS_TABLE_DATA'),
57+
('PROFICIENCIES', 'PROFICIENCIES'),
58+
('PROFICIENCY_BONUS', 'PROFICIENCY_BONUS'),
59+
('SPELL_SLOTS', 'SPELL_SLOTS'),
60+
]
61+
62+
feature_type = models.CharField(
63+
default='CLASS_FEATURE',
64+
choices=FEATURE_TYPES,
65+
max_length=32,
66+
help_text="The type that best represents this Class Feature",
67+
)
6468

6569
def __str__(self):
6670
return "{} ({})".format(self.name,self.parent.name)

0 commit comments

Comments
 (0)