7 Replies - 1887 Views - Last Post: 26 June 2014 - 12:51 PM Rate Topic: ***** 1 Votes

#1 project21124  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 40
  • Joined: 02-February 14

Ahhh, procedural programming!

Posted 16 February 2014 - 04:19 PM

I found this old file on my Linux side just now, it's an old RPG game I made in Python, and it's pretty sad.
Think of the hundreds of lines that could have been saved!
:D Enjoy!
import os
import time
def Start(place):
	while place == "start":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You stand inside a creaky, run down house."
		elif user_input == "west":
			print "To your west is a rotting door, tightly shut."
			
		elif user_input == "south":
			print "To your south is what appears to be a living room."
			
		elif user_input == "north":
			print "To your north is the kitchen of the house."
			
		elif user_input == "east":
			print "To your east is just a wall, the far end of the house."
			place = "start"
			Start(place)
		elif user_input == "walk west":
			print "You walk over to a rotting door, tightly shut."
			isKey()
		elif user_input == "walk south":	
			print "You walk over to a living room, and there is what appears to be a key lying on the floor."
			place = "living_room"
			LivingRoom(place)
		elif user_input == "walk east":
			print "You walk over to the wall, and since there is nothing there, you walk back to the where you were."
			place = "start"
			Start(place)
		elif user_input == "walk north":
			print "You walk over to a kitchen."
			place = "kitchen"
			Kitchen(place)
		elif user_input == "help":
			help()
		elif user_input == "inventory" or user_input == "show inventory":
			print inventory
		elif user_input == "cavern":
			place = "cavern"
			inventory.append("sword")
			cavern(place)
		
def Kitchen(place):
	while place == "kitchen":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing in a kitchen."
								
		elif user_input == "west":
				print "To your west is a rotting door, tightly shut."
									
		elif user_input == "south":
			print "To your south is what appears to be a living room."
									
		elif user_input == "north":
			print "To your north is the kitchen of the house."
									
		elif user_input == "east":
			print "To your east is just a wall, the far end of the house."											
		elif user_input == "walk west":
			print "You walk over to a rotting, tightly shut door."
			isKey()
		elif user_input == "walk south":	
			print "You walk over to a living room, and there is what appears to be a key lying on the floor."
			place = "living_room"
			LivingRoom(place)						
		elif user_input == "walk east":
			print "You walk to the wall, and since there is nothing here, you walk back to the kitchen."                       
			place = "kitchen"
			Kitchen(place)
		elif user_input == "walk north":
			print "You are standing in a kitchen."
			place = "kitchen"
			Kitchen(place)
		elif user_input == "help":
			help()
		elif user_input == "inventory" or user_input == "show inventory":
			print inventory

def LivingRoom(place):
	while place == "living_room":
		while not("key") in inventory:
			user_input = raw_input(prompt)
			if user_input == "look":
				print "You are standing in a living room."
							
			elif user_input == "west":
				print "To your west is a rotting, tightly shut door."
								
			elif user_input == "south":
				print "You are standing in a living room."
							
			elif user_input == "north":
				print "To your north is the kitchen of the house."
						
			elif user_input == "east":
				print "To your east is a wall, the far end of the house."
								
			elif  user_input == "walk west":
				print "You walk over to a rotting, tightly shut door."
				isKey()
			elif user_input == "walk south":
				print "You are standing in a living room, and there is what appears to be a key lying on the floor."
				place = "living_room"
				LivingRoom(place)
			elif user_input == "walk east":
				print "You walk over to the wall, and since there is nothing here, you walk back to the living room."
				place = "living_room"
				LivingRoom(place)			
			elif user_input == "walk north":
				print "You walk over to the kitchen of the house."
				place = "kitchen"
				Kitchen(place)
			elif user_input == "help":
				help()
			elif user_input == "take key":
				print "You take the key"
				inventory.append("key")
				
			elif user_input == "inventory" or user_input == "show inventory":
				print inventory
		while "key" in inventory:
			user_input = raw_input(prompt)
			if user_input == "look":
				print "You are standing in a living room."
							
			elif user_input == "west":
				print "To your west is a rotting, tightly shut door."
								
			elif user_input == "south":
				print "You are standing in a living room."
							
			elif user_input == "north":
				print "To your north is the kitchen of the house."
						
			elif user_input == "east":
				print "To your east is a wall, the far end of the house."
								
			elif  user_input == "walk west":
				print "You walk over to a rotting, tightly shut door."
				isKey()
			elif user_input == "walk south":
				print "You are standing in a living room, and there is what appears to be a key lying on the floor."
				place = "living_room"
				LivingRoom(place)
			elif user_input == "walk east":
				print "You walk over to the wall, and since there is nothing here, you walk back to the living room."
				place = "living_room"
				LivingRoom(place)			
			elif user_input == "walk north":
				print "You walk over to the kitchen of the house."
				place = "kitchen"
				Kitchen(place)
			elif user_input == "help":
				help()
			elif user_input == "take key":
				print "What key?"
				
			elif user_input == "inventory" or user_input == "show inventory":
				print inventory


		
def Door(place):
	while place == "starting_door" and not("key") in inventory:
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing inside a run down house, near a tightly shut door."
		elif user_input == "west":
			print "You are standing inside a run down house, near a tightly shut door."	
		elif user_input == "south":
			print "To your south is what appears to be the living room of the house."
					
		elif user_input == "north":
			print "To your north is what appears to be the kitchen of the house."
						
		elif user_input == "east":
			print "To your east is a wall, the far end of the house."
					
		elif user_input == "walk west":
			print "You are standing inside a run down house, near a tightly shut door."
			isKey()
		elif user_input == "walk south":
			print "You walk over to the living room."
			place = "living_room"
			LivingRoom(place)
		elif user_input == "walk east":
			print "You walk over to the wall, and since there is nothing there, you walk back to the door."						
			place = "starting_door"
			Door(place)
		elif user_input == "walk north":
			print "You walk over to a kitchen."
			place = "kitchen"
			Kitchen(place)
		elif user_input == "help":
			help()
		elif user_input == "inventory" or user_input == "show inventory":
			print inventory
