def test_creature_moving_on_grid(): grid = {(0,0): None, (1,1): None} creature = Creature(grid=grid, pos=(0,0)) assert grid[0, 0] == creature creature.move((1,1)) assert grid[0, 0] == None assert grid[1, 1] == creature assert creature.x == 1 assert creature.y == 1
def test_ac_set_with_armor_with_no_dex_bonus(): creature = Creature(armor=Armor("Natural", 12, 0), dexterity=15) assert creature.ac == 12
def test_ac_can_be_set_directly(): creature = Creature(ac=14) assert creature.ac == 14
def test_default_ac_is_10_plus_dex_mod(): creature = Creature(dexterity=15) assert creature.ac == 12
def test_abilities_computation_of_ability_modifiers(value, modifier, ability): creature = Creature(**{ability: value}) assert getattr(creature, ability).mod == modifier
def test_cast_spell_raises_error(spell_slots, spell, spell_level): with pytest.raises(RulesError): creature = Creature(spell_slots=spell_slots, spells=[TEST_SPELL]) creature.cast(spell, spell_level, [])
def test_distance_to_creature(): grid = {} creature = Creature(grid=grid, pos=(0,0)) target = Creature(grid=grid, pos=(0,10)) assert creature.distance_to(target) == 10
def test_creature(): return Creature(max_hp=5, spell_slots=[1], spells=[Spell("test")])
def test_creature_cannot_move_into_non_empty_space(): grid = {(0,0): None, (1,1): object()} creature = Creature(grid=grid, pos=(0,0)) assert grid[0, 0] == creature with pytest.raises(RulesError): creature.move((1,1))
def test_creature_spell_dc(): creature = Creature(level=1, spellcasting="wisdom", wisdom=12) assert creature.spell_dc == 11
def test_creature_max_hp_is_at_least_1(): creature = Creature(level=1, hd=Dice("1d1"), constitution=2) assert creature.max_hp == 1