#!/usr/bin/python from sys import exit # used at the end of almost every def string not_recognized = "> \n > \n > \n That input was not recognized. Try again. \n > \n > \n >" #raw input def to be used in all def's #def start_choice(): # result = raw_input("> To start game type \'start\'") # start_game_text = "> To start game type \'start\'" # return result #result = start_choice() #def choice(): # result = raw_input("> ") # return result #result = choice() # Game start def game_start(): print "You are on the ship \'The Fall of Troy\'" print "You do not ride above or beneath the law, you just take jobs that pay." print "While waiting for a job that does pay you have decided to explore your current star system." print "You can go to \'Delva\' or \'warp out of system\'" print "*** Note to the player, choices are in single quotation marks. ***" choice = raw_input("> ") if choice == "Delva": delva_start() elif choice == "warp out of system": start_warp_out() else: print not_recognized game_start() #Delva start def delva_start(): print "There is a large \'mountain\' or a \'cave\' that you can go to. You can also \'go back to ship\'" choice = raw_input("> ") if choice == "mountain": delva_mountain_start() elif choice == "cave": delva_cave() elif choice == "go back to ship": game_start() else: print not_recognized delva_start() #Delva Cave def delva_cave(): print "Inside the cave you can either go \'left\' or \'right\' or you can go \'back\'" choice = raw_input("> ") if choice == "left": delva_cave_left() elif choice == "right": delva_cave_right() elif choice == "back": delva_start() else: print not_recognized delva_cave() #Delva Cave Left def delva_cave_left(): print "your path is blocked by a cage. You can \'try to open it\' or \'try to melt it with your lazer\' or you can go \'back\'" delva_cave_left = raw_input("> ") if delva_cave_left == "try to open it": delva_cave_left_open() elif delva_cave_left == "try to melt it with your lazer": delva_cave_left_melt() elif delva_cave_left == "back": delva_cave() else: print not_recognized delva_cave_left() def delva_cave_left_open(): print "You try to open the cage, but it will not open. Do you want to \'try to melt it with your lazer\' or go \'back\'?" delva_cave_left_open = raw_input("> ") if delva_cave_left_open == "try to melt it with your lazer": delva_cave_left_melt() elif delva_cave_left_open == "back": delva_cave_left() else: print not_recognized delva_cave_left_open() def delva_cave_left_melt(): print "you try to melt the gate with your lazer." print "..." print "It works. You can now \'walk through the gate\' or go \'back.\'" delva_cave_left_melt = raw_input("> ") if delva_cave_left_melt == "walk through the gate": delva_cave_left_melt_through() elif delva_cave_left_melt == "back": delva_cave_left() else: print not_recognized delva_cave_left_melt() # Delva cave right def delva_cave_right(): print "You come to a massive cassim. There is a rotten \'bridge\' and a long \'vine\', do you take the bridge, vine or go \'back\'." delva_cave_right = raw_input("> ") if delva_cave_right == "bridge": delva_cave_right_bridge() elif delva_cave_right == "vine": delva_cave_right_vine() elif delva_cave_right == "back": delva_cave() else: print not_recognized delva_cave_right() def delva_cave_right_bridge(): print "You try to take the bridge. Halfway through a beam breaks and you slip." print "You barley regain your grip. Do you \'continue\' or go \'back\'?" delva_cave_right_bridge = raw_input("> ") if delva_cave_right_bridge == "continue": delva_cave_right_bridge_continue() elif delva_cave_right_bridge == "back": delva_cave_right_bridge_back() else: print not_recognized delva_cave_right_bridge() def delva_cave_right_bridge_continue(): print "You try to continue on the bridge. Near the very end another beam breaks." print "This time you are not able to save yourself and you fall." dead() def delva_cave_right_bridge_back(): print "You carfuly walk back to the start of the bridge. Do you want to \'try the bridge\' again," print "try the \'vine\' or go \'back\'?" delva_cave_right_bridge_back = raw_input("> ") if delva_cave_right_bridge_back == "try the bridge": delva_cave_right_bridge_continue() elif delva_cave_right_bridge_back == "vine": delva_cave_right_vine() elif delva_cave_right_bridge_back == "back": delva_cave_right() else: print not_recognized delva_cave_right_bridge_back() def delva_cave_right_vine(): print "You use the vine to swing across the cassim." print "On the other side. There is a mechanical item that looks valuable. You cannot swing across with it." print "Do you \'take it\' with you or \'leave it\'?" delva_cave_right_vine = raw_input("> ") if delva_cave_right_vine == "take it": delva_cave_right_vine_take() elif delva_cave_right_vine == "leave it": delva_cave_right_vine_leave() else: print not_recognized delva_cave_right_vine() def delva_cave_right_vine_take(): print "You try to take the item with you. It weighs you down as you cross the bridge and you fall." dead() def delva_cave_right_vine_leave(): print "You decide that you do you want to risk carrying the item across the bridge." print "That is a good choice, becuase as you cross the bridge falls apart. You barley make it." print "Do you want to explore the \'left\' side of the cave, the \'mountain\' or go back to the \'ship\'?" delva_cave_right_vine_leave = raw_input("> ") if delva_cave_right_vine_leave == "left": delva_cave_left() elif delva_cave_right_vine_leave == "mountain": delva_mountain_start() elif delva_cave_right_vine_leave == "ship": game_start() else: print not_recognized delva_cave_right_vine_leave() # Delva mountain start def delva_mountain_start(): print "You land near the base of the mountain since there is no easy way to land near the top." print "It looks like some weather is coming in. Do you want to \'wait\', \'climb\' the mountain now or go \'back\'?" choice() if result == "wait": delva_mountain_start_wait() elif result == "climb": delva_mountain_start_climb_now() elif result == "back": delva_start() else: print not_recognized delva_mountain_start() def delva_mountain_start_wait(): print "you decide to wait for the weather to clear up. It takes nearly a full day for that to happen. Do you want to \'climb\' now or go \'back\'?" delva_mountain_start_wait = raw_input("> ") if delva_mountain_start_wait == "climb": delva_mountain_start_climb() elif delva_mountain_start_wait == "back": delva_start() else: print not_recognized delva_mountain_start_wait() def delva_mountain_start_climb(): print "The rocks are still slick from the rain. It is difficult for you to climb, but you are able to make it to the top." print "You do not find anything valuable, but the view is breathtaking. Do you wan to explore the \'cave\' or go back to your \'ship\'?" delva_mountain_start_climb = raw_input("> ") if delva_mountain_start_climb == "cave": delva_cave() elif delva_mountain_start_climb == "ship": ship_after_delva() else: print not_recognized delva_mountain_start_climb() def delva_mountain_start_climb_now(): print "You climb the mountain now. The weather holds out untill you are near the top. Suddenly there is a huge downpour." print "Lightning flashes around you. You are trying to decide if you should try and climb back down when you slip." dead() # N7X4 def n7x4(): print "You can go to the \'surface\' of N-7X4, warp to \'Ceti-Vara\' or go back to \'Delva\'." choice() if result == "surface": n7x4_surface() elif result == "Ceti-Vara": cetivara() elif result == "Delva": delva_start() else: print not_recognized n7x4() def n7x4_surface(): print "The surface is very desolate. There is not much to see, but your scans find one anomaly do you \'investigate\' or go \'back\'." choice() if result == "investigate": n7x4_surface_investigate() elif result == "back": n7x4() else: print not_recognized n7x4_surface def n7x4_surface_investigate(): print "You find some minerals of limited value." print "You go back to your ship." print " " print " " n7x4() # ceti-vara def cetivara(): print "You can go to the \'surface\' or go \'back\'." choice() if result == "surface": cetivara_surface() elif result == "back": n7x4() else: print not_recognized cetivara() def cetivara_surface(): print "There are two anomalies. Do you go to the \'1st\' the \'2nd\' or do you go \'back\'?" choice = raw_input("> ") if choice == "1st": cetivara_surface_1st() elif choice == "2nd": cetivara_surface_2nd() elif choice == "back": else: print not_recognized cetivara_surface() # 1st anomoly def cetivara_surface_1st(): print "You go to the 1st anomoly. It is a crashed ship. It looks like it has been there for a few years" print "Do you want to search for \'supplies\' or go \'back\'" choice = raw_input("> ") if choice == "supplies": cetivara_surface_1st_supplies() elif choice == "back": cetivara_surface() else: print not_recognized cetivara_surface_1st() def cetivara_surface_1st_supplies(): print "You search for supplies and fine a few things worth keeping. While in a cooridore you hear a noise behind you." print "You are pretty sure something is behind you. Do you reach for your \'gun\' or raise your \'hands\'?" choice raw_input("> ") if choice == "gun": cetivara_surface_1st_supplies_gun() elif choice == "hands": cetivara_surface_1st_supplies_hands() else: print not_recognized cetivara_surface_1st_supplies() def cetivara_surface_1st_supplies_gun(): print "You reach for your gun. As you turn around you are shot through the heart." dead() def cetivara_surface_1st_supplies_hands(): print "You raise your hands slowley. A voice behind you says \"What are you doing here?\"" print "Do you say you are there to \'help\' or \'scavange\'?" choice = raw_input("> ") if choice == "help": cetivara_surface_1st_supplies_hands_help() elif choice == "scavange": cetivara_surface_1st_supplies_hands_scavange() else: print not_recognized cetivara_surface_1st_supplies_hands() def cetivara_surface_1st_supplies_hands_help(): print "You tell the man that you are there to help. he looks at you suspissiously. \"I don't like liars\" he says as he shoots you." dead() def cetivara_surface_1st_supplies_hands_scavange(): print "You tell the person that you are there to scavange. He looks at you suspissiously. You see a momentary laps in his concentration." print "Do you \'wait\' or try to \'overpower\' him?" choice = raw_input("> ") if choice == "wait": cetivara_surface_1st_supplies_hands_scavange_wait() elif choice == "overpower": cetivara_surface_1st_supplies_hands_scavange_overpower() else: print not_recognized cetivara_surface_1st_supplies_hands_scavange() def cetivara_surface_1st_supplies_hands_scavange_wait(): print "You decide to wait. It takes the man a short time to make his mind up, and he shoots you." dead() def cetivara_surface_1st_supplies_hands_scavange_overpower(): print "In the moment where he is not paying attention, you attack him and try to over power him. The gun goes off," print "and it barley misses you. You quickly pull out your own weapon and shoot the man. He stops struggeling" print "as he slumps to the floor, dead. Do you want to go back to your \'ship\' or to \'2nd\' anomaly?" choice = raw_input("> ") if choice == "ship": cetivara() elif choice == "2nd" cetivara_surface_2nd(): else: print not_recognized cetivara_surface_1st_supplies_hands_scavange_overpower() def cetivara_surface_2nd(): print "You go to the 2nd anomaly. It is a patch of ground that does not appear to be special. Do you \'scan\' it, get a \'closer\' look or go \'back\'" choise = raw_input("> ") if choice == "scan": cetivara_surface_2nd_scan() elif choice == "closer": cetivara_surface_2nd_closer() elif choice == "back" def cetivara_surface_2nd_scan(): print "You scan the surface and find minierals. Do you want to \'mine\' them or go \'back\'?" choice = raw_input("> ") if choice == "mine": cetivara_surface_2nd_scan_mine() elif choice == "back": cetivara_surface_2nd() else: print not_recognized cetivara_surface_2nd_scan() def cetivara_surface_2nd_scan_mine(): print "you mine the minierals and take them back to your ship." print "you deliver them to your supplier. He pays you well enough and offers you a job. Do you take the \'job\' or \'continue\' exploring?" choice = raw_input("> ") if choice == "job": cetivara_ending_choice() elif choice == "continue": n7x4() else: print not_recognized cetivara_surface_2nd_scan_mine() def cetivara_ending_choice(): print "You take the job, which is the end of this game. Do you want to \'end\' or go back to the \'game\'?" choice = raw_input("> ") if choice == "end": end() elif choice == "game": game_start() else: print not_recognized cetivara_ending_choice() # death ending def dead(): print "You died." print " " print "The End." print " " print "do you want to \'try again\' or \'quit\'?" dead = raw_input("> ") if dead == "try again": game_start() elif dead == "quit": exit(0) else: print not_recognized dead() # Game Ending def end(): print "Thank you for playing. You have won, whatever that means:" exit(0) # where the game starts. game_start()
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