def Kitchen(place):
	while place == "kitchen":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing in a kitchen."
								
		elif user_input == "west":
				print "To your west is a rotting door, tightly shut."
									
		elif user_input == "south":
			print "To your south is what appears to be a living room."
									
		elif user_input == "north":
			print "To your north is the kitchen of the house."
									
		elif user_input == "east":
			print "To your east is just a wall, the far end of the house."											
		elif user_input == "walk west":
			print "You walk over to a rotting, tightly shut door."
			isKey()
		elif user_input == "walk south":	
			print "You walk over to a living room, and there is what appears to be a key lying on the floor."
			place = "living_room"
			LivingRoom(place)						
		elif user_input == "walk east":
			print "You walk to the wall, and since there is nothing here, you walk back to the kitchen."                       
			place = "kitchen"
			Kitchen(place)
		elif user_input == "walk north":
			print "You are standing in a kitchen."
			place = "kitchen"
			Kitchen(place)
		elif user_input == "help":
			help()
		elif user_input == "inventory" or user_input == "show inventory":
			print inventory
		
def outside_door(place):
 	global money
	global Weapon
	while place == "outside_door" and "key" in inventory:
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing in the doorway of a house on the edge of a field, surrounded by a thick forest. In the distance you see a white-capped mountain."
		elif user_input == "west":
			print "To your west is a small village, bustling with activity."
		elif user_input == "south":
			print "You are standing in the doorway of a house on the edge of a field, surrounded by a thick forest. In the distance you see a white-capped mountain."
		elif user_input == "north":
			print "To your north is a snow-capped mountain."
		elif user_input == "east":
			print "To your east is a dark, dank, cave. I would recommend that you don't go in there unprepared(yes, I can do that, I AM the voice in your head afterall. ;)/>"
		elif user_input == "walk west":
			print "You start walking into the village."
			place = "village"
			Village(place)
		elif user_input == "walk east":			
			isWeapon()
		elif user_input == "walk south":
			print "You walk back into the house you started in."
			place = "starting_door"
			Door(place)
		elif user_input == "walk north":
			print "You walk to the base of the mountain."
			place = "base_mountain"
			BaseOfMountain(place)
		elif user_input == "inventory" or user_input == "show inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "cc99L":
			money += 99999999
			inventory.append("axe")
			Weapon = True
		
def Village(place):
	while place == "village":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing in a busy village, and there is a blacksmith shop nearby."
		elif user_input == "south":
			print "To your south is the path leading out of the village."
		elif user_input == "east":
			print "To your east is an old man, sitting by a fire."
		elif user_input == "west":
			print "To your west is a blacksmith shop."
		elif user_input == "north":
			print "To your north is the edge of a thick forest."
		elif user_input == "walk south":
			print "You walk out of the village."
			place = "outside_door"
			outside_door(place)
		elif user_input == "walk west":
			print "You walk into the blacksmith shop."
			place = "blacksmith_shop"
			blacksmith_shop(place)
		elif user_input == "walk north":
			print "You walk to the forest, and go back to where you were because there is nothing there."
			Village(place)
		elif user_input == "walk east":
			print "You walk over to the old man."
			place = "old_man"
			OldMan(place)
		elif user_input == "help":
			help()
		elif user_input == "inventory":
			print inventory
		


def blacksmith_shop(place):
	while place == "blacksmith_shop":
		user_input = raw_input(prompt)
		if user_input == "speak" or user_input == "say":
			blacksmith_talk()
		elif user_input == "west" or user_input == "north" or user_input == "east":
			print "A blacksmith shop, with a man sitting in the center."
		elif user_input == "walk west" or user_input == "walk north" or user_input == "walk east":
			print "The only way out is the way you came in, south"
		elif user_input == "south":
			print "The door leading out of the shop, and the only way out."
		elif user_input == "look":
			print "A blacksmith shop, with a man sitting in the center."
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "walk south":
			print "You walk out of the shop."
			place = "village"
			Village(place)
		


def OldMan(place):
	while place == "old_man":
		user_input = raw_input(prompt)
		if user_input == "play":
			print "The old man starts playing a game with you."
			print "So, if you for each question you answer correctly, I will give you 2 money, k?"
			PlayGame()
		elif user_input == "look":
			print "You are standing by a fire, next an old man."
		elif user_input == "west":
			print "To your west is a blacksmith shop."
		elif user_input == "south":
			print "To your south is the path out of the village."
		elif user_input == "east":
			print "You are standing by a fire, next to an old man."
		elif user_input == "north":
			print "To your north is a thick forest."
		elif user_input == "walk west":
			print "You walk over to the blacksmith shop."
			place = "blacksmith_shop"
			blacksmith_shop(place)
		elif user_input == "walk east":
			print "You are standing by a fire, next to an old man."
			OldMan(place)
		elif user_input == "walk south":
			print "You walk out of the village."
			place = "outside_door"
			outside_door(place)
		elif user_input == "walk north":
			print "The forest is too thick, you turn back to the fire."
			OldMan(place)
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		


def blacksmith_talk():
	print "Hello, friend, is there something you need?"
	print "I will tell you all the different items I have."
	print blacksmith
	print "It will cost you 10 coins for the axe, 15 coins for the sword, and 20 coins for the mace.(I'm not giving you my other equipment)"
	hasMoney()
def buyBlack():
	global money
	global Weapon
	user_input = raw_input(prompt)
	if user_input == "take axe" and money >= 10:
		inventory.append("axe")
		Weapon = True
		money -= 10
		print "You take the axe, you now have %s amount of money" % money
	elif user_input == "take sword" and money >= 15:
		inventory.append("sword")
		Weapon = True
		money -= 15
		print "You take the sword, you now have %s amount of money" % money
	elif user_input == "take mace" and money >= 20:
		inventory.append("mace")
		Weapon = True
		money -= 20
		print "You take the mace, you now have %s amount of money" % money
	elif user_input == "take mace" or user_input == "take sword" and money < 15:
		not_enough()
	elif user_input == "take axe" and money < 10:
		not_enough()

