Skip to content

Commit

Permalink
Initial draft of model.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Dec 8, 2023
1 parent 52a90e8 commit 0207573
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions api_v2/models/class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""The model for a feat."""
from django.db import models
from .abstracts import HasName, HasDescription, Modification
from .document import FromDocument

class FeatureItem(Modification):
"""This is the class for an individual class feature item, a subset of a class
feature. The name field is unused."""

feature = models.ForeignKey('Feature', on_delete=models.CASCADE)
level = models.ForeignKey('Level', on_delete=models.CASCADE)

class Feature(HasName, HasDescription, FromDocument):
"""This class represents an individual class feature, such as Rage, or Extra
Attack."""

character_class = models.ForeignKey('Class', on_delete=models.CASCADE)

class Level(models.Model):
"""This is an individual level of a character class."""
character_class = models.ForeignKey('Class', on_delete=models.CASCADE)


class Class(HasName, FromDocument):
"""The model for a character class or subclass."""
subclass_of = models.ForeignKey('self',
default=None,
blank=True,
null=True,
on_delete=models.CASCADE)

@property
def is_subclass(self):
"""Returns whether the object is a subrace."""
return self.subclass_of is not None

@property
def levels(self):
"""Returns the set of traits that are related to this race."""
return self.level_set

@property
def features(self):
"""Returns the set of traits that are related to this race."""
return self.feature_set

0 comments on commit 0207573

Please sign in to comment.