diff --git a/api_v2/migrations/0006_alter_weapon_range_long_alter_weapon_range_normal_and_more.py b/api_v2/migrations/0006_alter_weapon_range_long_alter_weapon_range_normal_and_more.py new file mode 100644 index 00000000..e5249aeb --- /dev/null +++ b/api_v2/migrations/0006_alter_weapon_range_long_alter_weapon_range_normal_and_more.py @@ -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)]), + ), + ] diff --git a/api_v2/migrations/0007_rename_range_long_weapon_long_range_and_more.py b/api_v2/migrations/0007_rename_range_long_weapon_long_range_and_more.py new file mode 100644 index 00000000..9882af1d --- /dev/null +++ b/api_v2/migrations/0007_rename_range_long_weapon_long_range_and_more.py @@ -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', + ), + ] diff --git a/api_v2/models/weapon.py b/api_v2/models/weapon.py index 3c2fbaaf..f1c40455 100644 --- a/api_v2/models/weapon.py +++ b/api_v2/models/weapon.py @@ -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 @@ -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, diff --git a/api_v2/views/item.py b/api_v2/views/item.py index a881599c..87c2eead 100644 --- a/api_v2/views/item.py +++ b/api_v2/views/item.py @@ -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'], diff --git a/data/v2/wizards-of-the-coast/srd/Weapon.json b/data/v2/wizards-of-the-coast/srd/Weapon.json index 3bfae54f..d71e7704 100644 --- a/data/v2/wizards-of-the-coast/srd/Weapon.json +++ b/data/v2/wizards-of-the-coast/srd/Weapon.json @@ -8,9 +8,9 @@ "damage_type": "slashing", "damage_dice": "1d8", "versatile_dice": "1d10", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -33,9 +33,9 @@ "damage_type": "piercing", "damage_dice": "1", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 25, - "range_long": 100, + "reach": 5.0, + "range": 25.0, + "long_range": 100.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -58,9 +58,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -83,9 +83,9 @@ "damage_type": "piercing", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 30, - "range_long": 120, + "reach": 5.0, + "range": 30.0, + "long_range": 120.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -108,9 +108,9 @@ "damage_type": "piercing", "damage_dice": "1d10", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 100, - "range_long": 400, + "reach": 5.0, + "range": 100.0, + "long_range": 400.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -133,9 +133,9 @@ "damage_type": "piercing", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 80, - "range_long": 320, + "reach": 5.0, + "range": 80.0, + "long_range": 320.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -158,9 +158,9 @@ "damage_type": "piercing", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 20, - "range_long": 60, + "reach": 5.0, + "range": 20.0, + "long_range": 60.0, "is_finesse": true, "is_thrown": true, "is_two_handed": false, @@ -183,9 +183,9 @@ "damage_type": "piercing", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 20, - "range_long": 60, + "reach": 5.0, + "range": 20.0, + "long_range": 60.0, "is_finesse": true, "is_thrown": true, "is_two_handed": false, @@ -208,9 +208,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -233,9 +233,9 @@ "damage_type": "slashing", "damage_dice": "1d10", "versatile_dice": "0", - "range_reach": 10, - "range_normal": 0, - "range_long": 0, + "reach": 10.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -258,9 +258,9 @@ "damage_type": "slashing", "damage_dice": "1d12", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -283,9 +283,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -308,9 +308,9 @@ "damage_type": "slashing", "damage_dice": "2d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -333,9 +333,9 @@ "damage_type": "slashing", "damage_dice": "1d10", "versatile_dice": "0", - "range_reach": 10, - "range_normal": 0, - "range_long": 0, + "reach": 10.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -358,9 +358,9 @@ "damage_type": "slashing", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 20, - "range_long": 60, + "reach": 5.0, + "range": 20.0, + "long_range": 60.0, "is_finesse": false, "is_thrown": true, "is_two_handed": false, @@ -383,9 +383,9 @@ "damage_type": "piercing", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 30, - "range_long": 120, + "reach": 5.0, + "range": 30.0, + "long_range": 120.0, "is_finesse": false, "is_thrown": true, "is_two_handed": false, @@ -408,9 +408,9 @@ "damage_type": "piercing", "damage_dice": "1d12", "versatile_dice": "0", - "range_reach": 10, - "range_normal": 0, - "range_long": 0, + "reach": 10.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -433,9 +433,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 20, - "range_long": 60, + "reach": 5.0, + "range": 20.0, + "long_range": 60.0, "is_finesse": false, "is_thrown": true, "is_two_handed": false, @@ -458,9 +458,9 @@ "damage_type": "piercing", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 150, - "range_long": 600, + "reach": 5.0, + "range": 150.0, + "long_range": 600.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -483,9 +483,9 @@ "damage_type": "slashing", "damage_dice": "1d8", "versatile_dice": "1d10", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -508,9 +508,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -533,9 +533,9 @@ "damage_type": "bludgeoning", "damage_dice": "2d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -558,9 +558,9 @@ "damage_type": "piercing", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -583,9 +583,9 @@ "damage_type": "bludgeoning", "damage_dice": "0", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 5, - "range_long": 15, + "reach": 5.0, + "range": 5.0, + "long_range": 15.0, "is_finesse": false, "is_thrown": true, "is_two_handed": false, @@ -608,9 +608,9 @@ "damage_type": "piercing", "damage_dice": "1d10", "versatile_dice": "0", - "range_reach": 10, - "range_normal": 0, - "range_long": 0, + "reach": 10.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -633,9 +633,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d6", "versatile_dice": "1d8", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -658,9 +658,9 @@ "damage_type": "piercing", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": true, "is_thrown": false, "is_two_handed": false, @@ -683,9 +683,9 @@ "damage_type": "slashing", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": true, "is_thrown": false, "is_two_handed": false, @@ -708,9 +708,9 @@ "damage_type": "piercing", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 80, - "range_long": 320, + "reach": 5.0, + "range": 80.0, + "long_range": 320.0, "is_finesse": false, "is_thrown": false, "is_two_handed": true, @@ -733,9 +733,9 @@ "damage_type": "slashing", "damage_dice": "1d6", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": true, "is_thrown": false, "is_two_handed": false, @@ -758,9 +758,9 @@ "damage_type": "slashing", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -783,9 +783,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 30, - "range_long": 120, + "reach": 5.0, + "range": 30.0, + "long_range": 120.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -808,9 +808,9 @@ "damage_type": "piercing", "damage_dice": "1d6", "versatile_dice": "1d8", - "range_reach": 5, - "range_normal": 20, - "range_long": 60, + "reach": 5.0, + "range": 20.0, + "long_range": 60.0, "is_finesse": false, "is_thrown": true, "is_two_handed": false, @@ -833,9 +833,9 @@ "damage_type": "piercing", "damage_dice": "1d6", "versatile_dice": "1d8", - "range_reach": 5, - "range_normal": 20, - "range_long": 60, + "reach": 5.0, + "range": 20.0, + "long_range": 60.0, "is_finesse": false, "is_thrown": true, "is_two_handed": false, @@ -858,9 +858,9 @@ "damage_type": "piercing", "damage_dice": "1d8", "versatile_dice": "0", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -883,9 +883,9 @@ "damage_type": "bludgeoning", "damage_dice": "1d8", "versatile_dice": "1d10", - "range_reach": 5, - "range_normal": 0, - "range_long": 0, + "reach": 5.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": false, "is_thrown": false, "is_two_handed": false, @@ -908,9 +908,9 @@ "damage_type": "slashing", "damage_dice": "1d4", "versatile_dice": "0", - "range_reach": 10, - "range_normal": 0, - "range_long": 0, + "reach": 10.0, + "range": 0.0, + "long_range": 0.0, "is_finesse": true, "is_thrown": false, "is_two_handed": false,