def Golhad(place):
	if Weapon == True:
		while place == "Golhad":
			global TakenMap
			global TakenCoins
			global money
			global Golhadf
			while Golhadf == True:
				print 'You walk into the cave, and Golhad starts to attack you. You fight back, and overcome him.'		
				print "On the ground, you see coins, made of gold, and a map lying on the ground."
				Golhadf = False
			while Golhadf == False:
				while place == "Golhad":
					user_input = raw_input(prompt)
					if user_input == "take coins" and TakenCoins == False:
						print "You take the coins."
						money += 50
						TakenCoins = True
					elif user_input == "take map" and TakenMap == False:
						print 'You pick up the map.'
						inventory.append("map")
						TakenMap = True
					elif user_input == "take coins" and TakenCoins == True:	
						print "What? I don't see any money around here."
					elif user_input == "take map" and TakenMap == True:
						print "What map? I don't see a map around here."
					elif user_input == "west" or user_input == "east" or user_input == "north" or user_input == "walk west" or user_input == "walk east" or user_input == "walk north":
						print "You are in a very small cave, and the only way out is the way you came in(south)."	
						Golhad(place)
					elif user_input == "south":
						print "The way out of the cave, to your south."
					elif user_input == "inventory":
						print inventory
					elif user_input == "walk south":
						print "You walk out of the cave."
						place = "outside_door"
						outside_door(place)
					elif user_input == "help":
						help()
					elif user_input == "show map" or user_input == "read map":
						mapTruth()
					elif user_input == "look":
						print "You are standing in a cave."
	elif Weapon == False:
		reason = "Golhad"
		Death(reason)


def BaseOfMountain(place):
	while place == "base_mountain":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing at the base of a huge mountain that is covered in snow."
		elif user_input == "south":
			print "To your south(and UP of course) is a huge mountain, covered in snow."
		elif user_input == "east":
			print "To your east is a village, bustling with people."
		elif user_input == "west":
			print "To your west is a dark, dank, cave, I would recommend that you don't go in there unprepared." 
		elif user_input == "north":
			print "To your north is a small, run-down house."
		elif user_input == "walk west":
			print "You walk to a dark, dank, cave."
			place = "Golhad"
			isWeapon()
		elif user_input == "walk east":
			print "You walk to a village, bustling with people."
			place = "village"
			Village(place)
		elif user_input == "walk south":
			mountain_climb()
		elif user_input == "walk north":
			print "You walk to a small, run-down house."
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "read map" or user_input == "show map":
			mapTruth()
		
def mountain_top(place):
	global HasBeenDried
	while place == "mountain_top":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing on the top of a mountain, probably around 3,000 feet high."
			print "There is a strange feeling in the air, and a shiver runs up your spine."
			print "You see the clouds shifting in the distance, and you see a valley spreading below you for miles and miles."
		elif user_input == "west":
			print "You are standing on the top of a huge mountain, and to your west there is a tree, with a curiously large hole in it."
		elif user_input == "east":
			print "You are standing on the top of a huge mountain, and to your east is a sheer drop-off, at least 3,000 feet down."
		elif user_input == "south":
			print "To your south is a steep, but not impossibly steep pathway."
		elif user_input == "north":
			print "To your north is a steep, but not impossibly steep pathway, leading down to a valley."
		elif user_input == "walk west":
			print "You walk to a tree."
			place = "tree"
			tree(place)
		elif user_input == "walk east":
			print "Oh my, you're sure a smart one..."
			reason = "dropoff"
			Death(reason)
		elif user_input == "walk south":
		 	mountain_descent()
		elif user_input == "walk north":
			mountain_north_descent()
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "read map" or user_input == "show map" or user_input == "map":
			mapTruth()
def BaseOfNorthMountain(place):
	while place == "mountain_base_north":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing at the base of a huge mountain, that is at least 3,000 feet high."
		elif user_input == "west":
			if HasBeenDried == True:
				print "There is a deep hole in the ground to your west, it appears to have been a lake at one time."
			elif HasBeenDried == False:
				print "There is a deep, blue, sparkling lake to your west."
		elif user_input == "east":
			print "You can see armor glinting in the distance."
		elif user_input == "north":
			print "TBD"
		elif user_input == "south":
			print "To your south(and UP of course), is a huge, seemingly impassable mountain."
		elif user_input == "walk west":
			print "You walk to the edge of the lake."
			place = "south_edge_lake"
			south_edge_lake(place)
		elif user_input == "walk east":
			place = "warrior"
			warrior(place)
		elif user_input == "walk north":
			place = "mine_entrance"
			mine_entrance(place)
		elif user_input == "walk south":
			mountain_climb()
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "read map" or user_input == "show map" or user_input == "map":
			mapTruth()



def south_edge_lake(place):
	global HasBeenDried
	while place == "south_edge_lake":
		while HasBeenDried == True:	
			user_input = raw_input(prompt)
			if user_input == "look":
				print "You are standing on the edge of what used to be a lake. It is still damp, so it must have been drained recently."
			elif user_input == "west":
				print "Trees line the former beach to the west."
			elif user_input == "south":
				print "To your south is a huge, seemingly impassable mountain."
			elif user_input == "east":
				print "Trees line the former beach to the east."
			elif user_input == "north":
				print "Directly in front of you(north), is a dried up, but still moist lake."
			elif user_input == "walk west" or user_input == "walk east":
				print "This lake is too large to walk around."
			elif user_input == "walk south":
				print "You walk to the base of the huge mountain."
				place = "mountain_base_north"
				BaseOfNorthMountain(place)
			elif user_input == "walk north":
				walk_north_lake()
			elif user_input == "inventory":
				print inventory
			elif user_input == "help":
				help()
			elif user_input == "show map" or user_input == "read map" or user_input == "map":
				mapTruth()
		
		while HasBeenDried == False:
			user_input = raw_input(prompt)
			if user_input == "look":
				print "You are standing on the edge of a deep, blue, sparkling lake."
			elif user_input == "west":
				print "Trees line the beach to the west."
			elif user_input == "south":
				print "To your south is a huge, seemingly impassable mountain."
			elif user_input == "east":
				print "Trees line the beach to the east."
			elif user_input == "north":
				print "Directly in front of you(north), is a deep, blue, sparkling lake."
			elif user_input == "walk west" or user_input == "walk east":
				print "This lake is too large to walk around."
			elif user_input == "walk south":
				print "You walk to the base of the huge mountain."
				place = "mountain_base_north"
				BaseOfNorthMountain(place)
			elif user_input == "walk north":
				reason = "lake"
				Death(reason)
			elif user_input == "inventory":
				print inventory
			elif user_input == "help":
				help()
			elif user_input == "show map" or user_input == "read map" or user_input == "map":
				mapTruth()
