move inventory verbs to inventory map from character

This commit is contained in:
evilchili
2024-08-29 16:41:15 -07:00
parent 0eda35b90d
commit 68a8f4920b
4 changed files with 89 additions and 70 deletions
+20 -21
View File
@@ -33,21 +33,23 @@ def test_equipment_inventory(db, carl):
assert fireball in carl.spells
assert fireball not in carl.equipment
pole_one = all_carls_poles[0]
# equip one pole
assert carl.equip(all_carls_poles[0])
assert pole_one.equip()
# can't equip it twice
assert not carl.equip(all_carls_poles[0])
assert not pole_one.equip()
# unequip it
assert carl.unequip(all_carls_poles[0])
assert pole_one.unequip()
# can't unequip the unequipped ones
assert not carl.unequip(all_carls_poles[1])
assert not carl.unequip(all_carls_poles[2])
assert not all_carls_poles[1].unequip()
assert not all_carls_poles[2].unequip()
# drop one pole
assert carl.equipment.remove(all_carls_poles[0])
assert carl.equipment.remove(pole_one)
assert ten_foot_pole in carl.equipment
# drop the remaining poles
@@ -56,7 +58,7 @@ def test_equipment_inventory(db, carl):
assert ten_foot_pole not in carl.equipment
# can't drop what you don't have
assert not carl.equipment.remove(all_carls_poles[0])
assert not carl.equipment.remove(pole_one)
def test_inventory_bundles(db, carl):
@@ -108,15 +110,12 @@ def test_spell_slots(db, carl, wizard):
# prepare the cantrip
carls_prestidigitation = carl.spells.get(prestidigitation)
assert carl.prepare(carls_prestidigitation)
assert carl.cast(carls_prestidigitation)
# prepare() and cast() require a spell from the spell inventory
carls_fireball = carl.spells.get(fireball)
assert carls_prestidigitation.prepare()
assert carls_prestidigitation.cast()
# can't prepare a 3rd level spell if you don't have 3rd level slots
assert carl.spellcaster_level == 1
assert not carl.prepare(carls_fireball)
assert not carl.spells.get(fireball).prepare()
# make carl a 5th level wizard so he gets a 3rd level spell slot
carl.level_up(wizard, num_levels=4)
@@ -124,10 +123,10 @@ def test_spell_slots(db, carl, wizard):
assert carl.spellcaster_level == 3
# cast fireball until he's out of 3rd level slots
assert carl.prepare(carls_fireball)
assert carl.cast(carls_fireball)
assert carl.cast(carls_fireball)
assert not carl.cast(carls_fireball)
assert carl.spells.get(fireball).prepare()
assert carl.spells.get(fireball).cast()
assert carl.spells.get(fireball).cast()
assert not carl.spells.get(fireball).cast()
# level up to 7th level, gaining 1 4th level slot and 1 more 3rd level slot
carl.add_class(wizard)
@@ -137,9 +136,9 @@ def test_spell_slots(db, carl, wizard):
assert len(carl.spell_slots_available[3]) == 1
# cast at 4th level
assert carl.cast(carls_fireball, 4)
assert not carl.cast(carls_fireball, 4)
assert carl.spells.get(fireball).cast(level=4)
assert not carl.spells.get(fireball).cast(level=4)
# use the last 3rd level slot
assert carl.cast(carls_fireball)
assert not carl.cast(carls_fireball)
assert carl.spells.get(fireball).cast()
assert not carl.spells.get(fireball).cast()
+7 -7
View File
@@ -82,8 +82,8 @@ def test_charges(db, carl):
db.add_or_update(carl)
carls_dagger = carl.equipment.get(dagger_of_lulz)
assert carl.equip(carls_dagger)
assert carl.attune(carls_dagger)
assert carls_dagger.equip()
assert carls_dagger.attune()
assert len(carls_dagger.charges) == dagger_of_lulz.charges == 6
assert len(carls_dagger.charges_available) == dagger_of_lulz.charges == 6
@@ -132,24 +132,24 @@ def test_attunement(db, carl):
assert carl.armor_class == 10
assert len(carl.attuned_items) == 0
carl.equip(carls_shield)
carls_shield.equip()
assert plus_two_ac in carl.modifiers["armor_class"]
assert ranged_resistance not in carl.modifiers[DamageType.ranged_weapon_attacks]
assert carl.armor_class == 12
assert carls_shield not in carl.attuned_items
carl.attune(carls_shield)
carls_shield.attune()
assert carl.armor_class == 12
assert plus_two_ac in carl.modifiers["armor_class"]
assert ranged_resistance in carl.modifiers[DamageType.ranged_weapon_attacks]
assert carls_shield in carl.attuned_items
assert carl.equip(carl.equipment.get(helm))
assert carl.equipment.get(helm).equip()
assert carl.armor_class == 13
assert carl.unattune(carls_shield)
assert carls_shield.unattune()
assert carl.armor_class == 13
assert ranged_resistance not in carl.modifiers[DamageType.ranged_weapon_attacks]
assert carl.unequip(carls_shield)
assert carls_shield.unequip()
assert carl.armor_class == 11