Ejemplo n.º 1
0
def gameloop(player, travel):
    choice = ""
    while choice != "quit":
        choice = input(">>> ")
        # using commands
        if choice == "help":
            Actions.get_help(player)
        elif choice == "look":
            Travel.look(travel)
        elif choice == "move":
            Travel.move(travel)
            in_city = False
            for city in Cities:
                if travel.x == city[1] and travel.y == city[2]:
                    print("You are now in " + city[0])
                    in_city = True
                else:
                    pass
            if in_city == False:
                name, hp, attack, toughness = random.choice(Enemies)
                mob = Enemy(name, hp, attack, toughness)
                
                Actions.combat_mode(player, mob)
                
        elif choice == "location":
            Travel.get_location(travel)
        elif choice == "map":
            Travel.map(travel, player)
        elif choice == "stats":
            Actions.stats(player)
        elif choice == "read note":
            Actions.read_note(player)
        elif choice == "inventory":
            Actions.check_inventory(player)
        elif choice == "potions":
            Actions.check_potions(player)
        elif choice.partition(" ")[0] == "check":
            try:
                Actions.check_item(player, choice.partition(" ")[2])
            except IndexError:
                print("You need an item to check")
        elif choice == "boss":
            in_city = False
            for city in Cities:
                if travel.x == city[1] and travel.y == city[2]:
                    in_city = True
                    if city_completion[city[0]] == True:
                        print("You have already killed this cities boss")
                    else:
                        for boss in Bosses:
                            if city[0] in boss:
                                name, hp, attack, toughness = boss[1], boss[2], boss[3], boss[4]
                                boss_mob = Enemy(name, hp, attack, toughness)
                                Actions.boss_combat_mode(player, boss_mob)
                                Actions.get_item(player, boss[5])
                                city_completion[city[0]] = True
                else:
                    pass
            if in_city == False:
                print("Bosses are in each city")
        elif choice == "wallet":
            Actions.coins(player)
        elif choice == "shop":
            in_city = False
            for city in Cities:
                if travel.x == city[1] and travel.y == city[2]:
                    in_city = True
                    Actions.shop(player)
                else:
                    pass
            if in_city == False:
                print("There is a shop in each city")
        elif choice == "attack":
            print("You slash the air")
        elif choice == "victory":
            Actions.victory(player)
        elif choice == "save":
            SaveLoad.save(player, travel)
        elif choice =="load":
            SaveLoad.load(player, travel)        
        elif choice == "quit":
            sys.exit()
        else:
            print("invalid choice - type 'help' for commands")