Ejemplo n.º 1
0
def start_world(player):
    print("You arrive at Start Town. A friendly local waves hello.")
    sleep(1)
    talk(
        "- Oi mate! Welcome to Start Town! We don't get many new folk here, stay a while!",
        1)
    dialog = [
        "I heard sometimes weapons land critical hits that do 3x damage!",
        "I wish I was a pegasus. What? You weren't supposed to hear that! Go away!",
        "A strange man came through here muttering about 'spaghetti code' and 'player and"
        " enemy objects' I think he's a bit coo-coo.",
        "I've heard that Fergus the Shopkeep here has the cheapest Health Potions around. In a 3 mile radius.",
        "Where did you say you're from? Some town by the name of player.town_name? What a strange place.",
        "A newbie's defence has only around a 1/10 shot of working. Better get some armour, huh?",
        "The quest system is so broken. It should be a list, damnit.",
        "What's with the guy that welcomes the new people here? \"ayo deadass wuz yo name nibba?\" Who speaks"
        " like that here? "
    ]

    active = True
    while active:
        action = menu("Start Town", options=False)
        if action == "shop":
            print("You have arrived at the shop. You begin to look around...")
            sleep(1)
            shop.start_store(player)
        elif action == "inventory":
            inventory.use_item(player)
        elif action == "talk":
            print("- " + random.choice(dialog))
        elif action == "exit":
            active = False
Ejemplo n.º 2
0
def combat(monster):
    """
    Function manages whole combat system, reads player and enemy statisctics and calls
    other functions to return combat rewards (such as experiece, items and gold)
    """

    win = True
    monster_stats, graphic, monster_name, exp, gold = monster

    player_stats = character.get_battle_stats()
    player_stats = convert_stats(player_stats)
    player_damage = player_stats["Attack"] - monster_stats["Defence"]
    monster_damage = monster_stats["Attack"] - player_stats["Defence"]

    while monster_stats["HP"] > 0 and player_stats["HP"] > 0:

        handle_graphics(graphic, monster_name, monster_stats, player_stats)
        combat_action = functions.getch()

        if combat_action == "1":

            if player_damage > 0:
                monster_stats["HP"] -= player_damage

            if monster_damage > 0 and monster_stats["HP"] > 0:
                player_stats["HP"] -= monster_damage

        elif combat_action == "2":
            player_stats["HP"] += inventory.use_item()

        elif combat_action == "3":
            character.change_hp(-10)
            return not win

    return resolve_encounter(player_stats["HP"], exp, gold, monster_name)
