Skip to content

Commit

Permalink
Adding some enums and spell values
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohnson committed Feb 1, 2024
1 parent 583f363 commit 3ad280d
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 11 deletions.
128 changes: 128 additions & 0 deletions api_v2/models/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@

# Standard set of dice used in 5e.
DIE_TYPES = [
("D4", "d4"),
("D6", "d6"),
("D8", "d8"),
("D10", "d10"),
("D12", "d12"),
("D20", "d20"),
]

# Enumerating sizes, so they are sortable.
SIZE_CHOICES = [
(1, "Tiny"),
(2, "Small"),
(3, "Medium"),
(4, "Large"),
(5, "Huge"),
(6, "Gargantuan")]

# Setting a reasonable maximum for AC.
ARMOR_CLASS_MAXIMUM = 100

# Setting a reasonable maximum for HP.
HIT_POINT_MAXIMUM = 10000

# Types of monsters, and their name spelling.
MONSTER_TYPES = [
("ABERRATION", "Aberration"),
("BEAST", "Beast"),
("CELESTIAL", "Celestial"),
("CONSTRUCT", "Construct"),
("DRAGON", "Dragon"),
("ELEMENTAL", "Elemental"),
("FEY", "Fey"),
("FIEND", "Fiend"),
("GIANT", "Giant"),
("HUMANOID", "Humanoid"),
("MONSTROSITY", "Monstrosity"),
("OOZE", "Ooze"),
("PLANT", "Plant"),
("UNDEAD", "Undead"),
]

# Type of creature attacks.
ATTACK_TYPES = [
("SPELL", "Spell"),
("WEAPON", "Weapon"),
]

DAMAGE_TYPES = [
("ACID", "Acid"),
("BLUDGEONING", "Bludgeoning"),
("COLD", "Cold"),
("FIRE", "Fire"),
("FORCE", "Force"),
("LIGHTNING", "Lightning"),
("NECROTIC", "Necrotic"),
("PIERCING", "Piercing"),
("POISON", "Poison"),
("PSYCHIC", "Psychic"),
("RADIANT", "Radiant"),
("SLASHING", "Slashing"),
("THUNDER", "Thunder"),
]

# Monster action uses description.
USES_TYPES = [
("PER_DAY", "X/Day"),
("RECHARGE_ON_ROLL", "Recharge X-6"),
("RECHARGE_AFTER_REST", "Recharge after a Short or Long rest"),
]

# Item Rarity
RARITY_CHOICES = [
(1, 'common'),
(2, 'uncommon'),
(3, 'rare'),
(4, 'very rare'),
(5, 'legendary'),
(6, 'artifact')
]

TARGET_TYPE_CHOICES = [
('creature',"Creature"),
('object',"Object"),
('point',"Point"),
('area',"Area")
]

TARGET_RANGE_CHOICES = [
('self',"Self"),
('touch',"Touch"),
('special',"special"),
('10',"10 feet"),
('25',"25 feet"),
('30',"30 feet"),
('60',"60 feet"),
('90',"90 feet"),
('100',"100 feet"),
('120',"120 feet"),
('150',"150 feet"),
('180',"180 feet"),
('300',"300 feet"),
('500',"500 feet"),
('1mile',"1 mile"),
('100miles',"100 miles"),
('sight',"Sight"),
]

EFFECT_SHAPE_CHOICES = [
('cone',"Cone"),
('cube',"Cube"),
('cylinder',"Cylinder"),
('line',"Line"),
('sphere',"sphere"),
]

CASTING_TIME_CHOICES = [
('reaction',"Reaction"),
('bonus-action',"Bonus Action"),
('action',"Action"),
('1minute',"1 Minute"),
('5minutes',"5 Minutes"),
('10minutes',"10 Minutes"),
('1hour',"1 Hour"),
('8hours',"8 Hours"),
]
23 changes: 12 additions & 11 deletions api_v2/models/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@

from .abstracts import HasName, HasDescription, FromDocument

from .enum import TARGET_TYPE_CHOICES, TARGET_RANGE_CHOICES, EFFECT_SHAPE_CHOICES
from .enums import TARGET_TYPE_CHOICES, TARGET_RANGE_CHOICES, EFFECT_SHAPE_CHOICES, CASTING_TIME_CHOICES

class Spell(HasName, HasDescription, FromDocument):
version = 'default'

# Casting options and requirements of a spell instance
# Casting options and requirements of a spell instance
level = models.IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(9)],
help_text='Integer representing the minimum slot level required by the spell. Cantrip is 0.')

# Casting target requirements of the spell instance
target = models.TextField(
target_type = models.TextField(
choices = TARGET_TYPE_CHOICES,
help_text='Choices for spell targets.')

range = models.TextField(
choices = TARGET_RANGE_CHOICES,
help_text='Choices for spell targets.')


class SpellCasting(models.Model):
ritual = models.BooleanField(
help_text='Whether or not the spell can be cast as a ritual.',
default=False)

casting_time = models.TextField(
choices = CASTING_TIME_CHOICES,
help_text = "Casting time name, such as '1 action'")

verbal = models.BooleanField(
help_text='Whether or not casting the spell requires a verbal component.',
default=False)
Expand All @@ -57,8 +61,8 @@ class SpellCasting(models.Model):
def components(self):
return ["v","s","m"]

target_count = models.TextField()

class SpellEffect(models.Model):
saving_throw_ability = models.TextField(
#
)
Expand Down Expand Up @@ -87,8 +91,5 @@ def shape_size(self):
help_text='Whether the effect requires concentration to be maintained.',
default=False)


class SpellSet(HasName, FromDocument):
spells = models.ManyToManyField(Spell,
help_text="The set of spells.")

def versions(self):
return ["default":{}]

0 comments on commit 3ad280d

Please sign in to comment.