mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
Fix tests
This commit is contained in:
parent
05d3ff455d
commit
3d76181d26
2 changed files with 21 additions and 13 deletions
|
@ -257,9 +257,9 @@ class Character(models.Model):
|
|||
if mana_max_compute == Profile.ManaMax.NO_MANA:
|
||||
return 0
|
||||
elif mana_max_compute == Profile.ManaMax.LEVEL:
|
||||
return self.level + self.modifier_intelligence
|
||||
return self.level + self.modifier_magic
|
||||
else:
|
||||
return 2 * self.level + self.modifier_intelligence
|
||||
return 2 * self.level + self.modifier_magic
|
||||
|
||||
@property
|
||||
def height_m(self) -> float:
|
||||
|
|
|
@ -2,7 +2,8 @@ import pytest
|
|||
from hypothesis import given
|
||||
from hypothesis.strategies import integers
|
||||
|
||||
from character.models.character import Character
|
||||
from character.models.character import Character, Profile
|
||||
from character.models.dice import Dice
|
||||
from character.tests.utils import ability_values, levels, modifier_test
|
||||
|
||||
|
||||
|
@ -70,17 +71,24 @@ def test_defense(armor, shield, dexterity, misc):
|
|||
|
||||
|
||||
@given(level=levels(), intelligence=ability_values())
|
||||
def test_mana_max(level, intelligence):
|
||||
char = Character(level=level, value_intelligence=intelligence)
|
||||
def test_mana_max_mage(level, intelligence):
|
||||
profile = Profile(
|
||||
name="Magicien",
|
||||
life_dice=Dice.D4,
|
||||
magical_strength=Profile.MagicalStrength.INTELLIGENCE,
|
||||
mana_max_compute=Profile.ManaMax.DOUBLE_LEVEL,
|
||||
)
|
||||
char = Character(level=level, profile=profile, value_intelligence=intelligence)
|
||||
assert char.mana_max == 2 * level + modifier_test(intelligence)
|
||||
|
||||
|
||||
@given(
|
||||
level=levels(), intelligence=ability_values(), mana_consumed=integers(min_value=0)
|
||||
@given(level=levels(), wisdom=ability_values())
|
||||
def test_mana_max_druid(level, wisdom):
|
||||
profile = Profile(
|
||||
name="Druide",
|
||||
life_dice=Dice.D4,
|
||||
magical_strength=Profile.MagicalStrength.WISDOM,
|
||||
mana_max_compute=Profile.ManaMax.LEVEL,
|
||||
)
|
||||
def test_mana_remaining(level, intelligence, mana_consumed):
|
||||
char = Character(
|
||||
level=level, value_intelligence=intelligence, mana_consumed=mana_consumed
|
||||
)
|
||||
mana_max = 2 * level + modifier_test(intelligence)
|
||||
assert char.mana_remaining == mana_max - mana_consumed
|
||||
char = Character(level=level, profile=profile, value_wisdom=wisdom)
|
||||
assert char.mana_max == level + modifier_test(wisdom)
|
||||
|
|
Loading…
Reference in a new issue