Ejemplo n.º 3
0
def battle(player, enemies):
    print("\n---{BATTLE START}---")
    try:
        if player.health > 0:
            print("{} joined the battle! ({}/{}HP)".format(
                player.name, player.health, player.max_health))
        else:
            print("ur dead lmao")
    except TypeError:
        print(
            "Battle system currently down, sorry. Go nag the dev about it (For error reporting, its a 'TypeError')"
        )
        print("also... you really shouldn't even be able to see this. go away")
        return "Broke"

    while player.health > 0:

        # check for the whole enemy team being dead.
        for enemy in enemies:
            dead = 0
            if enemy.health <= 0:
                dead += 1
            if dead == len(enemies):
                player.xp_check()
                return "Won"

        status = random.choice(enemy.doing)

        if len(enemies) == 1:
            choice = input(
                "\n{} {} What do? "
                "\n[A]ttack [I]nventory [S]pecial [E]scape\n>>>".format(
                    enemy.name, status)).lower().strip()
        else:
            names = []
            for enemy in enemies:
                names.append(enemy.name)
            status = status.replace("s ", " ")  # a grammar thing
            choice = input(
                ("\n{} {} What do? "
                 "\n[A]ttack [I]nventory [S]pecial [E]scape\n>>>".format(
                     arrange(names), status))).lower().strip()

        # Attacking
        if choice == "a" or choice == "attack":

            print("\nAttack who? (type 'cancel' to cancel attack)")
            target = select(enemies)

            if target:
                # Player Turn
                dam = weapons[player.weapon]  # returns attack stats
                dam += randint(0, dam)
                # random crits
                if randint(0,
                           100) <= player.crit_chance:  # a ten percent chance
                    dam += randint(dam * 2, dam * 3)
                    print("[!] CRITICAL HIT!")

                damage(target, dam)
                sleep(1)
                if target.health < 0:  # if you killed an enemy
                    print("[!] {} died!".format(target.name))

                print()  # spacer
                # Enemy Turn
                for enemy in enemies:
                    if enemy.health <= 0:
                        enemy.gain(player)
                        enemies.remove(enemy)
                    else:
                        print(enemy.name + " attacked!")
                        damage(player, enemy.damage + randint(0, enemy.damage))
                        sleep(1)
                        print()  # just a spacer
                    if len(enemies) == 0:
                        player.xp_check()
                        return "Won"

        # Inventory
        elif choice == "i" or choice == "inventory":
            item = inventory.use_item(player, battle=True)
            for enemy in enemies:
                if item == None:
                    pass
                elif item == enemy.item_trigger:
                    print("ITEM TRIGGER!")
                    enemy.trigger()

        # Special
        elif choice == "s" or choice == "special":
            print("Perform Special on who?")
            target = select(enemies)
            if target:
                target.special(player)
                # if enemy.health <= 0:  # if enemy dead
                #     break  # break just makes it go to win sequence

                # TODO: perhaps in the future make this script an Enemy class default?
                for enemy in enemies:
                    if enemy.health <= 0:
                        enemy.gain(player)
                        enemies.remove(enemy)
                    else:
                        print(enemy.name + " attacked!")
                        damage(player, enemy.damage + randint(0, enemy.damage))
                        sleep(1)
                        print()  # just a spacer
                    if len(enemies) == 0:
                        player.xp_check()
                        return "Won"

        # Escape # TODO: add ability to disable this option before a battle
        elif choice == "e" or choice == "escape":
            escape_number = randint(1, 100)
            if escape_number < 50:
                print("[!] You escaped from {}".format(enemy.name))
                return "Escaped"
            else:
                print("[!] You couldn't escape!")
                for enemy in enemies:
                    print("{} attacked!".format(enemy.name))
                    damage(player, enemy.damage)
                    print()

        # Unknown Command
        else:
            print("'{}' not recognized, please try again.".format(choice))

    # End sequence
    if not enemies:
        player.xp_check()
        sleep(1.5)
        return "Won"
    elif player.health <= 0:
        print("You lost. You lose 25% of your money.")
        player.health = 1
        player.money = player.money * .75
        return "Lost"
    else:
        print(
            "Unknown Error: You shouldn't be able to see this text unless the laws of math suddenly changed."
        )
        return None
