def shop(character, en1): from data.menu import game_menu os.system("cls") print("Hello {}! Welcome to the General Store, how may I help you today?".format(character.name)) print("1.) Buy") print("2.) Sell") print("Press [Enter] to exit the shop.") choice = input("> ") if choice == "1": print("1.) Weapons") print("2.) Armour") print("3.) Items") print("B.) Back") choice = input("> ") if choice == "1": buy_weapons(character, en1) if choice == "2": buy_armour(character, en1) if choice == "3": buy_items(character, en1) if choice.lower() == "b": shop(character, en1) elif choice == "2": print("1.) Weapons") print("2.) Armour") print("B.) Back") choice = input("> ") if choice == "1": sell_weapons(character, en1) if choice == "2": sell_armour(character, en1) if choice.lower() == "b": shop(character, en1) else: game_menu(character, en1)
def exit_check(character, en1): from data.menu import game_menu os.system("cls") print("Are you sure you want to exit? Make sure you have saved first. Y/N") choice = input("> ") if choice.lower() == "y": sys.exit() else: game_menu(character, en1)
def move_d(character, en1): from data.menu import game_menu destination = Map.zone_map[character.location][Map.RIGHT] if destination == "": print("You can't go that way.") input(">...") game_menu(character, en1) else: movement_handler(destination, character, en1)
def quests(character, en1): from data.menu import game_menu os.system("cls") print("Select an Option:") print("1.) Spell Information") print("2.) Quest Log") option = input("> ") if option == "1": spell_info(character, en1) elif option == "2": quest_log(character, en1) else: game_menu(character, en1)
def move_w(character, en1): from data.menu import game_menu # print("Where do you want to move to?\n") # print("Options = (W, A, S, D)") # direction = input("> ") # if direction in ['W', "w"]: destination = Map.zone_map[character.location][Map.UP] if destination == "": print("You can't go that way.") input(">...") game_menu(character, en1) else: movement_handler(destination, character, en1)
def run(character, en1): from data.menu import game_menu run_chance = random.randint(1, 10) if character.location == "d4": if character.d4_event_1: print("You can't run!") input(">...") if character.location == "f6": if character.f6_event_2: print("You can't run!") input(">...") if character.location == "g6": if character.g6_event_2: print("You can't run!") input(">...") if character.location == "k6": if character.k6_event_2: print("You can't run!") input(">...") if character.location == "o7": if character.o7_event_2: print("You can't run!") input(">...") if character.location == "q10": if character.q10_event_1: print("You can't run!") input(">...") if en1.name == "Baron of Hell": print("You can't run from the Baron of Hell!") input(">...") if character.location not in ["d4", "f6", "g6", "k6", "o7", "q10", "r10"]: if run_chance >= 6: print("You ran away successfully.") input(">...") character.town_zone = True character.forest_zone = True character.water_zone = True character.desert_zone = True character.dungeon_zone = True game_menu(character, en1) else: print("You tried to run away but were hit by {}.".format(en1.name)) input(">...") character.player_atk_turn = False if not character.player_atk_turn: if en1.name == "Baron of Hell": baron_of_hell_atk(character, en1) else: enemy_atk(character, en1)
def end_fight_lose(character, en1): from data.menu import game_menu os.system("cls") defeat_music(character) character.hp = character.max_hp en1.hp = en1.max_hp character.location = "d1" print("You died!") if character.gold <= 20: print("You've lost {} gold.".format(character.gold)) character.gold -= 20 character.gold = 0 else: print("You've lost 20 gold.") character.gold -= 20 input(">...") game_menu(character, en1)
def inventory(character, en1): from data.menu import game_menu os.system("cls") print("Select an Option:") print("1.) Equip") print("2.) Potions") print("3.) Misc") print("B.) Back") option = input("> ") if option == "1": item_type(character, en1) if option == "2": potion_items(character, en1) if option == "3": misc_items(character, en1) if option.lower() == "b": game_menu(character, en1)
def save(character, en1): from data.menu import game_menu if os.path.exists("save_file"): print("Are you sure you want to overwrite your current save? Y/N") option = input("> ") if option.lower() == "y": with open('save_file', 'wb') as f: pickle.dump(character, f) print("Game has been saved.") else: print("Game hasn't been saved.") else: with open('save_file', 'wb') as f: pickle.dump(character, f) print("Game has been saved.") input(">...") game_menu(character, en1)
def print_location(character, en1): from data.menu import game_menu print(Map.zone_map[character.location][Map.DESCRIPTION]) if character.location == 'f6': if character.f6_event_1: input(">...") print("You finally see a way out of the forest, on the edge of the forest is a river.") character.f6_event_1 = False elif character.location == 'g6': if character.g6_event_1: input(">...") print("You look around but there's no bridge in sight, it seems the only way to cross the river is to swim.\n" "Good thing you took all of those swimming classes.") character.g6_event_1 = False elif character.location == 'j6': if character.j6_event_1: input(">...") print("You're almost onto the other side of the river now, you can see the sand in the distance.") character.j6_event_1 = False elif character.location == "k6": if character.k6_event_1: input(">...") print("At last, dry land.") character.k6_event_1 = False elif character.location == "n6": if character.n6_event_1: input(">...") print("There's a small cabin up ahead, maybe you should take a look inside.") character.n6_event_1 = False elif character.location == "n7": if character.n7_event_1: input(">...") print("In the distance you see a small opening in the ground, that must be the entrance to Virwaki Dungeon.") character.n7_event_1 = False elif character.location == "o7": if character.n7_event_1: input(">...") print("You descend down the stairs into Virwaki Dungeon, which is dark, smelly, and has a lot of unnerving\n" "sounds coming from the depths of the Dungeon.") character.n7_event_1 = False input(">...") game_menu(character, en1)
def movement_handler(destination, character, en1): from data.menu import game_menu character.location = destination if Map.zone_map[character.location][Map.ZONE_NAME] in "town": print("\n" "You have gone to " + character.location + ".\n") print(cut_scene_art.village) print_location(character, en1) elif character.location in ["d4", "f6"]: print(cut_scene_art.forest) print_location(character, en1) elif character.location in ["g6", "j6"]: print(cut_scene_art.water) print_location(character, en1) elif character.location in ["k6", "n7"]: print(cut_scene_art.desert) print_location(character, en1) elif character.location in ["o7"]: print(cut_scene_art.dungeon) print_location(character, en1) else: game_menu(character, en1)
def teleport(character, en1): from data.menu import game_menu os.system("cls") if Colours.BOLD + Colours.ORANGE + "[Teleportation Stone]" + Colours.END in character.misc_items: print('''Where do you want to teleport to? Input coordinates e.g "d5".''') choice = input("> ") if choice.lower() in ["b6", "c2", "c5", "c6", "c7", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "e2", "e5", "e6", "e7", "f5", "f6", "g6", "h6", "i6", "j6", "k5", "k6", "k7", "l5", "l6", "m6", "m7", "n6", "n7", "o7", "o8", "o9", "o10", "p10", "q10"]: character.location = choice print("You have gone to {}.".format(choice)) input(">...") print_location(character, en1) elif choice.lower() in ["r10"]: print("It's probably not a good idea to teleport directly into the Baron's lair.") input(">...") else: print("Not a valid location.") else: print("You haven't unlocked teleportation yet.") input(">...") game_menu(character, en1)
def title_screen_selection(character, en1): maximize_console() os.system("cls") title_art() option = input("> ") if option == "1": intro(en1) elif option == "2": if os.path.exists("save_file"): with open('save_file', 'rb') as f: character = pickle.load(f) os.system("cls") print("Save file loaded.") input(">...") character.town_zone = True character.forest_zone = True character.water_zone = True character.desert_zone = True character.dungeon_zone = True character.battle_music_1 = True character.battle_music_2 = True character.boss_music_1 = True character.win_music_1 = True character.win_music_2 = True character.defeat_music_1 = True game_menu(character, en1) else: os.system("cls") print("You have no save file.") input(">...") title_screen_selection(character, en1) elif option == "3": help_menu(character, en1) elif option == "4": sys.exit() else: title_screen_selection(character, en1)
def end_fight_win(character, en1): from data.menu import game_menu from data.events import event_check os.system("cls") event_check(character) win_music(character) print("You defeated {}.\n".format(en1.name)) en1.hp = en1.max_hp if en1.name in ["Strange Man"]: input(">...") print( "You murder the strange man, search his corpse, and find ....5 gold." ) input(">...") character.gold += 5 if en1.name in ["Spider", "Bear", "Giant Frog", "Goblin"]: if character.d4_event_2: print(en1.name + " dropped x 5 " + Colours.BOLD + Colours.GREEN + "[Light Health Potion]" + Colours.END + ".") print("+ 5 " + Colours.BOLD + Colours.GREEN + "[Light Health Potion]" + Colours.END + ".\n") character.items.append({ 'name': Colours.BOLD + Colours.GREEN + "[Light Health Potion]" + Colours.END, 'property': 50, 'des': "+ 50 HP ", 'quantity': 5 }) character.d4_event_2 = False if character.level == 10: character.xp1 += 0 else: character.xp1 += 5 print("You gained 5 XP.") if character.xp1 >= character.xp2: level(character) loot1(character, en1) elif en1.name in ["Shark", "Octopus", "Giant Blowfish"]: if character.level == 10: character.xp1 += 0 else: character.xp1 += 10 print("You gained 10 XP.") if character.xp1 >= character.xp2: level(character) loot2(character, en1) elif en1.name in ["Scorpion", "Lizard", "Snake", "Sand Crab"]: if character.level == 10: character.xp1 += 0 else: character.xp1 += 20 print("You gained 20 XP.") if character.xp1 >= character.xp2: level(character) loot3(character, en1) elif en1.name in ["Dragon", "Demon"]: if character.level == 10: character.xp1 += 0 else: character.xp1 += 30 print("You gained 30 XP.") if character.xp1 >= character.xp2: level(character) loot4(character, en1) elif en1.name in ["Alien"]: if character.level == 10: character.xp1 += 0 else: character.xp1 += 50 print("You gained 50 XP.") if character.xp1 >= character.xp2: level(character) alien_loot(character, en1) elif en1.name in ["Baron of Hell"]: if character.level == 10: character.xp1 += 0 else: character.xp1 += 50 print("You gained 50 XP.") if character.xp1 >= character.xp2: level(character) baron_loot(character, en1) quest_tracker(character, en1) game_menu(character, en1)
def examine(character, en1): from data.menu import game_menu if character.location == "b6": if character.b6_event_1: print("You see something shiny behind a tree.") input(">...") character.gold += 20 character.b6_event_1 = False print("You gain 20 gold.") input(">...") elif not character.b6_event_1: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") elif character.location == 'c2': print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") shop(character, en1) elif character.location in [ "d2", "d4", "f6", "g6", "k6", "n7", "o7", "q10" ]: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") elif character.location == 'd1': print(Map.zone_map[character.location][Map.EXAMINE]) print("Do you want to rest? Y/N") choice = input("> ") if choice.lower() == "y": print("You sleep to regain your strength.") print("Your health has been restored to full.") character.hp = character.max_hp input(">...") elif character.location == 'd3': if character.d3_event_1: print("Do you want to talk to the man sitting in the grass? Y/N") choice = input("> ") if choice.lower() == "y": print( "You walk up to the man, and he begins to spew unintelligible words from his mouth. You don't\n" "quite understand what he's saying but nod along anyway. Once he stops talking there's a bit of an\n" "awkward pause as you don't really know what to say, but after a moment he hands you a note that reads..." ) input(">...") print('''"KILL 5 BEARS".''') input(">...") print("Do you wish to take quest to kill 5 bears? Y/N") choice = input("> ") if choice.lower() == "y": print( "You give the strange man a thumbs up and a forced smile as you walk away with the note in\n" "your hand.\n") print("QUEST ACCEPTED: Generic RPG Kill Quest") input(">...") character.active_quests.append({ "name": Quest_0.slay_monsters, "test": 0 }) character.d3_event_1 = False character.d3_event_2 = True elif choice.lower() == "n": print( "You decide not to take the quest to kill the innocent bears, probably for the best as it doesn't\n" "look like this man would give you a quest reward anyway. " ) input(">...") else: print("Not a valid input, enter Y or N.") elif choice.lower() == "n": print( "You speedily walk past the man in the grass as he begins shouting at you, but you don't understand\n" "what he's saying. Probably for the best you avoided him.") input(">...") else: print("Not a valid input, enter Y or N.") elif character.d3_event_2: for quest in character.active_quests: if "Generic RPG Kill Quest" in quest["name"].name: if quest["test"] <= 4: print( "No reason to talk to the strange man again until you've completed the quest." ) input(">...") elif quest["test"] == 5: print( "You walk up to the man, then as you greet him you pass back the note, covered in bear blood,\n" "and let him know that you've killed the 5 bears as requested." ) input(">...") print( "The man takes your note, glances at it for a moment, then stands up from the grass and begins to\n" "shout at you. Unable to understand what he's saying you just ask for your reward but before you get\n" "a chance to finish he pushes into you, knocking you down to the ground and as you fall some gold\n" "drops out of your pocket which he takes and runs into the forest." ) input(">...") print( "You lose gold but gain valuable life experience.") input(">...") print("You gain 60 XP.") if character.gold >= 10: print("You lose 10 gold.") else: print("You lose all your gold.") input(">...") character.xp1 += 60 character.gold -= 10 if character.gold <= 0: character.gold = 0 # character.active_quests.remove({"name": Quest_0.slay_monsters, "test": 5}) - FIX? for i in range(len(character.active_quests)): if character.active_quests[i]["test"] == 5: del character.active_quests[i] break character.completed_quests.append( {"name": Quest_0.slay_monsters}) character.d3_event_2 = False character.d3_event_3 = True character.d5_event_1 = True character.d5_event_2 = True if character.xp1 >= character.xp2: level(character) input(">...") elif character.d3_event_3: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") elif character.location == "d5": if character.d5_event_2: print( "Do you wish to confront the strange man about your stolen gold? Y/N" ) player_input = input("> ") if player_input.lower() == "y": print( "You walk up to the strange man, but he looks angry, seems like the only way to get your gold\n" "back is to fight him.") input(">...") enemy_gen(character) elif player_input.lower() == "n": print( "You decide to leave the strange man alone as it's not worth the effort to get your gold back." ) else: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") elif character.location == 'e2': print(Map.zone_map[character.location][Map.EXAMINE]) if character.e2_event_1: print( "Everyone is gathered around a poster on the wall, do you want to get a closer look? Y/N" ) option = input("> ") if option.lower() == "n": print( "You decide that you're not interested in the poster at the moment." ) input(">...") elif option.lower() == "y": print( "To the annoyance of others, you push through to see what everyone's looking at. As you quickly\n" "glance at the poster you soon see what all the fuss is about." ) input(">...") os.system('cls') wanted_poster() print( "Do you wish to take on this quest to kill the Baron of Hell and save the Hyfield Village from\n" "utter doom? Y/N") option = input("> ") if option.lower() == "n": print( "This might a dream, with no real consequences, but you've decided you're not prepared for\n" "this quest.") input(">...") elif option.lower() == "y": print( "Without hesitation or concern for your own life, you accept the quest.\n" ) print("QUEST ACCEPTED: WANTED: Baron of Hell") character.active_quests.append({ "name": Quest_0.baron_of_hell, "test": 0 }) character.e2_event_1 = False character.e2_event_2 = True input(">...") else: print("Not a valid input, enter Y or N.") elif character.e2_event_2: for quest in character.active_quests: if "WANTED: Baron of Hell" in quest["name"].name: if quest["test"] <= 0: print( "You should return here once you have completed your quest to slay the Baron of Hell." ) input(">...") elif quest["test"] == 1: print( "You walk up to the head desk in the Town Hall and slam a bloody bag with the Baron of Hell's head\n" "inside.") input(">...") print( "The Quest Masters looks as you in shock, he can't quite believe that you managed to kill the\n" "Baron of Hell. He walks over to his chest, unlocks it, and takes out\nthe " + Colours.BOLD + Colours.ORANGE + "[Teleportation Stone]" + Colours.END + " and a bag of gold.") input(">...") print( "The quest master congratulates you, and hands you your rewards." ) input(">...") print("You gain 500 gold.") print("You gain 200 XP.") print("You obtain " + Colours.BOLD + Colours.ORANGE + "[Teleportation Stone]" + Colours.END + ".") input(">...") character.misc_items.clear() item = { Colours.BOLD + Colours.ORANGE + "[Teleportation Stone]" + Colours.END: 0 } character.misc_items.update(item) character.gold += 500 character.e2_event_2 = False character.e2_event_3 = True for i in range(len(character.active_quests)): if character.active_quests[i]["test"] == 1: del character.active_quests[i] break character.completed_quests.append( {"name": Quest_0.baron_of_hell}) character.xp1 += 200 if character.xp1 >= character.xp2: level(character) input(">...") elif character.e2_event_3: print( "Nothing left for you to do now, the Baron of Hell will no longer trouble the people of Hyfield\n" "Village thanks to you.") input(">...") elif character.location == "f5": if character.f5_event_1: print( "You see a bag next to a bush, do you want to take what's inside? Y/N" ) choice = input("> ") if choice.lower() == "y": print( "You walk up to the bag and grab it, but as you do a plank of wood falls from the tree.\n" "Looks like it was booby-trapped.") character.f5_event_1 = False input(">...") print("You lose HP but at least you found x 2 " + Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END + ".") d = dict((i['name'], i["quantity"]) for i in character.items) if Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END in d: for i in character.items: if i["name"] == Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END: i["quantity"] += 2 else: character.items.append({ 'name': Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END, 'property': 150, 'des': "+ 150 HP ", 'quantity': 2 }) print("+ 2 " + Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END + ".") input(">...") character.hp -= 50 if character.base_hp <= 0: end_fight_lose(character, en1) elif choice.lower() == "n": print( "You leave the bag where it is, probably for the best as it might've been booby-trapped." ) input(">...") else: print("Not a valid input, enter Y or N.") else: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") elif character.location == 'i6': if character.i6_event_1: print( "You see something shiny at the bottom of the river and swim down to pick it up." ) input(">...") character.gold += 30 print("You gain 30 gold.") input(">...") character.i6_event_1 = False elif not character.b6_event_1: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") elif character.location == 'l5': if character.l5_event_1: character.l5_event_1 = False print("You've found something in the sand.") input(">...") d = dict((i['name'], i["quantity"]) for i in character.items) if Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END in d: for i in character.items: if i["name"] == Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END: i["quantity"] += 5 else: character.items.append({ 'name': Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END, 'property': 150, 'des': "+ 150 HP ", 'quantity': 1 }) print("+ 5 " + Colours.BOLD + Colours.BLUE + "[Health Potion]" + Colours.END + ".") input(">...") game_menu(character, en1) else: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") encounter = random.randint(1, 10) if encounter in range(1, 10): enemy_gen(character) else: game_menu(character, en1) elif character.location == 'n6': if character.n6_event_2: character.n6_event_2 = False print( "You open the creaky front door of the cabin, explore inside and find a note on the table which reads..." ) input(">...") print( '''"Good luck hero, there are supplies are under the table."''' ) input(">...") print( "You look under the table and find a bag full of supplies, this should come in handy." ) d = dict((i['name'], i["quantity"]) for i in character.items) if Colours.BOLD + Colours.PURPLE + "[Max Health Potion]" + Colours.END in d: for i in character.items: if i["name"] == Colours.BOLD + Colours.PURPLE + "[Max Health Potion]" + Colours.END: i["quantity"] += 2 else: character.items.append({ 'name': Colours.BOLD + Colours.PURPLE + "[Max Health Potion]" + Colours.END, 'property': 100000, 'des': "+ MAX HP ", 'quantity': 2 }) print("+ 2 " + Colours.BOLD + Colours.PURPLE + "[Max Health Potion]" + Colours.END) input(">...") else: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") encounter = random.randint(1, 10) if encounter in range(1, 10): enemy_gen(character) else: game_menu(character, en1) elif character.location in [ "c7", "c5", "c6", "d6", "d7", "d8", "e5", "e6", "e7", "f5", "h6", "j6", "k5", "k7", "l6", "m6", "m7", "o8", "o9", "o10", "p10" ]: print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") encounter = random.randint(1, 10) if encounter in range(1, 10): enemy_gen(character) else: game_menu(character, en1) elif character.location == 'r10': print(Map.zone_map[character.location][Map.EXAMINE]) input(">...") enemy_gen(character) game_menu(character, en1)
def intro(en1): winsound.PlaySound("music\\story_intro.wav", winsound.SND_ASYNC + winsound.SND_LOOP) os.system("cls") print(cut_scene_art.sleeping) typewriter( "It's 3am, the night is young, you're up late again playing your favourite RPG game - Skyrim.\n" "You drift off to sleep in front of your computer, dreaming of what it would be like to live in\n" "a world just like that, where you can fight Mudcrabs and shout at Dragons.\n" ) input(">...") os.system("cls") print(cut_scene_art.bedroom) typewriter( "The next morning you wake from your chair but nothing in your room is the same, your computer is gone,\n" "along with all of your other possessions.\n") input(">...") os.system("cls") print(cut_scene_art.bedroom) typewriter("Suddenly you hear a voice coming from behind you.\n") input(">...") os.system("cls") print(cut_scene_art.bedroom) typewriter('''“Hey, you. You're finally awake.”\n''') input(">...") os.system("cls") print(cut_scene_art.bedroom) typewriter( "You quickly spin around, but there's nobody there. It must have just been your imagination.\n" ) input(">...") os.system("cls") print(cut_scene_art.village) typewriter( "You walk over to your window to check what's outside, and you see this beautiful village,\n" "just like the one you dreamed of.\n") input(">...") os.system("cls") print(cut_scene_art.village) typewriter( "Then it hits you, suddenly you realise you are in the village you dreamed of, whether it's still a dream\n" "or not you are unsure of, but one thing is for certain, you have decided that you are going to be the hero\n" "that this village may, or may not need!\n") input(">...") os.system("cls") print(cut_scene_art.village) typewriter( "Though you think to yourself, if you're going to be a hero, you will need a name worthy to be one that\n" "people can write stories about and sing songs in your name.\n") input(">...\n") player_name = input("Enter Name: ") typewriter("\nGood! " + player_name + " is a great name.\n") input(">...\n") typewriter( "So, " + player_name + ", it's now time to venture outside and conquer whatever challenges you\n" "may face in your adventures.\n") # hp 250, atk 15, defence, name, atk_l, atk_h, b_atk_p, m_atk_p, bleed_dot_count, bleed_dot_dmg, burn_dot_count, burn_dot_dmg, gold, level, xp1, xp2, str character = Player(250, 15, 0, player_name, -5, +5, 0, 100, 0, 0, 0, 0, 0, Attributes.char["xp"], Attributes.char["level_up"], Attributes.char["level"], Attributes.stats["str"]) input(">...") game_menu(character, en1)