Skip to content

Commit

Permalink
Data type change first.
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohnson committed Oct 9, 2024
1 parent 0b151c9 commit e742ec8
Show file tree
Hide file tree
Showing 10 changed files with 9,452 additions and 5,106 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 5.1.1 on 2024-10-09 16:17

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='creatureactionattack',
name='distance_unit',
field=models.CharField(blank=True, choices=[('feet', 'feet'), ('miles', 'miles')], help_text='What distance unit the relevant field uses.', max_length=20, null=True),
),
migrations.AlterField(
model_name='creatureaction',
name='legendary_cost',
field=models.SmallIntegerField(blank=True, default=None, help_text='null if not legendary, else, the number of legendary actions this costs.', null=True),
),
migrations.AlterField(
model_name='creatureactionattack',
name='long_range_ft',
field=models.FloatField(blank=True, help_text='Used to measure distance.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='range_ft',
field=models.FloatField(blank=True, help_text='Used to measure distance.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='creatureactionattack',
name='reach_ft',
field=models.FloatField(blank=True, help_text='Used to measure distance.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
]
29 changes: 10 additions & 19 deletions api_v2/models/creature.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .abstracts import HasDescription, HasName, Modification
from .abstracts import damage_die_count_field, damage_die_type_field
from .abstracts import damage_bonus_field, key_field
from .abstracts import distance_field, distance_unit_field
from .object import Object
from .condition import Condition
from .damagetype import DamageType
Expand Down Expand Up @@ -202,7 +203,7 @@ class CreatureAction(HasName, HasDescription):
blank=True,
null=True,
default=None,
help_text='0 if not legendary, else, the number of legendary actions this costs.'
help_text='null if not legendary, else, the number of legendary actions this costs.'
)


Expand Down Expand Up @@ -234,26 +235,16 @@ class CreatureActionAttack(HasName):
help_text='Attack roll modifier.'
)

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

range_ft = models.SmallIntegerField(
blank=True,
null=True,
validators=[MinValueValidator(0)],
help_text='Normal range for ranged attacks, in feet.'
)
def get_distance_unit(self):
if self.distance_unit is None:
return self.document.distance_unit
return self.distance_unit

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

target_creature_only = models.BooleanField(
help_text='If an attack can target creatures only and not objects.'
Expand Down
Loading

0 comments on commit e742ec8

Please sign in to comment.