Ejemplo n.º 4
0
def ptonio(player):
    dialog = [
        "Howdy, pardner!",
        "Business out here's interestin', ya know. We live on the edge of the law round here.",
        "Safe-tee pro-toe-calls? I ain't heard nothin' like that before 'round here.",
        "Any potion is legal if nobody catches you with em.", "Yeehaw!"
    ]
    active = True
    while active:
        action = menu("Ptonio")
        if action == "shop":
            print("You have arrived at the shop. You begin to look around...")
            sleep(1)
            shop.ptonio_store(player)
        elif action == "inventory":
            inventory.use_item(player)
        elif action == "talk":
            print("- " + random.choice(dialog))
        elif action == "exit":
            active = False
        elif action == "other":
            o_check = True
            while o_check:
                print("----{PTONIO DIRECTORY}----\n")
                print("[1] Strange Alley\n"
                      "[2] Ptonio Dump\n"
                      "[3] Bulletin Board\n")
                print("\nWhere would you like to go? ('cancel' to cancel)")
                choice = input(">>>").strip()

                if choice == "1":
                    talk("You enter the strange alley...", 3)
                    # TODO: verifiy the below
                    if "metMel" not in player.metadata:
                        if "knowMelName" not in player.metadata:
                            talk("-[?] Eh? Who are you?", 2)
                            talk(
                                "- I sense you are new round here, aren't ya?",
                                2.5)
                            talk(
                                "- What brings you down here? Nobody ever comes down the alley...",
                                3)
                            talk(
                                "- You must be seekin some sort of potion, ain't that right?",
                                2.5)
                            talk(
                                "-[MEL] Well, alright. Folks round here call me Mel. I sell, uh, questionable potions.",
                                4)
                            player.metadata.append("knowMelName")
                            talk(
                                "- Apparently the Longbois didn't prefer that I allow just anyone to be tall, so\n"
                                "  they attempted to shut me down", 6)
                            talk("- But I managed. And here we are", 2)
                        else:
                            talk("-[MEL] Eh? Who's that?", 1.5)
                            talk("- Oh. I've seen you before. Come on in.", 3)
                        talk("- So, what're you lookin for?")
                        choice = input(
                            "[1] A tall potion?\n"
                            "[2] Nothing, just seeing what you have.\n"
                            ">>>")
                        if choice == "1":
                            choice = input(
                                "- I don't produce that one anymore. If it's that you're lookin for, "
                                "you best leave.\n"
                                "[1] What if I did something for ya?\n"
                                "[2] Ok, bye.\n"
                                ">>>")
                            if choice == "2":
                                o_check = False
                            elif choice == "1":
                                player.metadata.append("metMel")
                                talk(
                                    "- Well, you COULD clear out some pests for me.",
                                    2)
                                talk(
                                    "- The outlaws are gettin a real mess. If you can clear em out, we can talk.",
                                    3)
                                if player.quest:
                                    if "MelQuestBacklog" not in player.metadata:
                                        player.metadata.append(
                                            "MelQuestBacklog")
                                        print(
                                            "[!] Already have quest! Come back after it's done."
                                        )
                                    else:
                                        print("[!] Come back without a quest!")
                                else:
                                    player.quest = "Defeat the Outlaws"
                        elif choice == "2":
                            print("- Oh, ok. Here you are, take a look.")
                            shop.early_mel_shop(player)
                        else:
                            print("you done broke it wow good job try again")
                            o_check = False
                    else:
                        print(
                            "-[MEL] Oooh, is that {}? Yes, come in...".format(
                                player.name))
                        if "MelQuestBacklog" in player.metadata:
                            print("Start quest? Defeat the Outlaws (y/n)")
                            choice = input(">>>").strip().lower()
                            if choice == "y":
                                player.quest = "Defeat the Outlaws"
                                o_check = False
                            elif choice == "n":
                                o_check = False
                        else:
                            shop.mel_shop(player)

                elif choice == "2":
                    print("Nothing here...")
                    sleep(2)
                    o_check = False
                elif choice == "3":
                    print("No missions right now... damn.")
                    sleep(3)
                    o_check = False
                elif choice.lower() == "cancel":
                    o_check = False
Ejemplo n.º 5
0
def topshelf(player):
    print("You arrive at Topshelf. A local towers above and you waves hello.")
    sleep(1)
    if "tall" not in player.traits:
        print("- Welcome, small one, to Topshelf, realm of the Longbois.")
    else:
        print("- Welcome to Topshelf, realm of the Longbois.")
    sleep(2)
    dialog = [
        "One must be considered quite tall to join the Longbois. Visit the evaluator if you wish to be judged.",
        "Jacob is the current leader of the Longbois. He's served us well.",
        "You may want to investigate the [O] path near the entrance of this world.\n It shows a directory of"
        " things harder to find in this town, had you not a directory.",
        "One fool wished to name our realm The Ceiling. I'm glad the great Dev denied that idea. The fool was "
        "smited.",
        "Think you're tall enough to join the Longbois? Perhaps you should visit the Evaluator."
    ]

    active = True
    while active:
        action = menu("Topshelf")
        if action == "shop":
            print("You have arrived at the shop. You begin to look around...")
            sleep(1)
            shop.topshelf_store(player)
        elif action == "inventory":
            inventory.use_item(player)
        elif action == "talk":
            print("- " + random.choice(dialog))
        elif action == "exit":
            print("You climb back down to the surface.")
            active = False

        elif action == "other":
            o_check = True
            while o_check:
                print("----{TOPSHELF DIRECTORY}----\n")
                print("[1] The Evaluator's Hut\n"
                      "[2] Longboi Hall\n"
                      "[3] Bulletin Board\n")
                print("\nWhere would you like to go? ('cancel' to cancel)")
                choice = input(">>>")

                if choice == "1":
                    print("You head to the Evaluator's Hut...")
                    sleep(2)
                    if "tall" not in player.traits or "Longboi" not in player.traits:
                        talk("-[THE EVALUATOR] Well, what have we here?", 1.5)
                        # TODO: redo the print/sleeps with talk()s
                        print(
                            "- I assume you are looking to get evaluated, yes?"
                        )
                        sleep(2)
                        print("- Hmmm...")
                        sleep(1.5)
                        print("- Uh huh...")
                        sleep(2)
                        print(
                            "- Well, you seem to be quite short by Longboi standards."
                        )
                        sleep(1)
                        talk(
                            "- We require a certain height that you must achieve. I do admire"
                            " your determination, however...", 4)
                        talk(
                            "- Tell you what, small one. I happen to know of a town nearby that has a special "
                            "something that could boost you a bit. I'll show you on this map...",
                            4)
                        player.metadata.append("Ptonio")
                        print("[!] You have learned about Ptonio!")
                        sleep(1.5)
                        print(
                            "- Yes... Ptonio is a short ways away, but they have some potions."
                            " Try it out, you may find something good over there..."
                        )
                        o_check = False
                        sleep(3)
                    elif "Longboi" not in player.traits:
                        print("[INSERT EVALUATION]")
                        print("[!] You are now a Longboi!")
                        player.traits.append("Longboi")
                    else:
                        print(
                            "-[THE EVALUATOR] Why hello there fellow Longboi. I hope you enjoy "
                            "your stay here at Topshelf.")
                        sleep(3)
                elif choice == "2":
                    print("[UNDER CONSTRUCTION]")
                elif choice == "3":
                    print("No quests it seems...")
                    sleep(1)
                elif choice == "cancel":
                    o_check = False
                else:
                    print("'{}' isn't on the directory!")
