Skip to content

Commit 303364d

Browse files
Merge pull request open5e#599 from open5e/464-add-monster-filter-for-habitat-similar-to-cr
464 add monster filter for habitat similar to cr
2 parents 3a926c4 + 186d627 commit 303364d

24 files changed

+13401
-2992
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.2 on 2024-10-27 11:53
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0013_size_suggested_hit_dice'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='environment',
15+
name='interior',
16+
field=models.BooleanField(default=False, help_text='Whether or not this environment is an interior space.'),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.2 on 2024-10-27 12:05
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0014_environment_interior'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='creature',
15+
name='environments',
16+
field=models.ManyToManyField(related_name='creature_environments', to='api_v2.environment'),
17+
),
18+
]

api_v2/models/creature.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .condition import Condition
1414
from .damagetype import DamageType
1515
from .document import FromDocument
16+
from .environment import Environment
1617
from .speed import HasSpeed
1718
from .enums import CREATURE_ATTACK_TYPES, CREATURE_USES_TYPES, ACTION_TYPES
1819
import decimal
@@ -81,6 +82,9 @@ class Creature(Object, HasAbilities, HasSenses, HasLanguage, HasSpeed, FromDocum
8182
help_text="Optional override for calculated XP based on CR."
8283
)
8384

85+
environments = models.ManyToManyField(Environment,
86+
related_name="creature_environments")
87+
8488
def as_text(self):
8589
text = self.name + '\n'
8690
for action in self.creatureaction_set.all():

api_v2/models/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class Environment(HasName, HasDescription, FromDocument):
1818
help_text='Whether or not this environment is a plane of existence.',
1919
default=False)
2020

21+
interior = models.BooleanField(
22+
help_text='Whether or not this environment is an interior space.',
23+
default=False)
24+
2125
class Meta:
2226
"""To assist with the UI layer."""
2327

api_v2/serializers/creature.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ class Meta:
102102
'tremorsense_range',
103103
'truesight_range',
104104
'actions',
105-
'creaturesets'
105+
'creaturesets',
106+
'environments'
106107
]
107108

