Skip to content

Commit

Permalink
Merge pull request #417 from open5e/v2_spells
Browse files Browse the repository at this point in the history
V2 spells
  • Loading branch information
calumbell authored Mar 13, 2024
2 parents 12eb018 + 9da8d5a commit cf7585b
Show file tree
Hide file tree
Showing 58 changed files with 113,878 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"search": "http://localhost:8000/v1/search/",
"sections": "http://localhost:8000/v1/sections/",
"spelllist": "http://localhost:8000/v1/spelllist/",
"spells": "http://localhost:8000/v1/spells/",
"spells": "http://localhost:8000/v2/spells/",
"weapons": "http://localhost:8000/v2/weapons/"
}
5 changes: 4 additions & 1 deletion api_v2/management/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def handle(self, *args, **options) -> None:

for model in app_models:
SKIPPED_MODEL_NAMES = ['Document', 'Ruleset', 'License', 'Publisher']
CHILD_MODEL_NAMES = ['Trait', 'Capability', 'Benefit', 'FeatureItem']
CHILD_MODEL_NAMES = ['Trait', 'Capability', 'Benefit', 'FeatureItem', 'CastingOption']

if model._meta.app_label == 'api_v2' and model.__name__ not in SKIPPED_MODEL_NAMES:
if model.__name__ in CHILD_MODEL_NAMES:
if model.__name__ == 'Trait':
Expand All @@ -118,6 +119,8 @@ def handle(self, *args, **options) -> None:
modelq = model.objects.filter(feat__document=doc).order_by('pk')
if model.__name__ == 'Benefit':
modelq = model.objects.filter(background__document=doc).order_by('pk')
if model.__name__ == 'CastingOption':
modelq = model.objects.filter(spell__document=doc).order_by('pk')
if model.__name__ == 'FeatureItem':
modelq = model.objects.filter(feature__document=doc).order_by('pk')
else:
Expand Down
47 changes: 47 additions & 0 deletions api_v2/migrations/0031_spell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 3.2.20 on 2024-02-09 20:46

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0030_auto_20231106_2052'),
]

operations = [
migrations.CreateModel(
name='Spell',
fields=[
('name', models.CharField(help_text='Name of the item.', max_length=100)),
('desc', models.TextField(help_text='Description of the game content item. Markdown.')),
('key', models.CharField(help_text='Unique key for the Item.', max_length=100, primary_key=True, serialize=False)),
('level', models.IntegerField(help_text='Integer representing the minimum slot level required by the spell. Cantrip is 0.', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(9)])),
('target_type', models.TextField(choices=[('creature', 'Creature'), ('object', 'Object'), ('point', 'Point'), ('area', 'Area')], help_text='Choices for spell targets.')),
('range', models.TextField(choices=[('self', 'Self'), ('touch', 'Touch'), ('special', 'special'), ('10', '10 feet'), ('25', '25 feet'), ('30', '30 feet'), ('60', '60 feet'), ('90', '90 feet'), ('100', '100 feet'), ('120', '120 feet'), ('150', '150 feet'), ('180', '180 feet'), ('300', '300 feet'), ('500', '500 feet'), ('1mile', '1 mile'), ('100miles', '100 miles'), ('sight', 'Sight')], help_text='Choices for spell targets.')),
('ritual', models.BooleanField(default=False, help_text='Whether or not the spell can be cast as a ritual.')),
('casting_time', models.TextField(choices=[('reaction', 'Reaction'), ('bonus-action', 'Bonus Action'), ('action', 'Action'), ('1minute', '1 Minute'), ('5minutes', '5 Minutes'), ('10minutes', '10 Minutes'), ('1hour', '1 Hour'), ('8hours', '8 Hours')], help_text="Casting time name, such as '1 action'")),
('verbal', models.BooleanField(default=False, help_text='Whether or not casting the spell requires a verbal component.')),
('somatic', models.BooleanField(default=False, help_text='Whether or not casting the spell requires a verbal component.')),
('material', models.BooleanField(default=False, help_text='Whether or not casting the spell requires a verbal component.')),
('material_specified', models.TextField(help_text='A short description of the material required for the spell.')),
('material_cost', models.TextField(help_text='The cost of the material.')),
('material_consumed', models.BooleanField(default=False, help_text='Whether or the material component is consumed during the casting.')),
('target_count', models.TextField()),
('saving_throw_ability', models.TextField()),
('attack_roll', models.BooleanField(default=False, help_text='Whether or not the spell effect requires an attack roll.')),
('damage_roll', models.TextField()),
('damage_types', models.JSONField(default=[], help_text='The types of damage done by the spell in a list.')),
('duration', models.TextField(help_text='Description of the duration of the effect such as "instantaneous" or "Up to 1 minute"')),
('shape_type', models.TextField(choices=[('cone', 'Cone'), ('cube', 'Cube'), ('cylinder', 'Cylinder'), ('line', 'Line'), ('sphere', 'sphere')], help_text='The shape of the area of effect.')),
('shape_magnitude', models.IntegerField(help_text='The magnitude of the shape (without units).', validators=[django.core.validators.MinValueValidator(0)])),
('concentration', models.BooleanField(default=False, help_text='Whether the effect requires concentration to be maintained.')),
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api_v2.document')),
],
options={
'abstract': False,
},
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0032_alter_spell_damage_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-02-09 20:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0031_spell'),
]