def tree(place):
	global HasBeenDried
	while HasBeenDried == False:
		print "A large stash of gold sits in a large hole in the tree."
		while place == "tree":
			user_input = raw_input(prompt)
			if user_input == "take gold":
				print '''You reach for the gold, grab it, and start to pull it back to you.
Suddenly, it vanishes from your sight, and your grasp. You hear a large, groaning, rusty sound, and the hole suddenly snaps shut, and you pull your hand out quickly.'''
				HasBeenDried = True
				place = "mountain_top"
				mountain_top(place)
			else:
				print "I don't think that applies here." 
	while HasBeenDried == True:
		print "The gold is gone, nothing of interest here."
		place = "mountain_top"
		mountain_top(place)

def warrior(place):
	global HasHeDied
	while place == "warrior" and HasHeDied == False:
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You stand next to resting soldier, someone who appears to be a part of something royal."	
		elif user_input == "west":
			print "To your west is a clump of trees."
		elif user_input == "east" or user_input == "north" or user_input == "walk east" or user_input == "walk north":
			print "Just ground, nothing really."
		elif user_input == "south":
			print "To your south is a majestic mountain, at least 3,000 feet high."
		elif user_input == "walk west":
			place = "clump_of_trees"
			clumpTrees(place)
		elif user_input == "walk south":
			place = "mountain_base_north"
			BaseOfNorthMountain(place)
		elif user_input == "speak" or user_input == "talk":
			print '''Hello, my name is Aurious, and I am a soldier in the King's Royal Guard. I was separated from my group, and have been searching these thirty days, for the King's staff, which was stolen by his second in command. With this staff, this man can command armies, crumble nations, and rule the world, if not stopped. 
And who, may I ask, are you? So, you are ''', user, ''', nice to meet you. By the way, avoid Het-'''
			print "Without warning, an arrow wizzes by your head, and strikes the man. He falls, and you hear no more from him, and when you look in the direction of where the arrow came from, nothing is there."
			HasHeDied = True
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "show map" or user_input == "read map" or user_input == "map":
			mapTruth()
	while place == "warrior" and HasHeDied == True:
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You stand next to fallen soldier, someone who appears to have been a part of something royal."	
		elif user_input == "west":
			print "To your west is a clump of trees."
		elif user_input == "east" or user_input == "north" or user_input == "walk east" or user_input == "walk north":
			print "To your east, is just ground, nothing really."
		elif user_input == "south":
			print "To your south is a majestic mountain, at least 3,000 feet high."
		elif user_input == "walk west":
			place = "clump_of_trees"
			clumpTrees(place)
		elif user_input == "walk south":
			place = "mountain_base_north"
			BaseOfNorthMountain(place)
		elif user_input == "speak" or user_input == "talk":
			print "To who?"
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "show map" or user_input == "read map" or user_input == "map":
			mapTruth()
def north_edge_lake(place):
	while place == "north_edge_lake":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing on the edge of a former lake. You see a small shack directly in front of you."	
		elif user_input == "west":
			print "Trees line the former beach to the west."
		elif user_input == "east":
			print "Trees line the former beach to the east."
		elif user_input == "south":
			print "You stand at the edge of a former lake, and to your south(behind you), the former lake stretches out in the distance."
			print "You can see a mountain in the distance behind the lake."
		elif user_input == "north":
			print "To your north, is a small shack."
		elif user_input == "walk north":
			print "You walk over to the shack, and your feet sink into the damp ground as you walk."
			place = "doorway_of_shack"
			doorway_of_shack(place)
		elif user_input == "walk west" or user_input == "walk east":
			print "The lake is too big to walk around, the only way across, is straight through."
		elif user_input == "walk south":
			walk_south_lake()
		elif user_input == "help":
			help()
		elif user_input == "inventory":
			print inventory
		elif user_input == "read map" or user_input == "show map" or user_input == "map":
			mapTruth()


def doorway_of_shack(place):
	while place == "doorway_of_shack":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You stand outside of a small shack."
		elif user_input == "west" or user_input == "east":
			print "Just some trees"
		elif user_input == "north":
			print "You stand outside of a small shack, and the door is in front of you."
		elif user_input == "south":
			print "To your south is the edge of the former lake."
		elif user_input == "door" or user_input == "open door" or user_input == "walk north":
			print "The door creaks open as you push it."
			place = "small_shack"
			small_shack(place)
		elif user_input == "walk south":
			print "You walk back to the former beach."
			place = "north_edge_lake"
			north_edge_lake(place)
		elif user_input == "walk east" or user_input == "walk west":
			print "There are just trees here, nothing to see."
		elif user_input == "help":
			help()
		elif user_input == "inventory":
			print inventory
		elif user_input == "read map" or user_input == "show map" or user_input == "map":
			mapTruth()
