Skip to content

Commit 7c591f3

Browse files
committed
Merge branch 'staging' into bfrd-mechanist-class
2 parents 0742b19 + 4344909 commit 7c591f3

27 files changed

+2286
-680
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Django 5.2.1 on 2025-10-02 21:58
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.AlterModelOptions(
14+
name='featbenefit',
15+
options={'ordering': ['parent', 'order']},
16+
),
17+
migrations.RemoveField(
18+
model_name='featbenefit',
19+
name='id',
20+
),
21+
migrations.AddField(
22+
model_name='featbenefit',
23+
name='key',
24+
field=models.CharField(default='', help_text='Unique key for the Document.', max_length=100, primary_key=True, serialize=False),
25+
preserve_default=False,
26+
),
27+
migrations.AddField(
28+
model_name='featbenefit',
29+
name='order',
30+
field=models.SmallIntegerField(blank=True, help_text='The position in the list of features that this feature appears in its source statblock', null=True),
31+
),
32+
]
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+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 5.2.1 on 2025-10-01 12:12
2+
3+
import django.utils.timezone
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('api_v2', '0061_characterclass_desc_alter_abilitydescription_desc_and_more'),
11+
]
12+
13+
operations = [
14+
migrations.RemoveField(
15+
model_name='speciestrait',
16+
name='id',
17+
),
18+
migrations.AddField(
19+
model_name='speciestrait',
20+
name='key',
21+
field=models.CharField(default=django.utils.timezone.now, help_text='Unique key for the Document.', max_length=100, primary_key=True, serialize=False),
22+
preserve_default=False,
23+
),
24+
]
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 11:00
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0062_classfeature_feature_type'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='classfeature',
15+
name='feature_type',
16+
field=models.CharField(choices=[('CORE_TRAITS_TABLE', 'CORE_TRAITS_TABLE'), ('CLASS_LEVEL_FEATURE', 'CLASS_LEVEL_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+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.2.1 on 2025-10-02 09:25
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0062_remove_speciestrait_id_speciestrait_key'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='speciestrait',
15+
name='order',
16+
field=models.SmallIntegerField(blank=True, help_text='The position in the list of features that a feature appears in its source statblock', null=True),
17+
),
18+
migrations.AlterField(
19+
model_name='speciestrait',
20+
name='type',
21+
field=models.CharField(blank=True, choices=[('ABILITY_MODS', 'ABILITY_MODS'), ('SIZE', 'SIZE'), ('SPEED', 'SPEED')], max_length=16, null=True),
22+
),
23+
]
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 18:10
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0063_alter_classfeature_feature_type'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='classfeature',
15+
name='feature_type',
16+
field=models.CharField(choices=[('CORE_TRAITS_TABLE', 'CORE_TRAITS_TABLE'), ('CLASS_LEVEL_FEATURE', 'CLASS_LEVEL_FEATURE'), ('CLASS_TABLE_DATA', 'CLASS_TABLE_DATA'), ('PROFICIENCIES', 'PROFICIENCIES'), ('PROFICIENCY_BONUS', 'PROFICIENCY_BONUS'), ('STARTING_EQUIPMENT', 'STARTING_EQUIPMENT'), ('SPELL_SLOTS', 'SPELL_SLOTS')], default='CLASS_LEVEL_FEATURE', help_text='The type that best represents this Class Feature', max_length=32),
17+
),
18+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 5.2.1 on 2025-10-02 10:28
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0063_speciestrait_order_alter_speciestrait_type'),
10+
]
11+
12+
operations = [
13+
migrations.AlterModelOptions(
14+
name='speciestrait',
15+
options={'ordering': ['parent', 'order']},
16+
),
17+
]

api_v2/models/characterclass.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,22 @@ 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+
('STARTING_EQUIPMENT', 'STARTING_EQUIPMENT'),
60+
('SPELL_SLOTS', 'SPELL_SLOTS'),
61+
]
62+
63+
feature_type = models.CharField(
64+
default='CLASS_LEVEL_FEATURE',
65+
choices=FEATURE_TYPES,
66+
max_length=32,
67+
help_text="The type that best represents this Class Feature",
68+
)
6469

6570
def __str__(self):
6671
return "{} ({})".format(self.name,self.parent.name)

api_v2/models/feat.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""The model for a feat."""
22
from django.db import models
3-
from .abstracts import HasName, HasDescription, HasPrerequisite, Modification
3+
from .abstracts import HasName, HasDescription, HasPrerequisite, Modification, key_field
44
from .document import FromDocument
55

66
FEAT_TYPES = [
@@ -12,8 +12,16 @@
1212

1313
class FeatBenefit(Modification):
1414
"""This is the model for an individual benefit of a feat."""
15-
15+
key = key_field()
1616
parent = models.ForeignKey('Feat', on_delete=models.CASCADE)
17+
order = models.SmallIntegerField(
18+
blank=True,
19+
null=True,
20+
help_text='The position in the list of features that this feature appears in its source statblock'
21+
)
22+
23+
class Meta:
24+
ordering = ['parent', 'order']
1725

1826

1927
class Feat(HasName, HasDescription, HasPrerequisite, FromDocument):

api_v2/models/species.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""The model for a species, sub-species, and it's traits."""
22

33
from django.db import models
4-
from .abstracts import HasName, HasDescription, HasPrerequisite
5-
from .abstracts import Modification
4+
from .abstracts import HasName, HasDescription, HasPrerequisite, Modification, key_field
65
from .document import FromDocument
76
from drf_spectacular.utils import extend_schema_field
87
from drf_spectacular.types import OpenApiTypes
@@ -12,9 +11,30 @@ class SpeciesTrait(Modification):
1211
1312
It inherits from modification, which is an abstract concept.
1413
"""
15-
14+
key = key_field()
1615
parent = models.ForeignKey('Species', on_delete=models.CASCADE)
1716

17+
SPECIES_FEATURE_TYPES = [
18+
('ABILITY_MODS', 'ABILITY_MODS'),
19+
('SIZE', 'SIZE'),
20+
('SPEED', 'SPEED'),
21+
]
22+
23+
type = models.CharField(
24+
blank=True,
25+
null=True,
26+
max_length=16,
27+
choices=SPECIES_FEATURE_TYPES,
28+
)
29+
30+
order = models.SmallIntegerField(
31+
blank=True,
32+
null=True,
33+
help_text='The position in the list of features that a feature appears in its source statblock'
34+
)
35+
36+
class Meta:
37+
ordering = ['parent', 'order']
1838

1939
class Species(HasName, HasDescription, FromDocument):
2040
"""

0 commit comments

Comments
 (0)