108109
@extend_schema_field(inline_serializer(

api_v2/tests/responses/TestObjects.test_creature_ancient_example.approved.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@
132132
"damage_vulnerabilities": [],
133133
"darkvision_range": 120.0,
134134
"document": "http://localhost:8000/v2/documents/srd/",
135+
"environments": [
136+
"http://localhost:8000/v2/environments/hills/",
137+
"http://localhost:8000/v2/environments/mountain/"
138+
],
135139
"experience_points": 62000,
136140
"hit_dice": "28d20+252",
137141
"hit_points": 546,

api_v2/tests/responses/TestObjects.test_creature_goblin_example.approved.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@
4646
"damage_vulnerabilities": [],
4747
"darkvision_range": 60.0,
4848
"document": "http://localhost:8000/v2/documents/srd/",
49+
"environments": [
50+
"http://localhost:8000/v2/environments/arctic/",
51+
"http://localhost:8000/v2/environments/caves/",
52+
"http://localhost:8000/v2/environments/desert/",
53+
"http://localhost:8000/v2/environments/forest/",
54+
"http://localhost:8000/v2/environments/grassland/",
55+
"http://localhost:8000/v2/environments/hills/",
56+
"http://localhost:8000/v2/environments/mountain/",
57+
"http://localhost:8000/v2/environments/ruins/",
58+
"http://localhost:8000/v2/environments/sewer/",
59+
"http://localhost:8000/v2/environments/srd_feywild/",
60+
"http://localhost:8000/v2/environments/swamp/",
61+
"http://localhost:8000/v2/environments/underworld/",
62+
"http://localhost:8000/v2/environments/urban/"
63+
],
4964
"experience_points": 50,
5065
"hit_dice": "2d6",
5166
"hit_points": 7,

api_v2/tests/responses/TestObjects.test_creature_guard_example.approved.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
"damage_vulnerabilities": [],
3535
"darkvision_range": null,
3636
"document": "http://localhost:8000/v2/documents/srd/",
37+
"environments": [
38+
"http://localhost:8000/v2/environments/coast/",
39+
"http://localhost:8000/v2/environments/desert/",
40+
"http://localhost:8000/v2/environments/forest/",
41+
"http://localhost:8000/v2/environments/grassland/",
42+
"http://localhost:8000/v2/environments/hills/",
43+
"http://localhost:8000/v2/environments/mountain/",
44+
"http://localhost:8000/v2/environments/urban/"
45+
],
3746
"experience_points": 25,
3847
"hit_dice": "2d8+2",
3948
"hit_points": 11,

api_v2/tests/responses/TestObjects.test_creatureset_example.approved.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"damage_vulnerabilities": [],
3939
"darkvision_range": null,
4040
"document": "http://localhost:8000/v2/documents/srd/",
41+
"environments": [
42+
"http://localhost:8000/v2/environments/desert/",
43+
"http://localhost:8000/v2/environments/urban/"
44+
],
4145
"experience_points": 25,
4246
"hit_dice": "2d10+4",
4347
"hit_points": 15,
@@ -158,6 +162,7 @@
158162
"damage_vulnerabilities": [],
159163
"darkvision_range": null,
160164
"document": "http://localhost:8000/v2/documents/srd/",
165+
"environments": [],
161166
"experience_points": 0,
162167
"hit_dice": null,
163168
"hit_points": 11,
@@ -291,6 +296,9 @@
291296
"damage_vulnerabilities": [],
292297
"darkvision_range": null,
293298
"document": "http://localhost:8000/v2/documents/srd/",
299+
"environments": [
300+
"http://localhost:8000/v2/environments/urban/"
301+
],
294302
"experience_points": 50,
295303
"hit_dice": "3d10+3",
296304
"hit_points": 19,
@@ -436,6 +444,11 @@
436444
"damage_vulnerabilities": [],
437445
"darkvision_range": null,
438446
"document": "http://localhost:8000/v2/documents/srd/",
447+
"environments": [
448+
"http://localhost:8000/v2/environments/desert/",
449+
"http://localhost:8000/v2/environments/forest/",
450+
"http://localhost:8000/v2/environments/grassland/"
451+
],
439452
"experience_points": 1100,
440453
"hit_dice": "8d12+24",
441454
"hit_points": 76,
@@ -569,6 +582,11 @@
569582
"damage_vulnerabilities": [],
570583
"darkvision_range": null,
571584
"document": "http://localhost:8000/v2/documents/srd/",
585+
"environments": [
586+
"http://localhost:8000/v2/environments/forest/",
587+
"http://localhost:8000/v2/environments/hills/",
588+
"http://localhost:8000/v2/environments/urban/"
589+
],
572590
"experience_points": 25,
573591
"hit_dice": "1d8+1",
574592
"hit_points": 5,
@@ -702,6 +720,11 @@
702720
"damage_vulnerabilities": [],
703721
"darkvision_range": null,
704722
"document": "http://localhost:8000/v2/documents/srd/",
723+
"environments": [
724+
"http://localhost:8000/v2/environments/grassland/",
725+
"http://localhost:8000/v2/environments/hills/",
726+
"http://localhost:8000/v2/environments/urban/"
727+
],
705728
"experience_points": 25,
706729
"hit_dice": "2d8+2",
707730
"hit_points": 11,
@@ -835,6 +858,10 @@
835858
"damage_vulnerabilities": [],
836859
"darkvision_range": null,
837860
"document": "http://localhost:8000/v2/documents/srd/",
861+
"environments": [
862+
"http://localhost:8000/v2/environments/mountain/",
863+
"http://localhost:8000/v2/environments/urban/"
864+
],
838865
"experience_points": 25,
839866
"hit_dice": "2d8+2",
840867
"hit_points": 11,
@@ -968,6 +995,10 @@
968995
"damage_vulnerabilities": [],
969996
"darkvision_range": null,
970997
"document": "http://localhost:8000/v2/documents/srd/",
998+
"environments": [
999+
"http://localhost:8000/v2/environments/grassland/",
1000+
"http://localhost:8000/v2/environments/urban/"
1001+
],
9711002
"experience_points": 50,
9721003
"hit_dice": "2d10+2",
9731004
"hit_points": 13,
@@ -1101,6 +1132,9 @@
11011132
"damage_vulnerabilities": [],
11021133
"darkvision_range": null,
11031134
"document": "http://localhost:8000/v2/documents/srd/",
1135+
"environments": [
1136+
"http://localhost:8000/v2/environments/urban/"
1137+
],
11041138
"experience_points": 100,
11051139
"hit_dice": "3d10+3",
11061140
"hit_points": 19,

api_v2/tests/responses/TestObjects.test_environment_example.approved.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"aquatic": false,
33
"desc": "The **Astral Plane** is the realm of thought and dream, where visitors travel as disembodied souls to reach the planes of the divine and demonic. It is a great, silvery sea, the same above and below, with swirling wisps of white and gray streaking among motes of light resembling distant stars. Erratic whirlpools of color flicker in midair like spinning coins. Occasional bits of solid matter can be found here, but most of the Astral Plane is an endless, open domain.",
44
"document": "http://localhost:8000/v2/documents/srd/",
5+
"interior": false,
56
"key": "srd_astral-plane",
67
"name": "Astral Plane",
78
"planar": true,

0 commit comments

Comments
 (0)