def small_shack(place):
	while place == "small_shack":
		user_input = raw_input(prompt)
		if user_input == "look" or user_input == "west" or user_input == "east":
			print "You stand inside a small shack, and there is barely enough room to move around in."
			print "To your west(it's literally like half a foot away), are some dead fish, hanging from the ceiling."
			print "To your east(it's like a half a foot away, the shack is so small), is a frying pan."
		elif user_input == "north":
			print "In front of you, is an engraving, bolted to the wall. Hint: If you want to read it, just type 'read'."
		elif user_input == "south":
			print "The door is still open, and it's the way out(as if you didn't know that by now ;)/>...)"
		elif user_input == "walk west" or user_input == "walk east":
			print "What? Oh, well since the shack is so small, you can't...well...really walk there."
		elif user_input == "walk north":
			print "You can't move in that direction, an engraving blocks your way."
		elif user_input == "read":
			print "This building is dedicated as a memorial for the honorable Hettick, who saved the King's life in honorable battle 6 years ago."
			print "He was just an insignificant fisherman, but when the King was riding by this lake, a Gilhad(one of the tribes near Golhadlandia) came behind the King in pursuit. Hettick shot the Gilhad down just as the Gilhad was striking-distance of the King."
			print "Hettick was then swiftly appointed as the King's second hand man."
			print "The engraving seems to have part of it broken off, and you can't read the rest of it."
		elif user_input == "walk south":
			place = "doorway_of_shack"
			doorway_of_shack(place)
		elif user_input == "help":
			help()
		elif user_input == "inventory":
			print inventory
		elif user_input == "read map" or user_input == "show map" or user_input == "map":
			mapTruth()
		elif user_input == "take fish" or user_input == "take dead fish":
			print "You weirdo....fine...you take the fish..."
			inventory.append("fish")
		elif user_input == "take pan" or user_input == "pan":
			print "You take the pan, and as you do, some strange dust falls off of it."
			inventory.append("pan")	
def clumpTrees(place):
	while place == "clump_of_trees" and HasHeDied == True:
		print "You walk into the clump of trees."
		print "You see a bow lying on the ground, and a quiver of arrows. You also see a tiny bit of what appears to be some fishing net."
		print "You walk back to the fallen warrior."
		place = "warrior"
		warrior(place)
	while place == "clump_of_trees" and HasHeDied == False:
		print "I don't see anything of interest here, but you have a good view of the soldier through the trees."
		print "You walk back to the resting soldier."
		place = "warrior"
		warrior(place)	

def mine_entrance(place):
	while place == "mine_entrance":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You are standing at the entrance of a mine, that looks very old, and not very safe, I might add."
		elif user_input == "west" or user_input == "east":
			print "This mine is surrounded by a thick, literally impassable forest. The trees are so close together, that you can't even see the area between them."
		elif user_input == "north":
			print "To your north(in front of you), is the entrance of a mine."
		elif user_input == "south":
			print "To your south is a huge mountain, at least 3,000 feet high."
		elif user_input == "walk west" or user_input == "walk east":
			print "There is a thick forest, and the trees grow so closely together, that you can't even see the light through them."
			print "You walk back to the mine entrance."
		elif user_input == "walk south":
			print "You walk to the huge mountain."
			place = "mountain_base_north"
			BaseOfNorthMountain(place)
		elif user_input == "walk north":
			print "You walk into the cave."
			place = "mine" 
			Mine(place)
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "map" or user_input == "show map" or user_input == "read map":
			mapTruth()
def Mine(place):
	print "You will be presented with several directional options, indicated by a number. Simply enter the given number to navigate down that path."
	print "There are two paths, which do you take?"
	user_input = raw_input("1.Left   2.Right\n")
	if user_input == "1":
		print "You walk down the left path."
	elif user_input == "2":
		print "You walk down the right path."
	print "There are three paths, which do you take?"
	user_input = raw_input("1.Left   2.Right   3.Middle\n")
	if user_input == "1":
		print "You walk down the left path."
	elif user_input == "2":
		print "You walk down the right path."
	elif user_input == "3":
		print "You walk down the middle path."
	print "There is only one path to take, you walk down it."
	print "There are two paths ahead of you."
	user_input = raw_input("1.Left   2.Right\n")
	if user_input == "1":
		print "You walk down the left path."
		rightWay()
	elif user_input == "2":
		print "You walk down the right path."
		wrongWay()
	
		
		

def cavern(place):
	while place == "cavern":
		user_input = raw_input(prompt)
		if user_input == "look":
			print "You stand inside a large cavern, that seems to be manmade."
		elif user_input == "west":
			print "To your west are some digging tools, probably those that were used in the making of this tavern."
		elif user_input == "east":
			print "To your east...well, you can't really see what is there. There is darkness there, and that's all you can make out."
		elif user_input == "south":
			print "To your south is the path into/out of the cave, and ultimately leads back to the exit of the cave."
		elif user_input == "north":
			print "It is dark, but you see a small blue circle in the air, to your north."
		elif user_input == "walk north":
			print "As you walk towards the blue circle, you seee it get bigger, and bigger, and you realize that it is what used to be the exit of the cave, but is sealed up, so there is only a small hole, about the size of your fist."
			place = "hole"
			hole(place)
		elif user_input == "walk west":
			print "You walk to the clump of tools."
			place = "tools"
			tools(place)
		elif user_input == "walk east":
			print "You walk over the dark spot."
			place = "Hettick"
			Hettick(place)
		elif user_input == "walk south":
			print "You start walking out of the cave, and find your way out."
			place = "mine_entrance"
			mine_entrance(place)
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "map" or user_input == "show map" or user_input == "read map":
			mapTruth()