Ejemplo n.º 6
0
def main():
    print_header()
    # player = start_choice()
    player = start()
    if not player:
        player = start_choice()
    info(player)
    sleep(1)
    active = True

    while active:
        option = menu()
        # Quest Option
        if option == "quest":
            if player.quest:  # check that a quest exists
                confirm = input("Start quest?: {} (y/n) \n>>>".format(
                    player.quest))
                if confirm.find("y") != -1:
                    # TODO: make a good system for this, cuz 2 lines of extra elifs per quest cant be great
                    # if player.quest == "Clap the Dragon":
                    #     quests.clap_the_dragon(player)
                    if player.quest == "Dab on Turtles":
                        quests.battle_turtles(player, 3)
                    elif player.quest == "Beat up the Developer":
                        quests.beat_the_dev(player)
                    elif player.quest == "Mess with Goblins":
                        quests.mess_with_goblins(player)
                    elif player.quest == "Ryan's Battle":  # test battle - only accessable via debug mode
                        quests.ryans_battle(player)
                    elif player.quest == "Defeat Ryan":
                        quests.defeat_ryan(player)
                    elif player.quest == "Defeat the Outlaws":
                        quests.defeat_outlaws(player)
                    else:
                        print("You don't have a quest!")
                else:
                    print(
                        "ok then be that way man all this work i do to launch quests and u be that way ok cool"
                    )
            else:
                print(
                    "You don't have a quest! Go find one before trying to start! There may be some in town..."
                )

        # Inventory Option
        elif option == "inventory":
            inventory.use_item(player)

        # Shop Option
        elif option == "shop":
            shop.shop(player)

        # Player Info
        elif option == "player":
            info(player)

        # Debug mode
        elif option == "debug":
            player.debug()

        # World Option
        elif option == "world":
            world.world_init(player)
            selection = world.select_world()
            if selection == "Test World":
                world.test_world(player)
            elif selection == "Start Town":
                world.start_world(player)
            elif selection == "Topshelf":
                world.topshelf(player)
            elif selection == "Ptonio" and "Ptonio" in player.metadata:
                world.ptonio(player)

        # Save the game!
        elif option == "save":
            data.save(player)
            data.save_settings(settings)
            print("[!] Saved game!")

        # I NEED HELP!!!
        elif option == "help":
            game_help()

        # Set some tings
        elif option == "settings":
            change_settings()

        # Exit Option
        elif option == "exit":
            # print("See ya later!")
            data.save(player)
            data.save_settings(settings)
            active = False