from time import * from random import * import os,sys, random def setup(): global name global HP global MP name = input("What is your name warrior? ") HP = randint(5,20) MP = randint(5,20) def clear_screen(): os.system('cis' if os.name=='nt' else 'clear') def title(): print (" __ _ __ ") print (" / / ___ __ _ ___ _ __ __| | ___ / _| /\ /\___ _ __ ___ ___ ___ ") print (" / / / _ \/ _` |/ _ \ '_ \ / _` | / _ \| |_ / /_/ / _ \ '__/ _ \ / _ \/ __|") print ("/ /__| __/ (_| | __/ | | | (_| | | (_) | _| / __ / __/ | | (_) | __/\__ \ ") print ("\____/\___|\__, |\___|_| |_|\__,_| \___/|_| \/ /_/ \___|_| \___/ \___||___/") def castle(): print ("* |>>> + ") print ("+ * | * +") print (" |>>> _ _|_ _ * |>>> ") print (" * | |;| |;| |;| | *") print (" + _ _|_ _ \\. . / _ _|_ _ +") print (" * |;|_|;|_|;| \\: + / |;|_|;|_|;|") print (" \\.. / ||:+++. | \\. . / *") print (" + \\. , / ||:+++ | \\: . /") print (" ||:+ |_ _ ||_ . _ | _ _||:+ | *") print (" * ||+++.|||_|;|_|;|_|;|_|;|_|;||+++ | +") print (" ||+++ ||. . . . ||+++.| *") print ("+ * ||: . ||:. . . . , ||: | *") print (" * ||: ||: , + . ||: , | +") print (" * ||: ||:. +++++ . ||: | *") print (" + ||: ||. +++++++ . ||: . | +") print (" + ||: . ||: , +++++++ . . ||: | +") print (" ||: . ||: , +++++++ . . ||: | *") print (" ||: . ||: , +++++++ . . ||: |") clear_screen() title() castle() def north(): print ("To go north press n then enter") def east(): print ("To go east press e then enter") def south(): print ("To go south press s then enter") def west(): print ("To go west press w then enter") setup() def villager(): global npcname global repsonse responses = ["Hi", "Are you a hero?", "Are you from this village?", "There has been a dark shadow cast accross the village"] npcnamechoice = ["Bill", "Cedric", "Jimmy", "Jermaine"] random.shuffle(npcnamechoice) npcname = npcnamechoice[0] print ("\n["+npcname+":] Hello, my name is" "+npcname+", "Would you like to talk to me?\n") random.shuffle(responses) print ("Press y to talk to the villager") if input() == "y": print ("["+npcname+":] " +responses[0]) else: print("["+npcname+":] Goodbye") def enemy(): global enemyHP global enemyMP global enemyname enemyHP = randint(5,20) enemyMP = randint(5,20) enemyname = "Ogre" print ("\nSuddenly you hear a roar, and from the shadows you see an "+enemyname+" coming straight at you....") print ("Your enemy has " + " " + str(enemyHP) + " " + "Health Points") print ("Your enemy has " + " " + str(enemyMP) + " " + "Magic Points") villager() enemy() sleep(3) fight = input("Do you wish to fight?" ) if fight == "y": while HP > 0: hit = randint(0,5) print ("You swing your sword and cause " + str(hit) + " of damage") enemyHP = enemyHP - hit print (enemyHP) enemyhit = randint(0,5) print ("The ogre swings a club at you and causes " + str(enemyhit) + " of damage") HP = HP - enemyhit print (HP) else: print ("You turn and run away from the ogre") global name global HP global MP global move global enemyHP print ("Welcome to Middle Earth, " + name) sleep(2) print ("\nYour health is" + " " + str(HP)) print ("Your magic skill is" + " " + str(MP)) print ("Would you like to venture out into the land? Press y then enter to continue") if input() == "y": print ("You are in your home, with a roaring fireplace fireplace in front of you, above the fire you can see your sword and shield") print ("Would you like to take your sword and shield? Press y then enter to continue") if input () == "y": weapons = [] weapons.append("sword") weapons.append("shield") print ("You are now carrying your" " " + weapons[0] + " " + "and your" + " " + weapons[1]) print ("Armed with your " + weapons[0] + " " + "and " + weapons[1] + "You swing open the door to your home and see a green valley gleaming in the sunshine.") else: print ("You choose not to take your weapons") print ("Armed with your sense of humor, you swing open the door to see a green valley full of opportunity awaiting you.") else: print ("You stay at home, sitting in your favourite chair watching the fire grow colder. Middle Earth no longer has a hero") print ("Game Over") sys.exit(0) print ("In the distance to the north you can see a small village, to the east you can see a river and to the west a field of wild flowers.") print ("\n") north() east() west() south() move = input("Where would you like to go? ") if move == "n" or "W": print ("\nYou move to the north, walking in the sun") print ("A villager is in your path and greets you") elif move == "e" or "W": print ("\nYou walk to the river which lies to the east of your home.") print ("A villager is in your path and greets you") elif move == "w" or "W": print ("\nYou walk to the field of wild flowers, stopping to take in the beauty") print ("A villager is in your path and greets you\n") elif move == "s" or "W": print ("\nYou walk south to where the snowy mountains are, You reach a small village") print ("A villager greets you")