def game_intro(): """Introduction to the game""" if Player.Pclass == "": print_slow("Welcome to TxtBasedAdv") print_slow("Please enter a name: ", 0.025) Player.name = input() name_check(Player.name) print_slow("Hello " + Player.name) print_slow("\nChoose your class", 0.025) print_slow("1.Swordsman Class \n2.Wizard Class \n3.Rogue Class", 0.025) Player.uniqueId = uuid.uuid1().int choice = input() if choice == "1" or choice.lower() == "swordsman": _assign_class("swordsman", 10, 10, 100, 100, 'sword', 'bronze armor') elif choice == "2" or choice.lower() == "wizard": _assign_class("wizard", 5, 3, 50, 50, 'wand', 'cloth armor') elif choice == "3" or choice.lower() == "rogue": _assign_class("rogue", 7, 5, 70, 70, 'dagger', 'hard cloth armor') else: print("Wrong choice") game_intro() elif Player.Pclass != "": intro() else: print("GameIntro went wrong!!")
def intro(): """Another part to the game introduction""" inventory_insert('potion') print_slow("Now you are ready to go on an adventure. You will be able to travel", 0.025) print_slow("and collect awesome items and level up to your hearts content.", 0.025)
def _assign_class(PlayerClass, strength, dfs, hp, mHp, weapon, armor): """Assigning the players class and stats Arguments: PlayerClass - The class the player chose str - Starting strength of the player dfs - Starting defense of the player hp - Starting hp of the player mHp - Starting MaxHP of the player weapon - Starting weapon of the player armor - Starting armor of the player """ print_slow("\nWelcome to the " + PlayerClass + " class") Player.Pclass = PlayerClass Player.Strength = strength Player.Defense = dfs Player.hp = hp Player.MaxHP = mHp equip_insert(weapon) print_text("You have been given a " + weapon) equip_insert(armor) print_text("You have been given a " + armor + ".\n") intro()
def _enemy_introduction(): """Introduction for the start of battle""" print_slow("It's a " + ENEMY_STATS.name, 0.05) if ENEMY_STATS.questFight: QuestInfo.InQuest = True
def _random_encounter(): rand = random.randrange(0, 10) if 0 <= rand <= 5: print("A group of trees\n") elif 6 <= rand <= 8: print_slow("You encountered a monster", 0.05) fight() elif rand == 9: print_slow("You found an item on the ground", 0.05) random.seed() type = ["item", "weapon", "armor"] choosenType = random.choice(type) list_of_items = item_list(type) item = [] if not list_of_items: item = random.choice(list(item_list('item').items())) else: item = random.choice(list(list_of_items.items())) print(item[0] + "\n") inventory_insert(item[0]) else: print("ERROR: Something went wrong with Forest")
def healer(): """Gives the player a choice to heal in exchange for gold""" print_slow("Welcome to the healer.\nWould you like to heal?") choice = input("Y/N\n") if Player.hp != Player.MaxHP and choice == 'Y' or choice == 'y': _check_player_healing() elif choice == 'N' or choice == 'n': print("Thank you for visiting") else: print("Wrong choice")
def forest_intro(): """The introduction to entering the forest""" if Player.hp > 0: print_slow("Welcome to the forest!", 0.05) elif Player.hp <= 0: if Player.gold <= 0 and check_healing() == False: death() else: print("You do not have enough hp to fight.") else: print("ERROR: Can't Access forest")
def menu_sell(): """Menu for player selling an item/armor/weapon""" sell = "" while sell != "exit": print_inventory() print_slow("\nWhat item do you want to sell from your inventory?", 0.05) print("Type exit to go back") sell = input() for key, value in list(Player.Inventory.items()): if key == sell: _sell_item(sell, key, value)
def augmentation(): """Allows the player to augment their weapon or armor""" print_slow("\nWelcome to the augmentation center.", 0.05) print_slow("Please select what you want to augment", 0.05) print("\n1.Weapon \n2.Armor") choice = input() if choice == "1": augment_item("weapon") elif choice == "2": augment_item("armor") else: print("wrong key")
def _players_turn(player_damage): """Players turn to attack""" print("What action is to be performed?") print("1. Attack") print("2. Use Item") battle_option = input() print("") if battle_option == "1" or battle_option.lower() == "attack": print_slow("You hit the " + ENEMY_STATS.name + " for " + str(player_damage) + " damage", 0.025) ENEMY_STATS.HP -= player_damage print_slow(ENEMY_STATS.name + " now has " + str(ENEMY_STATS.HP) + " life left.", 0.025) elif battle_option == "2" or battle_option.lower() == "use item": use_item() else: print("That is not a valid option")
def kill_the_rats(): """Quest to kill 10 rats""" if QuestInfo.QuestNumber == 0: if not QuestInfo.QuestSeen: print_slow("QUEST NAME: Kill The Rats\n") print_slow("The first quest on this journey is to kill 10 rats\n") QuestInfo.QuestSeen = True QuestInfo.InQuest = True pause() if 'rat' in QuestInfo.MonstersKilled.keys(): print("RATS KILLED: " + str(QuestInfo.MonstersKilled['rat']) + "\n") if QuestInfo.MonstersKilled['rat'] >= 10: print("Congragulations you have completed the first quest\n") QuestInfo.QuestNumber = QuestInfo.QuestNumber + 1 QuestInfo.QuestSeen = False QuestInfo.InQuest = True quest_reward() pause()
def goblin_extermination(): """Quest to kill 10 goblins""" if QuestInfo.QuestNumber == 1: if not QuestInfo.QuestSeen: print_slow("QUEST NAME: Goblin Extermination\n") print_slow("Kill 10 goblins to complete the quest\n") QuestInfo.QuestSeen = True QuestInfo.InQuest = True pause() if 'goblin' in QuestInfo.MonstersKilled.keys(): print("GOBLINS KILLED: " + str(QuestInfo.MonstersKilled['goblin']) + "\n") if QuestInfo.MonstersKilled['goblin'] >= 10: print("Congragulations on completing the quest\n") QuestInfo.QuestNumber = QuestInfo.QuestNumber + 1 QuestInfo.QuestSeen = False QuestInfo.InQuest = True quest_reward() pause()
def _win(): """Winning state for player""" if Player.hp > 0: print_slow("YOU WON!!!", 0.05) exp = random.randrange(0, ENEMY_STATS.exp) + (ENEMY_STATS.lvl * 2) Player.exp += exp print_slow("You gained " + str(exp) + " exp", 0.05) level_up() print_slow("EXP: " + str(Player.MaxExp) + "/" + str(Player.exp), 0.05) monster_drop(ENEMY_STATS.lvl) if not ENEMY_STATS.questFight: if ENEMY_STATS.name in QuestInfo.MonstersKilled: QuestInfo.MonstersKilled[ENEMY_STATS.name] += 1 else: QuestInfo.MonstersKilled[ENEMY_STATS.name] = 1
def PlayerStats(): '''Displays the players stats''' print_slow("Name: " + Player.name) print_slow("Level: " + str(Player.lvl)) print_slow("HP: " + str(Player.hp) + "/" + str(Player.MaxHP)) print_slow("EXP: " + str(Player.exp) + "/" + str(Player.MaxExp)) print_slow("Strength: " + str(Player.Strength)) print_slow("Defense: " + str(Player.Defense)) print_slow("Gold: " + str(Player.gold)) print_slow("\nEquipment:") print_equip()
def print_inventory(): """Prints the players inventory""" for key, value in list(Player.Inventory.items()): print_slow(key + " X " + str(value[Item.count]), 0.05)
def _enemies_turn(enemy_damage): """Enemies turn to attack""" print_slow(ENEMY_STATS.name + " hit you for " + str(enemy_damage) + " damage", 0.025) Player.hp -= enemy_damage print_slow("You have " + str(Player.hp) + " life left.", 0.025)