def fight_skeleton(player): time.sleep(2) monster = monsters.Skeleton() time.sleep(2) monster.descr_monster() print() while True: choice = player.choose() if choice == "q": break if choice == "3": player.use_potion() player.display_hp() else: pl_dam = player.attack(choice) if pl_dam: monster.update_hp(pl_dam) if monster.hp < 1: conditions.update_stats(player.hp, monster.hp) break time.sleep(1) print("the monster now has", monster.hp, "hp\n") if player.stunned == True: player.stunned = False move = monster.attack(player) if move["move_type"] == "stab": if move["blocked"] == True: player.update_shield(move["damage"]) else: player.update_hp(move["damage"]) elif move["move_type"] == "slash": if move["blocked"] == True: player.update_shield(move["damage"]) else: player.update_hp(move["damage"]) #elif move["move_type"] == "block": #player.update_hp(move["damage"]) if player.hp < 1: conditions.update_stats(player.hp, monster.hp) break time.sleep(1) player.display_hp()
def test_hard_win(self): attacker = monsters.Skeleton(550) defender = monsters.ArchDevil(5) result = attacker.fight_with(defender) self.assertEqual(result, (1, 0))
def reset_sell_items(self): self.sell_items = [] def print_sell_items(self): print("You have " + player().gold + " gold.") #Tells player what items are for sale. for item in self.sell_items: print(item) def buy_item(self, item): for items in sell_items: if item == items.name and player.gold <= item.value: # Fix player and item calls. Next 3 lines included. player.inventory.append(item) self.sell_items -= items player.gold -= item.value available_monsters = [monsters.Skeleton()] class Room: def __init__(self, name, room_text, rating): self.name = name self.room_text = room_text self.rating = rating def __str__(self): return room_text def get_monster(self): potential_monsters = [] for mob in available_monsters: if mob.rating == self.rating: potential_monsters.append(mob) mob_in_room = []
def test_bonus_win(self): attacker = monsters.Skeleton(24) defender = monsters.Cerberus(7) result = attacker.fight_with(defender) self.assertEqual(result, (1, 0))