|
1 | 1 | """The model for a creature.""" |
| 2 | +import decimal |
| 3 | + |
2 | 4 | from fractions import Fraction |
3 | 5 |
|
4 | 6 | from django.db import models |
|
9 | 11 | from .abstracts import damage_die_count_field, damage_die_type_field |
10 | 12 | from .abstracts import damage_bonus_field, key_field |
11 | 13 | from .abstracts import distance_field, distance_unit_field |
| 14 | +from .image import HasIllustration |
12 | 15 | from .object import Object |
13 | 16 | from .condition import Condition |
14 | 17 | from .damagetype import DamageType |
15 | 18 | from .document import FromDocument |
16 | 19 | from .environment import Environment |
17 | 20 | from .speed import HasSpeed |
18 | 21 | from .enums import CREATURE_ATTACK_TYPES, CREATURE_USES_TYPES, ACTION_TYPES |
19 | | -import decimal |
20 | 22 |
|
21 | 23 |
|
22 | 24 | class CreatureType(HasName, HasDescription, FromDocument): |
23 | 25 | """The Type of creature, such as Aberration.""" |
24 | 26 |
|
25 | 27 |
|
26 | | -class Creature(Object, HasAbilities, HasSenses, HasLanguage, HasSpeed, FromDocument): |
| 28 | +class Creature(Object, HasAbilities, HasSenses, HasLanguage, HasSpeed, HasIllustration, FromDocument): |
27 | 29 | """ |
28 | 30 | This is the model for a Creature, per the 5e gamesystem. |
29 | 31 |
|
@@ -151,7 +153,7 @@ def search_result_extra_fields(self): |
151 | 153 | "type": self.type.name, |
152 | 154 | "size": self.size.name, |
153 | 155 | } |
154 | | - |
| 156 | + |
155 | 157 | @property |
156 | 158 | def challenge_rating_text(self): |
157 | 159 | '''Challenge rating as text string representation of a fraction or integer. ''' |
@@ -204,6 +206,7 @@ def experience_points(self): |
204 | 206 | except: |
205 | 207 | return None |
206 | 208 |
|
| 209 | + |
207 | 210 | class CreatureAction(HasName, HasDescription): |
208 | 211 | """Describes an action available to a creature.""" |
209 | 212 | key = key_field() |
@@ -266,6 +269,7 @@ def as_text(self): |
266 | 269 |
|
267 | 270 | return text |
268 | 271 |
|
| 272 | + |
269 | 273 | class CreatureActionAttack(HasName): |
270 | 274 | """Describes an attack action used by a creature.""" |
271 | 275 | key = key_field() |
@@ -337,7 +341,7 @@ class CreatureTrait(Modification): |
337 | 341 | """ |
338 | 342 | key = key_field() |
339 | 343 | parent = models.ForeignKey(Creature, on_delete=models.CASCADE, related_name="traits") |
340 | | - |
| 344 | + |
341 | 345 |
|
342 | 346 | class CreatureSet(HasName, FromDocument): |
343 | 347 | """Set that the creature belongs to.""" |
|
0 commit comments