-
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.
- Loading branch information
BuildTools
committed
Dec 8, 2023
1 parent
52a90e8
commit 0207573
Showing
1 changed file
with
45 additions
and
0 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
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 |