Skip to content

Commit 8ee2099

Browse files
Merge pull request open5e#746 from open5e/v2/additional-model-fields
V2: Expand Models to handle new fields introduced in 5.2 SRD
2 parents 332c3f7 + d972d80 commit 8ee2099

18 files changed

+96
-5
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Generated by Django 5.1.2 on 2025-05-22 12:38
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0045_merge_20250520_0729'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='characterclass',
15+
name='primary_abilities',
16+
field=models.ManyToManyField(help_text='Primary abilities for thie class', to='api_v2.ability'),
17+
),
18+
migrations.AddField(
19+
model_name='creature',
20+
name='proficiency_bonus',
21+
field=models.SmallIntegerField(help_text="The Creauture's Proficiency Bonus", null=True),
22+
),
23+
migrations.AddField(
24+
model_name='feat',
25+
name='type',
26+
field=models.CharField(choices=[('GENERAL', 'General'), ('ORIGIN', 'Origin'), ('FIGHTING_STYLE', 'Fighting Style'), ('EPIC_BOON', 'Epic Boon')], default='GENERAL', max_length=32),
27+
),
28+
migrations.AddField(
29+
model_name='weaponproperty',
30+
name='type',
31+
field=models.CharField(blank=True, help_text='Weapon property type: ie. Weapon Mastery, etc.', max_length=32, null=True),
32+
),
33+
]

api_v2/models/characterclass.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ class CharacterClass(HasName, FromDocument):
8686
related_name="characterclass_saving_throws",
8787
help_text='Saving throw proficiencies for this class.')
8888

89+
primary_abilities = models.ManyToManyField(
90+
Ability,
91+
help_text='Primary abilities for thie class'
92+
)
93+
8994
caster_type = models.CharField(
9095
max_length=100,
9196
default=None,

api_v2/models/creature.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ class Creature(Object, HasAbilities, HasSenses, HasLanguage, HasSpeed, FromDocum
108108
help_text="Challenge Rating field as a decimal number."
109109
)
110110

111+
proficiency_bonus = models.SmallIntegerField(
112+
null=True,
113+
help_text='The Creauture\'s Proficiency Bonus'
114+
)
115+
111116
experience_points_integer = models.IntegerField(
112117
null=True,
113118
blank=True,

api_v2/models/feat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
from .abstracts import HasName, HasDescription, HasPrerequisite, Modification
44
from .document import FromDocument
55

6+
FEAT_TYPES = [
7+
('GENERAL', 'General'),
8+
('ORIGIN', 'Origin'),
9+
('FIGHTING_STYLE', 'Fighting Style'),
10+
('EPIC_BOON', 'Epic Boon')
11+
]
12+
613
class FeatBenefit(Modification):
714
"""This is the model for an individual benefit of a feat."""
815

@@ -19,6 +26,12 @@ class Feat(HasName, HasDescription, HasPrerequisite, FromDocument):
1926
class provides.
2027
"""
2128

29+
type = models.CharField(
30+
max_length=32,
31+
choices=FEAT_TYPES,
32+
default='GENERAL'
33+
)
34+
2235
@property
2336
def benefits(self):
2437
"""Returns the set of benefits that are related to this feat."""

api_v2/models/weapon.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
from rest_framework import serializers
1212

1313
class WeaponProperty(HasName, HasDescription, FromDocument):
14+
type = models.CharField(
15+
null=True,
16+
blank=True,
17+
max_length=32,
18+
help_text='Weapon property type: ie. Weapon Mastery, etc.',
19+
)
1420
class Meta:
15-
verbose_name_plural = "Weapon Properties"
16-
ordering = ["pk"]
21+
verbose_name_plural = 'Weapon Properties'
22+
ordering = ['pk']
1723

1824
def __str__(self):
1925
return self.name

api_v2/serializers/creature.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class Meta:
170170
'size',
171171
'challenge_rating_decimal',
172172
'challenge_rating_text',
173+
'proficiency_bonus',
173174
'speed',
174175
'speed_all',
175176
'category',

api_v2/serializers/item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class Meta:
4646
class WeaponPropertySerializer(GameContentSerializer):
4747
class Meta:
4848
model = models.WeaponProperty
49-
fields = ['key', 'name', 'desc', 'document', 'url']
49+
fields = ['key', 'name', 'desc', 'document', 'url', 'type']
5050

5151
class WeaponPropertySummarySerializer(GameContentSerializer):
5252
class Meta:
5353
model = models.WeaponProperty
54-
fields = ['name', 'url']
54+
fields = ['name', 'type', 'url']
5555

5656
class WeaponPropertyAssignmentSerializer(GameContentSerializer):
5757
property = WeaponPropertySummarySerializer()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@
515515
},
516516
"key": "srd_barbarian",
517517
"name": "Barbarian",
518+
"primary_abilities": [],
518519
"saving_throws": [
519520
{
520521
"name": "Constitution",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
"name": "Ancient Red Dragon",
242242
"normal_sight_range": 10560.0,
243243
"passive_perception": 26,
244+
"proficiency_bonus": null,
244245
"resistances_and_immunities": {
245246
"condition_immunities": [],
246247
"condition_immunities_display": "",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
"name": "Goblin",
200200
"normal_sight_range": 10560.0,
201201
"passive_perception": 9,
202+
"proficiency_bonus": null,
202203
"resistances_and_immunities": {
203204
"condition_immunities": [],
204205
"condition_immunities_display": "",

0 commit comments

Comments
 (0)