def tools(place):
	while place == "tools":
		user_input = raw_input(prompt)
		if user_input == "take tools" or user_input == "take tool":
			print "You take a pick-axe, and a shovel."
			inventory.append("pick-axe")
			inventory.append("shovel")
		elif user_input == "look":
			print "You stand at a clump of tools."
		elif user_input == "west":
			print "To your west is the western(duh;) ) wall of the cavern."
		elif user_input == "east":
			print "To your east is a spot of darkness, you can't really see what is there."
		elif user_input == "south":
			print "To your south is the path you took to get into the cavern, which ultimately leads to the exit of the cave."
		elif user_input == "north":
			print "To your north is a small, blue circle of light."
		elif user_input == "walk west":
			print "You can't walk into a wall."
		elif user_input == "walk east":
			place = "Hettick"
			Hettick(place)
		elif user_input == "walk north":
			print "As you walk towards the blue circle, you seee it get bigger, and bigger, and you realize that it is what used to be the exit of the cave, but is sealed up, so there is only a small hole, about the size of your fist."
			place = "hole"
			hole(place)
		elif user_input == "walk south":
			print "You walk down the path you came in, and eventually come to the exit of the cave."
			place = "mine_entrance"
			mine_entrance(place)
		elif user_input == "inventory":
			print inventory
		elif user_input == "help":
			help()
		elif user_input == "map" or user_input == "show map" or user_input == "read map":
		 	mapTruth()



def Hettick(place):
	global Hettickf
	if not("axe" or "mace" or "sword" in inventory):
		print "You walk to the dark spot, and you see a man, leaning against the wall."
		print "He advances toward you, and you pick up a rock and throw it at him, he yells and runs out of the cavern, never to be seen again."
		print "You walk back to the entrance of the cave."
		place = "cavern"
		cavern(place)
	if "axe" or "mace" or "sword" in inventory:
		print "You walk up to a man, leaning against the wall."
		print "He advances toward you, and you draw your weapon."
		print "He steps back, and raises his hands so that you know he is un-armed."
		print '"Who are you", you say. He says, "I am the noble Hettick, and I have been running these 30 days from the King\'s men.'
		print "You put your weapon closer to his body, and ask him why he is running."
		print "He says, 'I am running, because I care for this land's people.'"
		print "'Here, look at this.' he says. He hands you a dusty piece of stone, and you see some words written on it."
		print '''
This memorial was at one time dedicated to Hettick, but now it stands as a reminder, never to cross our King. Hettick was found conspiring against the King, thirty days ago. He is being found, and destroyed as this is being inscribed.\n\n''' 
		print "You look up, and in a loud voice, ask him what this means."
		print "He looks at you, and he whispers 'It means that the King must die.'"
		print "He advances toward you, and he picks up a sword to attack you, but you overcome him, and he falls."
		print "You walk back to the entrance of the cavern."
		Hettickf = False
		place = "cavern"
		cavern(place)

def hole(place):
	if not("pick-axe" or "shovel") in inventory:
		print "There is a small hole in front of you, about the size of your fist."
		print "Since you obviously can't fit into it, you walk back to the mouth of the cavern."
		place = "cavern"
		cavern(place)
	if "hole" and "pick-axe" or "shovel" in inventory:
		print "There is a small hole in front of you, you pick up your pick-axe, and start to beat at the rock. You finally open the hole up to about your waist, the sunlight streaming in, and take out your shovel. You dig away at the dirt on the outside, and you finally get free."
		print '''
	
It seems that that mine, lead directly under the thick forest.
You see a castle in the distance, and walk up to it.
		'''
		castle(place)

def castle(place):
	if Hettickf == True:
		print "As you walk towards the castle, several soldiers appear, grab your arms, and escort you into the castle."
		print "You see a large, fat, middle-aged man sitting on a gold throne."
		print "'And who is this that dares enter my castle?' he says. 'It is I,", user, " your Majesty' you reply."
		print "'So, you have brought tidings of Hettick?' he states. Puzzled, you ask him what he means."
		print "'You didn't know that no one is to come to me, without tidings of the whereabouts of Hettick, on the pang of the death!' he roars. 'Si-sir, I didn't know, I-I wouldn't have come if I had known.' you stammer."
		print "'Well, since you didn't know, you don't have to die, but you must get back to work, send him to the dungeon to work, guards.' They drag you away to the dungeons."
		reason = "dungeon"
		Death(reason)
	elif Hettickf == False:
		print "As you walk towards the castle, several soldiers appear, grab your arms, and escort you into the castle."
		print "You see a large, fat, middle-aged man sitting on a gold throne."
		print "'And who is this that dares enter my castle?' he says. 'It is I,", user, " your Majesty' you reply."
		print "'So, you have brought tidings of Hettick?' he states."
		print "Yes,  he rose up agaisnt me in the mines, and I struck him down."
		print "'HAHA, YES,  THE KI-, er, usurper is dead!' he shouts. 'He said something about the King must die, before I threatened him, do you know why he said that?' you ask."	
		print "Er, pay no attention to what he said, it must have been a part of his evil plan."
		print "The King gives you riches, for the rest of your life, and you live happily ever after.\n\n"
	
		print "But you always wondered what the King meant, when he said as he walked away from you that day, 'Haha, now, the true fun begins...'"
		




		print "\n\n\n\n\n\n\n Congratulations! You finished the 1st part of 'The King's Spear', hopefully I left enough information out, so that you can't figure out what really happened. When I get the time, I will make a Part 2, which will be better programmed, and I look forward to it."
		exit()
	
