-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from open5e/v2_conditions
V2 conditions
- Loading branch information
Showing
10 changed files
with
224 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 3.2.20 on 2023-11-04 20:55 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api_v2', '0021_auto_20231104_1919'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Condition', | ||
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)), | ||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api_v2.document')), | ||
], | ||
options={ | ||
'verbose_name_plural': 'conditions', | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""The model for a condition.""" | ||
from django.db import models | ||
from .abstracts import HasName, HasDescription | ||
from .document import FromDocument | ||
|
||
class Condition(HasName, HasDescription, FromDocument): | ||
""" | ||
This is the model for a condition. | ||
""" | ||
|
||
class Meta: | ||
"""To assist with the UI layer.""" | ||
|
||
verbose_name_plural = "conditions" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Serializer for the Condition model.""" | ||
|
||
from rest_framework import serializers | ||
|
||
from api_v2 import models | ||
|
||
from .abstracts import GameContentSerializer | ||
|
||
class ConditionSerializer(GameContentSerializer): | ||
key = serializers.ReadOnlyField() | ||
|
||
class Meta: | ||
model = models.Condition | ||
fields = '__all__' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from rest_framework import viewsets | ||
|
||
from api_v2 import models | ||
from api_v2 import serializers | ||
|
||
|
||
class ConditionViewSet(viewsets.ReadOnlyModelViewSet): | ||
""" | ||
list: API endpoint for returning a list of conditions. | ||
retrieve: API endpoint for returning a particular condition. | ||
""" | ||
queryset = models.Condition.objects.all().order_by('pk') | ||
serializer_class = serializers.ConditionSerializer | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
[ | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "blinded", | ||
"fields": { | ||
"name": "Blinded", | ||
"desc": "* A blinded creature can't see and automatically fails any ability check that requires sight.\r\n* Attack rolls against the creature have advantage, and the creature’s attack rolls have disadvantage.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "charmed", | ||
"fields": { | ||
"name": "Charmed", | ||
"desc": "* A charmed creature can’t attack the charmer or target the charmer with harmful abilities or magical effects.\r\n* The charmer has advantage on any ability check to interact socially with the creature.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "deafened", | ||
"fields": { | ||
"name": "Deafened", | ||
"desc": "* A deafened creature can’t hear and automatically fails any ability check that requires hearing.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "exhaustion", | ||
"fields": { | ||
"name": "Exhaustion", | ||
"desc": "Some special abilities and environmental hazards, such as starvation and the long-‐term effects of freezing or scorching temperatures, can lead to a special condition called exhaustion. Exhaustion is measured in six levels. An effect can give a creature one or more levels of exhaustion, as specified in the effect’s description.\r\n\r\n| Level | Effect |\r\n| --- | --- |\r\n| 1 | Disadvantage on ability checks | \r\n| 2 | Speed halved | \r\n| 3 | Disadvantage on attack rolls and saving throws | \r\n| 4 | Hit point maximum halved | \r\n| 5 | Speed reduced to 0 | \r\n| 6 | Death |\r\n\r\nIf an already exhausted creature suffers another effect that causes exhaustion, its current level of exhaustion increases by the amount specified in the effect’s description.\r\nA creature suffers the effect of its current level of exhaustion as well as all lower levels. For example, a creature suffering level 2 exhaustion has its speed halved and has disadvantage on ability checks. \r\nAn effect that removes exhaustion reduces its level as specified in the effect’s description, with all exhaustion effects ending if a creature’s exhaustion level is reduced below 1.\r\nFinishing a long rest reduces a creature’s exhaustion level by 1, provided that the creature has also ingested some food and drink.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "frightened", | ||
"fields": { | ||
"name": "Frightened", | ||
"desc": "* A frightened creature has disadvantage on ability checks and attack rolls while the source of its fear\r\nis within line of sight.\r\n* The creature can’t willingly move closer to the source of its fear.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "grappled", | ||
"fields": { | ||
"name": "Grappled", | ||
"desc": "* A grappled creature’s speed becomes 0, and it can’t benefit from any bonus to its speed. \r\n* The condition ends if the grappler is incapacitated (see the condition).\r\n* The condition also ends if an effect removes the grappled creature from the reach of the grappler or grappling effect, such as when a creature is hurled away by the *thunder-wave* spell.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "incapacitated", | ||
"fields": { | ||
"name": "Incapacitated", | ||
"desc": "* An incapacitated creature can’t take actions or reactions.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "invisible", | ||
"fields": { | ||
"name": "Invisible", | ||
"desc": "* An invisible creature is impossible to see without the aid of magic or a special sense. For the purpose of hiding, the creature is heavily obscured. The creature’s location can be detected by any noise it makes or any tracks it leaves.\r\n* Attack rolls against the creature have disadvantage, and the creature’s attack rolls have advantage.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "paralyzed", | ||
"fields": { | ||
"name": "Paralyzed", | ||
"desc": "* A paralyzed creature is incapacitated (see the condition) and can’t move or speak. \r\n* The creature automatically fails Strength and Dexterity saving throws.\r\n* Attack rolls against the creature have advantage. \r\n* Any attack that hits the creature is a critical hit if the attacker is within 5 feet of the creature.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "petrified", | ||
"fields": { | ||
"name": "Petrified", | ||
"desc": "* A petrified creature is transformed, along with any nonmagical object it is wearing or carrying, into a solid inanimate substance (usually stone). Its weight increases by a factor of ten, and it ceases aging.\r\n* The creature is incapacitated (see the condition), can’t move or speak, and is unaware of its surroundings.\r\n* Attack rolls against the creature have advantage.\r\n* The creature automatically fails Strength and Dexterity saving throws.\r\n* The creature has resistance to all damage.\r\n* The creature is immune to poison and disease, although a poison or disease already in its system\r\nis suspended, not neutralized.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "poisoned", | ||
"fields": { | ||
"name": "Poisoned", | ||
"desc": "A poisoned creature has disadvantage on attack rolls and ability checks.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "prone", | ||
"fields": { | ||
"name": "Prone", | ||
"desc": "* A prone creature’s only movement option is to crawl, unless it stands up and thereby ends the condition.\r\n* The creature has disadvantage on attack rolls. \r\n* An attack roll against the creature has advantage if the attacker is within 5 feet of the creature. Otherwise, the attack roll has disadvantage.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "restrained", | ||
"fields": { | ||
"name": "Restrained", | ||
"desc": "* A restrained creature’s speed becomes 0, and it can’t benefit from any bonus to its speed.\r\n* Attack rolls against the creature have advantage, and the creature’s attack rolls have disadvantage.\r\n* The creature has disadvantage on Dexterity saving throws.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "stunned", | ||
"fields": { | ||
"name": "Stunned", | ||
"desc": "* A stunned creature is incapacitated (see the condition), can’t move, and can speak only falteringly.\r\n* The creature automatically fails Strength and Dexterity saving throws.\r\n* Attack rolls against the creature have advantage.", | ||
"document": "srd" | ||
} | ||
}, | ||
{ | ||
"model": "api_v2.condition", | ||
"pk": "unconscious", | ||
"fields": { | ||
"name": "Unconscious", | ||
"desc": "* An unconscious creature is incapacitated (see the condition), can’t move or speak, and is unaware of its surroundings\r\n* The creature drops whatever it’s holding and falls prone.\r\n* The creature automatically fails Strength and Dexterity saving throws.\r\n* Attack rolls against the creature have advantage.\r\n* Any attack that hits the creature is a critical hit if the attacker is within 5 feet of the creature.", | ||
"document": "srd" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters