def test_equip(): assert (player.equip(objects.bandit)) == ("Bandit cannot be equipped.") assert (player.equip(objects.healing_potion)) == ("There is no Healing Potion in your inventory.") assert (player.equip(objects.iron_sword)) == ("You have equipped Iron Sword (equipped) as weapon.") assert (player.equip(objects.iron_armour)) == ("You have equipped Iron Armour (equipped) as armour.") assert (player.equip(objects.iron_shield)) == ("You have equipped Iron Shield (equipped) as shield.") objects.iron_sword.equipped_as_weapon = False objects.iron_armour.equipped_as_armour = False objects.iron_shield.equipped_as_shield = False
def test_flee(): player.move_north() player.equip(objects.iron_sword) import random random.seed(0) assert (player.flee()) == "Bandit hits you for 25 damage!\nYou now have 75 HP.\nYou are in the starting room." text_adventure.tile_exists(-1,0).enemy.hp = 100 player.move_south() player.hp = 100 objects.iron_sword.equipped_as_weapon = False
def test_attack_weapon(): player.move_north() player.equip(objects.iron_sword) import random random.seed(0) assert (player.attack()) == "You hit Bandit with Iron Sword (equipped), dealing 37 damage!\nBandit now has 63 HP.\nBandit hits you for 25 damage!\nYou now have 75 HP." text_adventure.tile_exists(player.location_x, player.location_y).enemy.hp = 100 player.move_south() player.hp = 100 objects.iron_sword.equipped_as_weapon = False
def test_attack(): random.seed(0) player.equip(objects.iron_sword) player.move_north() assert player.do_action( text_adventure.Attack ) == "You hit Bandit with Iron Sword (equipped), dealing 37 damage!\nBandit now has 63 HP.\nBandit hits you for 25 damage!\nYou now have 75 HP." player.hp = 100 objects.bandit.hp = 100 objects.iron_sword.equipped_as_weapon = False player.move_south()
def test_gold(): assert (player.equip(objects.gold)) == ("Gold cannot be equipped.")