Skip to content

Commit

Permalink
weapon ranges.
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohnson committed Oct 9, 2024
1 parent 02c2c43 commit e11b6f1
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 131 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 5.1.1 on 2024-10-09 16:48

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


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0005_size_distance_unit'),
]

operations = [
migrations.AlterField(
model_name='weapon',
name='range_long',
field=models.FloatField(blank=True, help_text='Used to measure distance.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='weapon',
name='range_normal',
field=models.FloatField(blank=True, help_text='Used to measure distance.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.AlterField(
model_name='weapon',
name='range_reach',
field=models.FloatField(blank=True, help_text='Used to measure distance.', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.1.1 on 2024-10-09 16:49

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0006_alter_weapon_range_long_alter_weapon_range_normal_and_more'),
]

operations = [
migrations.RenameField(
model_name='weapon',
old_name='range_long',
new_name='long_range',
),
migrations.RenameField(
model_name='weapon',
old_name='range_normal',
new_name='range',
),
migrations.RenameField(
model_name='weapon',
old_name='range_reach',
new_name='reach',
),
]
21 changes: 4 additions & 17 deletions api_v2/models/weapon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.core.validators import MinValueValidator

from .abstracts import HasName
from .abstracts import distance_field, distance_unit_field
from .document import FromDocument


Expand Down Expand Up @@ -35,25 +36,11 @@ class Weapon(HasName, FromDocument):
help_text="""The damage dice when attacking using versatile.
A value of 0 means that the weapon does not have the versatile property.""")

range_reach = models.IntegerField(
null=False,
default=5,
validators=[MinValueValidator(0)],
help_text='The range of the weapon when making a melee attack.')
reach = distance_field()

range_normal = models.IntegerField(
null=False,
default=0,
validators=[MinValueValidator(0)],
help_text="""The normal range of a ranged weapon attack.
A value of 0 means that the weapon cannot be used for a ranged attack.""")
range = distance_field()

range_long = models.IntegerField(
null=False,
default=0,
validators=[MinValueValidator(0)],
help_text="""The long range of a ranged weapon attack.
A value of 0 means that the weapon cannot be used for a long ranged attack.""")
long_range = distance_field()

is_finesse = models.BooleanField(
null=False,
Expand Down
6 changes: 3 additions & 3 deletions api_v2/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class Meta:
'document__gamesystem__key': ['in','iexact','exact'],
'damage_dice': ['in','iexact','exact'],
'versatile_dice': ['in','iexact','exact'],
'range_reach': ['exact','lt','lte','gt','gte'],
'range_normal': ['exact','lt','lte','gt','gte'],
'range_long': ['exact','lt','lte','gt','gte'],
'reach': ['exact','lt','lte','gt','gte'],
'range': ['exact','lt','lte','gt','gte'],
'long_range': ['exact','lt','lte','gt','gte'],
'is_finesse': ['exact'],
'is_thrown': ['exact'],
'is_two_handed': ['exact'],
Expand Down
Loading

0 comments on commit e11b6f1

Please sign in to comment.