import time import random print(' __ __ _ _ _____ _ ') print(' \ \ / /___ | | __ ___ ___ ___ | |_ ___ |_ _|| |_ ___ ') print(' \ \/\/ // -_)| |/ _|/ _ \| \ / -_) | _|/ _ \ | | | \ / -_)') print(' \_/\_/ \___||_|\__|\___/|_|_|_|\___| \__|\___/ |_| |_||_| \___|') print('') print('████████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗') print('╚══██╔══╝██╔═══██╗████╗ ████║██╔══██╗ ██╔═══██╗██╔════╝ ██║ ██║██╔═══██╗██╔══██╗██╔══██╗██╔═══██╗██╔══██╗') print(' ██║ ██║ ██║██╔████╔██║██████╔╝ ██║ ██║█████╗ ███████║██║ ██║██████╔╝██████╔╝██║ ██║██████╔╝') print(' ██║ ██║ ██║██║╚██╔╝██║██╔══██╗ ██║ ██║██╔══╝ ██╔══██║██║ ██║██╔══██╗██╔══██╗██║ ██║██╔══██╗') print(' ██║ ╚██████╔╝██║ ╚═╝ ██║██████╔╝ ╚██████╔╝██║ ██║ ██║╚██████╔╝██║ ██║██║ ██║╚██████╔╝██║ ██║') print(' ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝') floor1 = ['nothing', 'sword', 'monster', 'stones', 'upstairs'] floor2 = ['upstairs', 'sword', 'monster', 'sword', 'downstairs'] floor3 = ['downstairs', 'monster', 'stones', 'sword', 'boss'] monstersdead = ['no', 'no', 'no'] print('welcome to the tomb of horror') global room global floor global inventory global action1 room = 4 inventory = ['sword','stones'] floor = 3 action1 = 'nothing' print('You Are in the starting room type help for all of their commands and uses or if you already know the commands use them.') action1 = input('What is your next command') def go(): global floor, room, action1 if action1.lower() == 'help': print('You type right to go right, left to go left, up to go upstairs if availiable, down to go down stairs if available, grab if there is an item on the floor help to list commands') action1 = input('What is your next Command') go() elif action1 == 'left' and room == 1: print('there is nothing that direction') action1 = input('What is your next command') go() elif action1 == 'left' and room != 1: print('On to the left room!') room = room - 1 if floor == 1: if floor1[room - 1] == 'nothing': nothing() elif floor1[room - 1] == 'monster': monster() elif floor1[room - 1] == 'stones': magicstones() elif floor1[room - 1] == 'sword': sword() elif floor1[room - 1] == 'upstairs': upstairs() elif floor1[room - 1] == 'downstairs': downstairs() if floor == 2: if floor2[room - 1] == 'nothing': nothing() elif floor2[room - 1] == 'monster': monster() elif floor2[room - 1] == 'stones': magicstones() elif floor2[room - 1] == 'sword': sword() elif floor2[room - 1] == 'upstairs': upstairs() elif floor2[room - 1] == 'downstairs': downstairs() if floor == 3: if floor3[room - 1] == 'nothing': nothing() elif floor3[room - 1] == 'monster': monster() elif floor3[room - 1] == 'stones': magicstones() elif floor3[room - 1] == 'sword': sword() elif floor3[room - 1] == 'boss': boss() elif floor3[room - 1] == 'downstairs': downstairs() elif action1 == 'right' and room == 5: print('there is no room that direction') action1 = input('What is your next command') go() elif action1 == 'right' and room != 5: print('On to the right room!') room = room + 1 if floor == 1: if floor1[room - 1] == 'nothing': nothing() elif floor1[room - 1] == 'monster': monster() elif floor1[room - 1] == 'stones': magicstones() elif floor1[room - 1] == 'sword': sword() elif floor1[room - 1] == 'upstairs': upstairs() elif floor1[room - 1] == 'downstairs': downstairs() if floor == 2: if floor2[room - 1] == 'nothing': nothing() elif floor2[room - 1] == 'monster': monster() elif floor2[room - 1] == 'stones': magicstones() elif floor2[room - 1] == 'sword': sword() elif floor2[room - 1] == 'upstairs': upstairs() elif floor2[room - 1] == 'downstairs': downstairs() if floor == 3: if floor3[room - 1] == 'nothing': nothing() elif floor3[room - 1] == 'monster': monster() elif floor3[room - 1] == 'stones': magicstones() elif floor3[room - 1] == 'sword': sword() elif floor3[room - 1] == 'boss': boss() elif floor3[room - 1] == 'downstairs': downstairs() elif action1 == 'inv': print(inventory) action1 = input('What is your next command') go() elif action1 == 'floorlayout' and floor == 1: print(floor1) action1 = input('What is your next command') go() elif action1 == 'floorlayout' and floor == 2: print(floor2) action1 = input('What is your next command') go() elif action1 == 'floorlayout' and floor == 3: print(floor3) action1 = input('What is your next command') go() else: print('That is an invalid command') action1 = input('What is your next command') go() #To end game def end(): print('Thank you for playing!') # if sword found def sword(): global action1 action = input('You found a Sword laying on the ground to pick up the sword type grab \n if you cant just continue with "right" or "left" then your next command') if action == 'grab' and len(inventory) < 3: print('You Picked up the sword') inventory.append('sword') if floor == 1: floor1.pop(room - 1) floor1.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif floor == 2: floor2.pop(room - 1) floor2.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif floor == 3: floor3.pop(room - 1) floor3.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif action == 'grab' and len(inventory) == 3: print('Your inventory is full sorry') action1 = input('What is your next command') go() elif action == 'left' or action == 'right' or action == 'inv' or action == 'floorlayout': action1 = action go() else: print('That is an invalid action ') sword() # if monster room def monster(): global action1 action = input( 'You find a monster in this room you can try running to the next room with continue, fight with fight or run back with run') if action == 'fight' and 'sword' in inventory: print('You defeated the monster consuming your sword.') inventory.remove('sword') if floor == 1: floor1.pop(room - 1) floor1.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif floor == 2: floor2.pop(room - 1) floor2.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif floor == 3: floor3.pop(room - 1) floor3.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif action == 'fight' and 'sword' not in inventory: print('You fought hard but the monster killed you.') time.sleep(2) print('▓██ ██▓ ▒█████ █ ██ ██▓ ██▒ █████ ██████ ▄██▄████▓') print(' ▒██ ██▒▒██▒ ██▒ ██ ▓██▒ ▓██▒ ▒██▒ ██▒▒██ ▒ ▓ ██▒ ▓▒') print(' ▒██ ██░▒██░ ██▒▓██ ▒██░ ▒██░ ▒██░ ██▒░ ▓██▄ ▒ ▓██░ ▒░') print(' ░ ▐██▓░▒██ ██░▓▓█ ░██░ ▒██░ ▒██ ██░ ▒ ██▒░ ▓██▓ ░ ') print(' ░ ██▒▓░░ ████▓▒░▒▒█████▓ ░ ██████▒░████▓▒░▒██████▒▒ ▒██▒ ░') print(' ██▒▒▒ ░ ▒░▒░▒░ ░▒▓▒ ▒ ▒ ░ ▒░▓ ░░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░ ▒ ░░ ') print(' ▓██ ░▒░ ░ ▒ ▒░ ░░▒░ ░ ░ ░ ░ ▒ ░ ░ ▒ ▒░ ░ ░▒ ░ ░ ░ ') print(' ▒ ▒ ░░ ░ ░ ░ ▒ ░░░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ') print(' ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ') time.sleep(3) end() elif action == 'continue': print('You were killed by the monster trying to run past it Game Over') elif action == 'run': action1 = 'left' go() else: print('That is an invalid action') monster() # If Stones room def magicstones(): global action1 action = input( 'You found some magic stones laying on the ground to pick up the magic stones type grab \n if you cant just continue with right or left') if action == 'grab' and len(inventory) < 3: print('You Picked up the magic stones') inventory.append('stones') if floor == 1: floor1.pop(room - 1) floor1.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif floor == 2: floor2.pop(room - 1) floor2.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif floor == 3: floor3.pop(room - 1) floor3.insert(room - 1, 'nothing') action1 = input('What is your next command') go() elif action == 'grab' and len(inventory) == 3: print('Your inventory is full, sorry') action1 = input('What is your next command') go() elif action == 'left' or action == 'right' or action == 'inv' or action == 'floorlayout': action1 = action go() else: print('That is an invalid command') magicstones() # If Nothing in Room def nothing(): global action1 print('There is nothing in this room') action1 = input('What is your next Command') go() # If Stairs going up def upstairs(): global floor, action1, room action = input('You see stairs going up to the next floor type up to go up or go back the way you came') if action == 'up' and floor != 2: print('You went up to the next floor') floor = floor + 1 room = 5 downstairs() if action == 'up' and floor == 2: print('You went up to the next floor') floor = floor + 1 room = 1 downstairs() elif action == 'left' or action == 'right' or action == 'inv' or action == 'floorlayout': action1 = action go() else: print('That is an invalid command') upstairs() # If Stairs going down def downstairs(): global floor, action1, room action = input('You see stairs going dow to the lower floor type down to go down them or continue on your journey') if action == 'down': floor = floor - 1 room = 5 print('you went down a floor') upstairs() elif action == 'left' or action == 'right' or action == 'inv' or action == 'floorlayout': action1 = action go() else: print('That is an invalid command') upstairs() # If boss room def boss(): print( "As you enter the room you see a gigantic monster made of at least 50 corpses You realise you need Magic Stones and a Sword to fight it and have a chance to win") time.sleep(2) action = input('Do you wish to fight the corpse demon or run and collect supplies') if action == 'fight' and 'sword' in inventory and 'stones' in inventory: print('Fighting...') time.sleep(random.randint(1,10)) print('It was a close fight but you beat the Corpse Demon and collected the Soul of 1000 Corpse.') time.sleep(4) print(' _______ _______ _ ') print('|\ /|( ___ )|\ /| |\ /|( ___ )( ( /|') print('( \ / )| ( ) || ) ( | | ) ( || ( ) || \ ( |') print(' \ (_) / | | | || | | | | | _ | || | | || \ | |') print(' \ / | | | || | | | | |( )| || | | || (\ \) |') print(' ) ( | | | || | | | | || || || | | || | \ |') print(' | | | (___) || (___) | | () () || (___) || ) \ |') print(' \_/ (_______)(_______) (_______)(_______)|/ )_)') time.sleep(3) end() elif action == 'fight' and 'sword' not in inventory or 'stones' not in inventory: print('Fighting...') time.sleep(random.randint(1,10)) print('You Tried your Hardest but the Corpse Demon Was just too strong you died') time.sleep(2) print('▓██ ██▓ ▒█████ █ ██ ██▓ ██▒ █████ ██████ ▄██▄████▓') print(' ▒██ ██▒▒██▒ ██▒ ██ ▓██▒ ▓██▒ ▒██▒ ██▒▒██ ▒ ▓ ██▒ ▓▒') print(' ▒██ ██░▒██░ ██▒▓██ ▒██░ ▒██░ ▒██░ ██▒░ ▓██▄ ▒ ▓██░ ▒░') print(' ░ ▐██▓░▒██ ██░▓▓█ ░██░ ▒██░ ▒██ ██░ ▒ ██▒░ ▓██▓ ░ ') print(' ░ ██▒▓░░ ████▓▒░▒▒█████▓ ░ ██████▒░████▓▒░▒██████▒▒ ▒██▒ ░') print(' ██▒▒▒ ░ ▒░▒░▒░ ░▒▓▒ ▒ ▒ ░ ▒░▓ ░░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░ ▒ ░░ ') print(' ▓██ ░▒░ ░ ▒ ▒░ ░░▒░ ░ ░ ░ ░ ▒ ░ ░ ▒ ▒░ ░ ░▒ ░ ░ ░ ') print(' ▒ ▒ ░░ ░ ░ ░ ▒ ░░░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ') print(' ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ') time.sleep(3) end() go()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question