Skip to content

Commit

Permalink
Merge branch 'staging' into 486-add-subcategory
Browse files Browse the repository at this point in the history
  • Loading branch information
tylereed committed Sep 27, 2024
2 parents f3d62c0 + acdf2ae commit 1d8bc64
Show file tree
Hide file tree
Showing 41 changed files with 264,414 additions and 39,400 deletions.
18 changes: 18 additions & 0 deletions api_v2/migrations/0114_alter_creatureaction_uses_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-09-14 13:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0113_spell_classes'),
]

operations = [
migrations.AlterField(
model_name='creatureaction',
name='uses_param',
field=models.SmallIntegerField(blank=True, help_text='The parameter X for if the action is limited.', null=True),
),
]
44 changes: 44 additions & 0 deletions api_v2/migrations/0115_auto_20240914_1346.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 3.2.20 on 2024-09-14 13:46

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0114_alter_creatureaction_uses_param'),
]

operations = [
migrations.AlterField(
model_name='creatureaction',
name='uses_type',
field=models.CharField(blank=True, choices=[('PER_DAY', 'X/Day'), ('RECHARGE_ON_ROLL', 'Recharge X-6'), ('RECHARGE_AFTER_REST', 'Recharge after a Short or Long rest')], help_text='How use of the action is limited, if at all.', max_length=20, null=True),
),
migrations.AlterField(
model_name='creatureactionattack',
name='damage_bonus',
field=models.SmallIntegerField(blank=True, help_text='Damage roll modifier.', null=True, validators=[django.core.validators.MinValueValidator(-5), django.core.validators.MaxValueValidator(20)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='extra_damage_bonus',
field=models.SmallIntegerField(blank=True, help_text='Damage roll modifier.', null=True, validators=[django.core.validators.MinValueValidator(-5), django.core.validators.MaxValueValidator(20)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='long_range_ft',
field=models.SmallIntegerField(blank=True, help_text='Long range for ranged attacks, in feet.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='range_ft',
field=models.SmallIntegerField(blank=True, help_text='Normal range for ranged attacks, in feet.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='reach_ft',
field=models.SmallIntegerField(blank=True, help_text='Reach for melee attacks, in feet.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
]
34 changes: 34 additions & 0 deletions api_v2/migrations/0116_auto_20240914_1347.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.20 on 2024-09-14 13:47

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0115_auto_20240914_1346'),
]

operations = [
migrations.AlterField(
model_name='creatureactionattack',
name='damage_die_count',
field=models.SmallIntegerField(blank=True, help_text='The number of dice to roll for damage.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='damage_die_type',
field=models.CharField(blank=True, choices=[('D4', 'd4'), ('D6', 'd6'), ('D8', 'd8'), ('D10', 'd10'), ('D12', 'd12'), ('D20', 'd20')], help_text='What kind of die to roll for damage.', max_length=20, null=True),
),
migrations.AlterField(
model_name='creatureactionattack',
name='extra_damage_die_count',
field=models.SmallIntegerField(blank=True, help_text='The number of dice to roll for damage.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='extra_damage_die_type',
field=models.CharField(blank=True, choices=[('D4', 'd4'), ('D6', 'd6'), ('D8', 'd8'), ('D10', 'd10'), ('D12', 'd12'), ('D20', 'd20')], help_text='What kind of die to roll for damage.', max_length=20, null=True),
),
]
34 changes: 34 additions & 0 deletions api_v2/migrations/0117_auto_20240922_1708.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.20 on 2024-09-22 17:08

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0116_auto_20240914_1347'),
]

operations = [
migrations.RemoveField(
model_name='creaturetrait',
name='id',
),
migrations.AddField(
model_name='creaturetrait',
name='key',
field=models.CharField(default='a', help_text='Unique key for the Document.', max_length=100, primary_key=True, serialize=False),
preserve_default=False,
),
migrations.AlterField(
model_name='creatureactionattack',
name='damage_type',
field=models.ForeignKey(blank=True, help_text='What kind of damage this attack deals', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='api_v2.damagetype'),
),
migrations.AlterField(
model_name='creatureactionattack',
name='extra_damage_type',
field=models.ForeignKey(blank=True, help_text='What kind of extra damage this attack deals', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='api_v2.damagetype'),
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0118_creatureaction_form_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-09-22 19:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0117_auto_20240922_1708'),
]

operations = [
migrations.AddField(
model_name='creatureaction',
name='form_condition',
field=models.CharField(blank=True, default=None, help_text='Description of form-based conditions for this action.', max_length=100, null=True),
),
]
3 changes: 3 additions & 0 deletions api_v2/models/abstracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@

def damage_die_count_field():
return models.SmallIntegerField(
blank=True,
null=True,
validators=[MinValueValidator(0)],
help_text='The number of dice to roll for damage.'
)

def damage_die_type_field():
return models.CharField(
blank=True,
null=True,
max_length=20,
choices=DIE_TYPES,
Expand All @@ -31,6 +33,7 @@ def damage_die_type_field():
def damage_bonus_field():
return models.SmallIntegerField(
null=True,
blank=True,
validators=[MinValueValidator(-5), MaxValueValidator(20)],
help_text='Damage roll modifier.'
)
Expand Down
17 changes: 16 additions & 1 deletion api_v2/models/creature.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,27 @@ class CreatureAction(HasName, HasDescription):
)

uses_type = models.CharField(
blank=True,
null=True,
max_length=20,
choices=CREATURE_USES_TYPES,
help_text='How use of the action is limited, if at all.'
)

uses_param = models.SmallIntegerField(
blank=True,
null=True,
help_text='The parameter X for if the action is limited.'
)

form_condition = models.CharField(
blank=True,
null=True,
default=None,
max_length=100,
help_text='Description of form-based conditions for this action.'
)

def as_text(self):
'''Text representation of creature is name/desc.'''
text = self.name + '\n' + self.desc
Expand Down Expand Up @@ -202,18 +212,21 @@ class CreatureActionAttack(HasName):
)

reach_ft = models.SmallIntegerField(
blank=True,
null=True,
validators=[MinValueValidator(0)],
help_text='Reach for melee attacks, in feet.'
)

range_ft = models.SmallIntegerField(
blank=True,
null=True,
validators=[MinValueValidator(0)],
help_text='Normal range for ranged attacks, in feet.'
)

long_range_ft = models.SmallIntegerField(
blank=True,
null=True,
validators=[MinValueValidator(0)],
help_text='Long range for ranged attacks, in feet.'
Expand All @@ -230,6 +243,7 @@ class CreatureActionAttack(HasName):

damage_type = models.ForeignKey(
"DamageType",
blank=True,
null=True,
related_name="+", # No backwards relation.
on_delete=models.CASCADE,
Expand All @@ -242,6 +256,7 @@ class CreatureActionAttack(HasName):

extra_damage_type = models.ForeignKey(
"DamageType",
blank=True,
null=True,
on_delete=models.CASCADE,
related_name="+", # No backwards relation.
Expand All @@ -253,7 +268,7 @@ class CreatureTrait(Modification):
It inherits from modification, which is an abstract concept.
"""

key = key_field()
parent = models.ForeignKey('Creature', on_delete=models.CASCADE)


Expand Down
8 changes: 4 additions & 4 deletions api_v2/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class ItemFilterSet(FilterSet):
class Meta:
model = models.Item
fields = {
'key': ['in', 'iexact', 'exact' ],
'name': ['iexact', 'exact'],
'key': ['in', 'iexact', 'exact'],
'name': ['iexact', 'exact', 'icontains'],
'desc': ['icontains'],
'cost': ['exact', 'range', 'gt', 'gte', 'lt', 'lte'],
'weight': ['exact', 'range', 'gt', 'gte', 'lt', 'lte'],
# 'rarity': ['exact', 'in', ],
'rarity': ['exact', 'in'],
'requires_attunement': ['exact'],
#'category': ['in', 'iexact', 'exact'],
'category': ['in', 'exact'],
'document__key': ['in','iexact','exact'],
'document__ruleset__key': ['in','iexact','exact'],
}
Expand Down
22 changes: 17 additions & 5 deletions api_v2/views/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@ class SpellFilterSet(FilterSet):
class Meta:
model = models.Spell
fields = {
'key': ['in', 'iexact', 'exact' ],
'name': ['iexact', 'exact','contains'],
'document__key': ['in','iexact','exact'],
'document__ruleset__key': ['in','iexact','exact'],
'classes__key': ['in','iexact','exact']
'key': ['in', 'iexact', 'exact'],
'name': ['iexact', 'exact', 'contains', 'icontains'],
'document__key': ['in', 'iexact', 'exact'],
'document__ruleset__key': ['in', 'iexact', 'exact'],
'classes__key': ['in', 'iexact', 'exact'],
'classes__name': ['in'],
'level': ['exact', 'range', 'gt', 'gte', 'lt', 'lte'],
'range': ['exact', 'range', 'gt', 'gte', 'lt', 'lte'],
'school__key': ['exact'],
'school__name': ['in', 'iexact', 'exact'],
'duration': ['in', 'iexact', 'exact'],
'concentration': ['exact'],
'verbal': ['exact'],
'somatic': ['exact'],
'material': ['exact'],
'material_consumed': ['exact'],
'casting_time': ['in', 'iexact', 'exact'],
}

class SpellViewSet(viewsets.ReadOnlyModelViewSet):
Expand Down
Loading

0 comments on commit 1d8bc64

Please sign in to comment.