mapf = '''
#########     ####################################
#????????    ?????????????????????         ???????????????????????????????????#
#????????     ?????????????????????????????????                           ????#
#??????????  ????????????????         ???????           ??   ?????????????????#
#????????????     ????????????????????????????????????????????????????????????#			
#?????????????????????????????????????????????????????????????????????????????#
#????         ????                              ??????????????????????????????#
#???????????????                   ???????????      ?????                ?????#
#????????????????????????         ???????????????? ???????????????       #
#??????????????????????????????????????????????????????           ?????????????#
#????           ????????         ???????????                              ????#
#?????????????????????????????????????????????????????????????????????????????#
#????????????????????????????????  ########  ?????????????????????????????????#		
#????????????????????????????????  Mountain  ?????????????????????????????????#		
#????????????????????????????????  ########  ?????????????????????????????????#		
#?????????????????????????????????????????????????????????????????????????????#		
#?????????????????????????????????????????????????????????????????????????????#				
#?????????????????????????????????????????????????????????????????????????????#	 
#?????????????????????????????????????????????????????????????????????????????#	 
#?????????????????????????????????????????????????????????????????????????????#		 				
#???????   #######  ??????????????????????????????  #############  ???????????#	 				
#???????   Village  ??????????????????????????????  Golhad's Cave  ???????????#	 			
#???????   #######  ??????????????????????????????  #############  ???????????#			
#?????????????????????????????????????????????????????????????????????????????#				
#?????????????????????????????????????????????????????????????????????????????#			
#?????????????????????????????????????????????????????????????????????????????#
#?????????????????????????????  ##############  ??????????????????????????????#
#?????????????????????????????  Starting House  ??????????????????????????????#
#?????????????????????????????  ##############  ??????????????????????????????#
###############################################################################
'''
def PlayGame():
	global PlayedGame
	global money
	if PlayedGame == False:

		print "You only get once chance to play this game, no repeating."
		print 'First question: "The capital of Texas?"'
		user_input = raw_input(prompt)
		if user_input == "Austin" or user_input == "austin":
			
			money += 2
			print "Correct!"
		else:
			print "Incorrect."
		
		print 'What are the first 5 numbers of Pi?'
		user_input = raw_input(prompt)
		if user_input == "3.141" or user_input == "3141":
			print "Correct!"
			money += 2
		else:
			print 'Incorrect.'
		
		print "What is the square root of 4?"
		user_input = int(raw_input(prompt))
		if user_input == 2:
			print "Correct!"
			
			money += 2
		else:
			print "Incorrect."
		
		
		print "What is the second color in the Google name?"
		user_input = raw_input(prompt)
		if user_input == "red" or user_input == "Red":
			print "Correct!"
			
			money += 2
		else:
			print "Incorrect."
		
		
		print "Who created this game?"
		user_input = raw_input(prompt)
		if user_input == "nicholas" or user_input == "Nicholas" or user_input == "Nick" or user_input == "nick":
			print "Wonderful! It's amazing that you got that one right(unless I gave you a direct download link), you get extra money!"
			
			money += 4
		else:
			print "Incorrect. I'm not suprised you got that one wrong."
	

		print "Who was the first President of the USA?"
		user_input = raw_input(prompt)
		if user_input == "george washington" or user_input == "George Washington":
			print "Correct!"
			
			money += 2
		else:
			print "Incorrect."
	
	
		print "What is -5 + 7(4 + 5)?"
		user_input = int(raw_input(prompt))
		if user_input == 58:
			print "Correct!"
			
			money += 2
		
		else:
			print "Incorrect."
		

		print "Who won the American Civil war?"
		user_input = raw_input(prompt)
		if user_input == "the north" or user_input == "the Union" or user_input == "the North" or user_input == "North" or user_input == "north" or user_input == "the union" or user_input == "union" or user_input == "Union":
			print "Correct!"
			
			money += 2
		else:
			print "Incorrect."
	

		print "Who's equation is this? E=mc^2"
		user_input = raw_input(prompt)
		if user_input == "Einstein" or user_input == "einstein" or user_input == "Albert Einstein" or user_input == "albert einstein":
			print "Correct!"
			
			money += 2
	
		else:
			print "Incorrect."
	

		print "Last one, what language is this game written in?(Not English)"
		user_input = raw_input(prompt)
		if user_input == "Python" or user_input == "python":
			print 'Correct!'
			
			money += 2
		else:
			"Incorrect."
	
		print "Congratulations!, you have finished playing this mini-game, good luck with the rest of the game!"
		print "You now have %s money" % money
		
		PlayedGame = True

	else:
		print "You have already played, I'm sorry, you can't play again."


def isWeapon():
	if "axe" or "sword" or "mace" in inventory:
		place = "Golhad"
		Golhad(place)
	else:
		Death(reason)

def TakeItem(item):
	print "You pick up the %s and put it into your inventory." % item
	inventory.append(item)
	print "Your inventory now contains %s" % inventory

def Death(reason):
	if reason == "Golhad":
		print "You died by the hands of Golhad, because you had no weapon. Game Over."
		exit()
	elif reason == "dropoff":
		print "You walk off a cliff, plung straight down, and die. Game Over."
		exit()
	elif reason == "lake":
		print "Foolishly, you walk into the lake, and try your best to swim, but the lake is so deep, and the water so rough, that you drown. Game Over."
		exit()
	elif reason == "dungeon":
		print "You spend your life pining away in the dungeon, working at splitting rock."
		print "Game Over."
		exit()
		
def isKey():
	if "key" in inventory:
		place = "outside_door"
		outside_door(place)
	else:
		place = "starting_door"
		Door(place)
def hasMoney():
	if money >= 10:
		buyBlack()
	else:
		not_enough()

def mapTruth():
	if "map" in inventory:
		print mapf
	elif not("map") in inventory:
		print "What map?"
def not_enough():
	print "You don't have enough money"

def mountain_climb():
	print "You start climbing the mountain."
	a = 1
	b = 1
	c = 10
	for a in range(b, c):
		print "----------------------"
		time.sleep(1)
		a += 1	
	print "You made it to the top."
	place = "mountain_top"
	a = 1
	mountain_top(place)


def mountain_descent():
	print "You start descending the mountain."
	a = 1
	b = 1
	c = 10
	for a in range(b, c):
		print "----------------------"
		time.sleep(1)
		a += 1
	print "You arrive safely at the base of the mountain."
	place = "base_mountain"
	a = 1
	BaseOfMountain(place)	

def mountain_north_descent():
	print "You start descending the mountain."
	a = 1
	b = 1
	c = 10
	for a in range(b, c):
		print "----------------------"
		time.sleep(1)
		a += 1
	print "You arrive safely at the bottom of the mountain."
	place = "mountain_base_north"
	a = 1
	BaseOfNorthMountain(place)
	
def walk_north_lake():
	print "You walk across the former lake."
	a = 1
	b = 1
	c = 5
	for a in range(b, c):
		print "----------------------"
		time.sleep(1)
		a += 1
	print "You arrive at the north edge of the lake."
	place = "north_edge_lake"
	a = 1
	north_edge_lake(place)

