Skip to content

Commit a60cb93

Browse files
authored
SpeciesTrait update, and srd-2024 Species (open5e#805)
* added srd-2024 species * SpeciesTrait key is now a string - updated data * updated SpeciesTrait model to include nullable 'type' and 'order' fields * added srd-2024 dragonborn data * added srd-2024 dwarf SpeciesTraits * added srd-2024 elf SpeciesTraits * added srd-2024 gnome SpeciesBenefits * updated SpeciesTrait sort order * added srd-2024 goliath SpeciesTraits * added srd-2024 halfling SpeciesBenefits * added srd-2024 human SpeciesTraits * added srd-2024 orc SpeciesTraits * added srd-2024 tiefling SpeciesTraits * updated species test data to reflect new shape of API response
1 parent 85e1b0c commit a60cb93

File tree

10 files changed

+1049
-292
lines changed

10 files changed

+1049
-292
lines changed
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: 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: 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/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
"""

api_v2/serializers/species.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SpeciesTraitSerializer(GameContentSerializer):
1111

1212
class Meta:
1313
model = models.SpeciesTrait
14-
fields = ['name', 'desc']
14+
fields = ['name', 'desc', 'type', 'order']
1515

1616

1717
class SpeciesSerializer(GameContentSerializer):

api_v2/tests/responses/TestObjects.test_species_example.approved.json

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,57 @@
2323
"traits": [
2424
{
2525
"desc": "Your Dexterity score increases by 2.",
26-
"name": "Ability Score Increase"
26+
"name": "Ability Score Increase",
27+
"order": null,
28+
"type": null
2729
},
2830
{
2931
"desc": "Your base walking speed is 25 feet.",
30-
"name": "Speed"
32+
"name": "Speed",
33+
"order": null,
34+
"type": null
3135
},
3236
{
3337
"desc": "A halfling reaches adulthood at the age of 20 and generally lives into the middle of his or her second century.",
34-
"name": "Age"
38+
"name": "Age",
39+
"order": null,
40+
"type": null
3541
},
3642
{
3743
"desc": "Most halflings are lawful good. As a rule, they are good-hearted and kind, hate to see others in pain, and have no tolerance for oppression. They are also very orderly and traditional, leaning heavily on the support of their community and the comfort of their old ways.",
38-
"name": "Alignment"
44+
"name": "Alignment",
45+
"order": null,
46+
"type": null
3947
},
4048
{
4149
"desc": "Halflings average about 3 feet tall and weigh about 40 pounds. Your size is Small.",
42-
"name": "Size"
50+
"name": "Size",
51+
"order": null,
52+
"type": null
4353
},
4454
{
4555
"desc": "You can speak, read, and write Common and Halfling. The Halfling language isn't secret, but halflings are loath to share it with others. They write very little, so they don't have a rich body of literature. Their oral tradition, however, is very strong. Almost all halflings speak Common to converse with the people in whose lands they dwell or through which they are traveling.",
46-
"name": "Languages"
56+
"name": "Languages",
57+
"order": null,
58+
"type": null
4759
},
4860
{
4961
"desc": "When you roll a 1 on the d20 for an attack roll, ability check, or saving throw, you can reroll the die and must use the new roll.",
50-
"name": "Lucky"
62+
"name": "Lucky",
63+
"order": null,
64+
"type": null
5165
},
5266
{
5367
"desc": "You have advantage on saving throws against being frightened.",
54-
"name": "Brave"
68+
"name": "Brave",
69+
"order": null,
70+
"type": null
5571
},
5672
{
5773
"desc": "You can move through the space of any creature that is of a size larger than yours.",
58-
"name": "Halfling Nimbleness"
74+
"name": "Halfling Nimbleness",
75+
"order": null,
76+
"type": null
5977
}
6078
],
6179
"url": "http://localhost:8000/v2/species/srd_halfling/"

0 commit comments

Comments
 (0)