operations = [
migrations.AlterField(
model_name='spell',
name='damage_types',
field=models.JSONField(default=list, help_text='The types of damage done by the spell in a list.'),
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0033_alter_spell_saving_throw_ability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-02-09 20:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0032_alter_spell_damage_types'),
]

operations = [
migrations.AlterField(
model_name='spell',
name='saving_throw_ability',
field=models.TextField(default='', help_text='Given the spell requires a saving throw, which ability is targeted. Empty string if no saving throw.'),
),
]
44 changes: 44 additions & 0 deletions api_v2/migrations/0034_auto_20240216_1856.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 3.2.20 on 2024-02-16 18:56

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0033_alter_spell_saving_throw_ability'),
]

operations = [
migrations.AlterField(
model_name='spell',
name='damage_roll',
field=models.TextField(blank=True, help_text='The damage roll for the field in dice notaion. Empty string if no roll.'),
),
migrations.AlterField(
model_name='spell',
name='material_specified',
field=models.TextField(blank=True, help_text='A short description of the material required for the spell.'),
),
migrations.AlterField(
model_name='spell',
name='range',
field=models.TextField(choices=[('self', 'Self'), ('touch', 'Touch'), ('special', 'special'), ('5', '5 feet'), ('10', '10 feet'), ('15', '15 feet'), ('20', '20 feet'), ('25', '25 feet'), ('30', '30 feet'), ('40', '40 feet'), ('50', '50 feet'), ('60', '60 feet'), ('90', '90 feet'), ('100', '100 feet'), ('120', '120 feet'), ('150', '150 feet'), ('180', '180 feet'), ('200', '200 feet'), ('300', '300 feet'), ('400', '400 feet'), ('500', '500 feet'), ('1000', '1000 feet'), ('1mile', '1 mile'), ('5miles', '5 miles'), ('10miles', '10 miles'), ('100miles', '100 miles'), ('150miles', '150 miles'), ('500miles', '500 miles'), ('sight', 'Sight'), ('unlimited', 'Unlimited')], help_text='Choices for spell targets.'),
),
migrations.AlterField(
model_name='spell',
name='saving_throw_ability',
field=models.TextField(blank=True, help_text='Given the spell requires a saving throw, which ability is targeted. Empty string if no saving throw.'),
),
migrations.AlterField(
model_name='spell',
name='shape_magnitude',
field=models.IntegerField(blank=True, help_text='The magnitude of the shape (without units).', validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='spell',
name='shape_type',
field=models.TextField(blank=True, choices=[('cone', 'Cone'), ('cube', 'Cube'), ('cylinder', 'Cylinder'), ('line', 'Line'), ('sphere', 'sphere')], help_text='The shape of the area of effect.'),
),
]
24 changes: 24 additions & 0 deletions api_v2/migrations/0035_auto_20240216_1859.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.20 on 2024-02-16 18:59

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0034_auto_20240216_1856'),
]