def walk_south_lake():
	print "You walk across the former lake."
	a = 1
	b = 1
	c = 5
	for a in range(b, c):
		print "----------------------"
		a += 1
	print "You arrive at the south edge of the lake."
	place = "south_edge_lake"
	a = 1
	south_edge_lake(place)
def rightWay():
	print "There are three paths ahead of you, which do you take?"
	user_input = raw_input("1.Left  2.Right  3.Middle\n")
	if user_input == "1":
		print "You walk down the left path."
	elif user_input == "2":
		print "You walk down the right path."
	elif user_input == "3":
		print "You walk down the middle path."
	print "There are two paths ahead of you, which do you take?"
	user_input = raw_input("1.Left   2.Right\n")
	if user_input == "1":
		print "You walk down the left path."
	elif user_input == "2":
		print "You walk down the right path."
	print "You come to a large cavern, it's ceiling towers above your head."
	place = "cavern"
	cavern(place)
	
def wrongWay():
	print "There are two paths ahead of you, which do you take?"
	user_input = raw_input("1.Left  2.Right  \n")
	if user_input == "1":
		print "You walk down the left path."
	elif user_input == "2":
		print "You walk down the right path."
	print "There are three paths ahead of you, which do you take?"
	user_input = raw_input("1.Left   2.Right   3.Middle\n")
	if user_input == "1":
		print "You walk down the left path."
	elif user_input == "2":
		print "You walk down the right path."
	elif user_input == "3":
		print "You walk down the middle path."
	print "There are four paths ahead of you, which do you take?"
	user_input = raw_input("1.Left  2.Right 3.Middle 4.Far left\n")
	if user_input == "1":
		print "You walk down the left side."
	elif user_input == "2":
		print "You walk down the right side."
	elif user_input == "3":
		print "You walk down the middle path."
	elif user_input == "4":
		print "You walk down the far left side."
	print "You come to a...dead end, and you return to the entrance of the cave."
	place = "mine_entrance"
	mine_entrance(place)


def help():
	print '''Command list:
Directional commands:
look:Prints out your surroundings.
west:Prints out what is to your west.
south:Prints out what is to your south.
north:Prints out what is to your north.
east:Prints out what is to your east.

Movement commands:
walk west:Move to the west.
walk south:Move to the south.
walk north:Move to the north.
walk east:Move to the east.

Misc. Commands:

help:Prints out this text.''' 

blacksmith = ["axe", "horseshoe", "sword", "anvil", "mace"]
inventory = []
Hettickf = True
HasHeDied = False
HasBeenDried = False
Weapon = False
TakenMap = False
TakenCoins = False
PlayedGame = False
money = 0
os.system('clear')
prompt = ">"
place = "start"
user = raw_input("Enter your name: ")
print '''Hello, ''', user, ''',and welcome to \'The King's Spear\', in this game, to move, you use these commands:
walk west:Move to the west.
walk south:Move to the south.
walk north:Move to the north.
walk east:Move to the east.
'''
print '''\nTo look around you, use these commands:
look:Prints out your surroundings.
west:Prints out what is to your west.
south:Prints out what is to your south.
north:Prints out what is to your north.
east:Prints out what is to your east.
'''
print '''\nOther misc. commands:
take <item>:Adds said item to your inventory.
inventory:Prints out the contents of your inventory.
speak:Engages you in dialogue
NOTE:Sometimes, a character will talk to you without the 'speak' command, and sometimes he won't.

'''
print "\n Okay, well that should start you on your way."
print "You are a young man/woman, who is in a house, and great adventures lead from there.  Make sure you look in all directions before you use the movement commands. Using the look, east, west, south, and north commands, is crucial for you survival, and good experience with this game."

print "Also, just type in 'help', anytime you need, well, help :D/>"
print "\n\n\n Enjoy!"
Golhadf = True	
Start(place)



Is This A Good Question/Topic? 0
  • +

Replies To: Ahhh, procedural programming!

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4334
  • View blog
  • Posts: 12,131
  • Joined: 18-April 07

Re: Ahhh, procedural programming!

Posted 16 February 2014 - 05:27 PM

I kind of thought from the title this would be just bad implementation of procedures, but this is more like just bad DRY principles. Either way, a nightmare for the ages and hopefully I will be able to sleep tonight knowing this is out there.

:)
Was This Post Helpful? 0
  • +
  • -

#3 project21124  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 40
  • Joined: 02-February 14

Re: Ahhh, procedural programming!

Posted 16 February 2014 - 09:15 PM

Read it over and over again, and let it creep into your heart.
*mwahaha*
Was This Post Helpful? 1
  • +
  • -

#4 Lieoften  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 244
  • Joined: 06-January 10

Re: Ahhh, procedural programming!

Posted 17 February 2014 - 01:10 PM

View Postproject21124, on 16 February 2014 - 09:15 PM, said:

Read it over and over again, and let it creep into your heart.
*mwahaha*


You sir are the devil...
Was This Post Helpful? 0
  • +
  • -

#5 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 463
  • View blog
  • Posts: 3,166
  • Joined: 12-January 10

Re: Ahhh, procedural programming!

Posted 17 February 2014 - 02:40 PM

has anyone seen my
elif
? The internet seems to have run out of them...
Was This Post Helpful? 2
  • +
  • -

#6 project21124  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 40
  • Joined: 02-February 14

Re: Ahhh, procedural programming!

Posted 17 February 2014 - 05:09 PM

Yea!
Was This Post Helpful? 0
  • +
  • -

#7 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Ahhh, procedural programming!

Posted 27 February 2014 - 02:02 PM

Well, that's interesting...

You have Kitchen in there twice by the way.
Was This Post Helpful? 0
  • +
  • -

#8 dak45309  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 80
  • Joined: 22-April 13

Re: Ahhh, procedural programming!

Posted 26 June 2014 - 12:51 PM

Why didn't you just use switches and functions that passed Strings into the function for player movement? o.O
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1