operations = [
migrations.AlterField(
model_name='spell',
name='shape_magnitude',
field=models.IntegerField(help_text='The magnitude of the shape (without units).', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='spell',
name='shape_type',
field=models.TextField(choices=[('cone', 'Cone'), ('cube', 'Cube'), ('cylinder', 'Cylinder'), ('line', 'Line'), ('sphere', 'sphere')], help_text='The shape of the area of effect.', null=True),
),
]
25 changes: 25 additions & 0 deletions api_v2/migrations/0036_auto_20240217_1238.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.20 on 2024-02-17 12:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0035_auto_20240216_1859'),
]

operations = [
migrations.AddField(
model_name='spell',
name='higher_level',
field=models.TextField(default='', help_text="Description of casting the spell at a different level.'"),
preserve_default=False,
),
migrations.AddField(
model_name='spell',
name='school',
field=models.TextField(choices=[('abjuration', 'Abjuration'), ('conjuration', 'Conjuration'), ('divination', 'Divination'), ('enchantment', 'Enchantment'), ('evocation', 'Evocation'), ('illusion', 'Illusion'), ('necromancy', 'Necromancy'), ('transmutation', 'Transmutaion')], default='', help_text="Spell school, such as 'Evocation'"),
preserve_default=False,
),
]
28 changes: 28 additions & 0 deletions api_v2/migrations/0037_auto_20240217_1926.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.20 on 2024-02-17 19:26

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0036_auto_20240217_1238'),
]

operations = [
migrations.AlterField(
model_name='spell',
name='casting_time',
field=models.TextField(choices=[('reaction', 'Reaction'), ('bonus-action', '1 Bonus Action'), ('action', '1 Action'), ('1minute', '1 Minute'), ('5minutes', '5 Minutes'), ('10minutes', '10 Minutes'), ('1hour', '1 Hour'), ('8hours', '8 Hours')], help_text="Casting time name, such as '1 action'"),
),
migrations.CreateModel(
name='CastingOption',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('type', models.TextField(choices=[('default', 'Default'), ('ritual', 'Ritual'), ('player_level_1', 'Player Level 1'), ('player_level_2', 'Player Level 2'), ('player_level_3', 'Player Level 3'), ('player_level_4', 'Player Level 4'), ('player_level_5', 'Player Level 5'), ('player_level_6', 'Player Level 6'), ('player_level_7', 'Player Level 7'), ('player_level_8', 'Player Level 8'), ('player_level_9', 'Player Level 9'), ('player_level_10', 'Player Level 10'), ('player_level_11', 'Player Level 11'), ('player_level_12', 'Player Level 12'), ('player_level_13', 'Player Level 13'), ('player_level_14', 'Player Level 14'), ('player_level_15', 'Player Level 15'), ('player_level_16', 'Player Level 16'), ('player_level_17', 'Player Level 17'), ('player_level_18', 'Player Level 18'), ('player_level_19', 'Player Level 19'), ('player_level_20', 'Player Level 20'), ('slot_level_1', 'Spell Slot Level 1'), ('slot_level_2', 'Spell SlotLevel 2'), ('slot_level_3', 'Spell Slot Level 3'), ('slot_level_4', 'Spell Slot Level 4'), ('slot_level_5', 'Spell Slot Level 5'), ('slot_level_6', 'Spell Slot Level 6'), ('slot_level_7', 'Spell Slot Level 7'), ('slot_level_8', 'Spell Slot Level 8'), ('slot_level_9', 'Spell Slot Level 9')])),
('damage_roll', models.TextField(help_text="The damage roll for the field in dice notaion. Null if options don't affect damage roll.", null=True)),
('spell', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api_v2.spell')),
],
),
]
41 changes: 41 additions & 0 deletions api_v2/migrations/0038_auto_20240222_1130.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 3.2.20 on 2024-02-22 11:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0037_auto_20240217_1926'),
]

operations = [
migrations.AddField(
model_name='castingoption',
name='duration',
field=models.TextField(default='', help_text='Description of the duration of the effect such as "instantaneous" or "Up to 1 minute"'),
preserve_default=False,
),
migrations.AddField(
model_name='castingoption',
name='range',
field=models.TextField(default='', help_text='asdf'),
preserve_default=False,
),
migrations.AddField(
model_name='castingoption',
name='target_count',
field=models.TextField(default=0),
preserve_default=False,
),
migrations.AlterField(
model_name='castingoption',
name='damage_roll',
field=models.TextField(help_text="The damage roll for the field in dice notation. Null if options don't affect damage roll.", null=True),
),
migrations.AlterField(
model_name='spell',
name='damage_roll',
field=models.TextField(blank=True, help_text='The damage roll for the field in dice notation. Empty string if no roll.'),
),
]
28 changes: 28 additions & 0 deletions api_v2/migrations/0039_auto_20240225_1315.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.20 on 2024-02-25 13:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0038_auto_20240222_1130'),
]

operations = [
migrations.AlterField(
model_name='castingoption',
name='duration',
field=models.TextField(help_text='Description of the duration of the effect such as "instantaneous" or "Up to 1 minute"', null=True),
),
migrations.AlterField(
model_name='castingoption',
name='range',
field=models.TextField(help_text='asdf', null=True),
),
migrations.AlterField(
model_name='castingoption',
name='target_count',
field=models.TextField(help_text='The count of targets for this casting of the spell.', null=True),
),
]
59 changes: 59 additions & 0 deletions api_v2/migrations/0040_auto_20240228_2227.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated by Django 3.2.20 on 2024-02-28 22:27

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0039_auto_20240225_1315'),
]

operations = [
migrations.AlterField(
model_name='spell',
name='casting_time',
field=models.TextField(choices=[('reaction', 'Reaction'), ('bonus-action', '1 Bonus Action'), ('action', '1 Action'), ('1minute', '1 Minute'), ('5minutes', '5 Minutes'), ('10minutes', '10 Minutes'), ('1hour', '1 Hour'), ('8hours', '8 Hours')], help_text="Casting time key, such as 'action'"),
),
migrations.AlterField(
model_name='spell',
name='higher_level',
field=models.TextField(help_text='Description of casting the spell at a different level.'),
),
migrations.AlterField(
model_name='spell',
name='level',
field=models.IntegerField(help_text='Integer representing the default slot level required by the spell.', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(9)]),
),
migrations.AlterField(
model_name='spell',
name='material_cost',
field=models.TextField(help_text='Cost of the material. Null if no cost specified'),
),
migrations.AlterField(
model_name='spell',
name='material_specified',
field=models.TextField(blank=True, help_text='Description of the material specified for the spell.'),
),
migrations.AlterField(
model_name='spell',
name='range',
field=models.TextField(choices=[('self', 'Self'), ('touch', 'Touch'), ('special', 'special'), ('5', '5 feet'), ('10', '10 feet'), ('15', '15 feet'), ('20', '20 feet'), ('25', '25 feet'), ('30', '30 feet'), ('40', '40 feet'), ('50', '50 feet'), ('60', '60 feet'), ('90', '90 feet'), ('100', '100 feet'), ('120', '120 feet'), ('150', '150 feet'), ('180', '180 feet'), ('200', '200 feet'), ('300', '300 feet'), ('400', '400 feet'), ('500', '500 feet'), ('1000', '1000 feet'), ('1mile', '1 mile'), ('5miles', '5 miles'), ('10miles', '10 miles'), ('100miles', '100 miles'), ('150miles', '150 miles'), ('500miles', '500 miles'), ('sight', 'Sight'), ('unlimited', 'Unlimited')], help_text='Spell target range key.'),
),
migrations.AlterField(
model_name='spell',
name='school',
field=models.TextField(choices=[('abjuration', 'Abjuration'), ('conjuration', 'Conjuration'), ('divination', 'Divination'), ('enchantment', 'Enchantment'), ('evocation', 'Evocation'), ('illusion', 'Illusion'), ('necromancy', 'Necromancy'), ('transmutation', 'Transmutaion')], help_text="Spell school key, such as 'evocation'"),
),
migrations.AlterField(
model_name='spell',
name='target_count',
field=models.TextField(help_text='Description '),
),
migrations.AlterField(
model_name='spell',
name='target_type',
field=models.TextField(choices=[('creature', 'Creature'), ('object', 'Object'), ('point', 'Point'), ('area', 'Area')], help_text='Spell target type key.'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-02-28 22:28

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0040_auto_20240228_2227'),
]

operations = [
migrations.RenameField(
model_name='spell',
old_name='material_cost',
new_name='material_cost_txt',
),
]
Loading

0 comments on commit cf7585b

Please sign in to comment.