import random import time def win(): print "As you slay the dragon, the other monsters cower before you. They flee in peril. THE VILLAGE IS SAVED!" redo = raw_input("\nDo you want to play again!?!?!\n").title() if redo == "Yes": time.sleep(2.5) print "\nSweet!\n" time.sleep(1.5) print "\nLoading...\n" time.sleep(5) game() elif redo == "No": print "\nIts a shame to let you go. I hope you had fun!\n" time.sleep(3) s = raw_input("\nAre you sure you want to go?\n").title() if s == "Yes": time.sleep(2) print "\nOkay. :( Bye,\n" time.sleep(1.5) quit() elif s == "No": time.sleep(2) ss = raw_input("You really mean it?").title() if ss == "Yes": time.sleep(2) print "Yay!" time.sleep(3) print "Loading Game!" time.sleep(5) game() elif ss == "No": time.sleep(2) print "Oh... you are mean! >:(" time.sleep(5) print "Leave me alone!" time.sleep(3) quit() else: pa = raw_input("I don't understand, play again?").title() while pa == "": pa = raw_input("I don't understand, play again?").title() if "Yes": time.sleep(3) print "\nLoading\n" time.sleep(5) game() else: time.sleep(3) print "\nOk, bye!\n" time.sleep(2) quit() else: pa = raw_input("I don't understand, play again?").title() while pa == "": pa = raw_input("I don't understand, play again?").title() if "Yes": time.sleep(3) print "\nLoading\n" time.sleep(5) game() else: time.sleep(3) print "\nOk, bye!\n" time.sleep(2) quit() else: pa = raw_input("I don't understand, play again?").title() while pa == "": pa = raw_input("I don't understand, play again?").title() if "Yes": time.sleep(3) print "\nLoading\n" time.sleep(5) game() else: time.sleep(3) print "\nOk, bye!\n" time.sleep(2) quit() def gameOver(): time.sleep(3) print "\nAww shucks, looks like you've been killed. Sucks to be you\n!" retry = raw_input("\nDo you want to try again? (yes or no)\n\n").title() if retry == "Yes": game() else: quit() def game(): gold = 5000 #ForTestingValueNotPermenant" character_hp = 125 weapon_damage = 15 monster_damage = 18 monster_payout = 80 #pdmg = weapon_damage + rand wpndmg = weapon_damage weapons = ["fists"] chest = ["shirt"] hands = ["gloves"] legs = ["pants"] MONSTERS = { "rat":10, "goblin":55, "zombie":80, "skeleton":65, "wolf":105, "dragon":150 } ARMOR_CHEST = { "dragonscale breastplate":1000, "steel breastplate":500, "iron breastplate":300, "bronze breastplate":200, "placebo breastplate":0 } WEAPONS_STORE = { "dragonsbane":500, "greatsword":250, "sword":140, "axe":120, "club":75, "bat":45, "stick":5 } gender = raw_input("\nAre you a boy or a girl?\n\n").title() while gender == "": gender = raw_input("\nThat is not a real gender. Are you a boy or a girl?\n\n").title() name = raw_input("\nWhat is your name?\n\n").title() while name == "": name = raw_input("\nThat's not a valid name. What is your name?\n\n").title() print "\nWelcome", name, "Enjoy, Your Adventure" while character_hp > 0: #Chestplate Purchasing store = raw_input("\nDo you want to buy chest protection? (yes or no)\n\n").title() if store == "Yes": print "\nCHESTPIECES\t\tCOSTS\n" for items in ARMOR_CHEST: print items, "\t\t", ARMOR_CHEST[items], "\n" print "\nYou have", gold, "gold.\n\n" armor_purchase = raw_input("Which armor piece would you like to buy? (Dragonscale Gear is Useful Only for Fighting Dragons) \n\n").lower() while armor_purchase not in ARMOR_CHEST or armor_purchase in chest: armor_purchase = raw_input("That is not in stock. Which chestpiece would you like to buy?\n\n").lower() if armor_purchase in ARMOR_CHEST and armor_purchase not in chest: if gold >= ARMOR_CHEST[armor_purchase]: print "\nYou just bought a(n)", armor_purchase, "!\n" gold -= ARMOR_CHEST[armor_purchase] chest.append(armor_purchase) print "\nYou have", gold, "gold remaining.\n" print "\nChestware you now own", chest,"\n" elif gold <= ARMOR_CHEST[armor_purchase]: print "Not enough gold. You poor, poor", gender, ". Kill more stuff! You need to actually grind for gold dummy!" elif store == "No": store1 = raw_input("\nDo you wish to purchase a weapon? (yes or no)\n\n").title() #Weapons Purchasing if store1 == "Yes": print "\nWEAPONt\tCOST\n" for items in WEAPONS_STORE: print items, "\t\t", WEAPONS_STORE[items], "\n" print "\nYou have", gold, "gold\n\n" weapon_purchase = raw_input("Which weapon would you like to buy?\n\n").lower() while weapon_purchase not in WEAPONS_STORE or weapon_purchase in weapons: weapon_purchase = raw_input("Which weapon would you like to buy?\n\n").lower() if weapon_purchase in WEAPONS_STORE and weapon_purchase not in weapons: if gold >= WEAPONS_STORE[weapon_purchase]: print "you bought a(n)", weapon_purchase, "\n" gold -= WEAPONS_STORE[weapon_purchase] weapons.append(weapon_purchase) print "\nyou have", gold, "gold\n" print "\nWeapons(s) you own", weapons,"\n" elif gold <= WEAPONS_STORE[weapon_purchase]: print "not enough gold" elif store1 == "No": print "\nThen its about time you should go and fight some monsters!\n" print "\nMONSTERS\tHEALTH\t\n" for monster in MONSTERS: print monster, "\t\t", MONSTERS[monster], "\n" monchoice = raw_input("Which monster do you want to fight first?\n\n").lower() if monchoice in MONSTERS: print "\nGood luck! Try not to get killed by the", monchoice, "!" else: print "That monster listed is not here." while monchoice not in MONSTERS: monchoice = raw_input ("Which moster do you want to fight first?\n\n").lower() print "\nWEAPONS YOU OWN\n" for weapon in weapons: print weapon, "\n" weapuse = raw_input("Which weapon will you use for this fight?\n\n").lower() if weapuse in weapon: print "\nGreat choice", name,"! You will use the", weapuse,"against the", monchoice, ".\n" else: print name, "\n\nYou do not own a", weapuse,"!" while weapuse not in weapons: weapuse = raw_input("\nWhat weapon will you use?\n\n").lower() print "\nGood choice", name, "you will use your", weapuse, "to fight the", monchoice #Protection Values #Chest Armor if chest == "dragonscale breastplate": rand3 = random.randint (2, 5) elif chest == "steel breastplate": rand3 = random.randint (21, 34) elif chest == "iron breastplate": rand3 = random.randint(13, 19) elif chest == "bronze breastplate": rand3 = random.randint(6, 11) elif chest == "placebo breastplate": rand3 = random.randint(0, 1) #rand3 + rand4 + rand5 = protection #rand4 = hands #rand5 = pants #Mob Damage if monchoice == "dragon": rand2 = random.randint (-1,15) if chest == "dragonscale breastplate": rand3 = random.randint (24, 61) elif monchoice == "goblin": rand2 = random.randint (-6, -2) elif monchoice == "wolf": rand2 = 12 elif monchoice == "skeleton": rand2 = random.randint (-3, 6) elif monchoice == "rat": rand2 = random.randint (-17, -14) '''if chest == "placebo breastplate": rand3 = 5''' elif monchoice == "zombie": rand2 = random.randint (-4, 6) if weapuse == "fists" or "stick": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = (monster_damage + rand2) - rand3 mdmg >= 1 rand = random.randint(4, 8) pdmg = rand + wpndmg print monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) elif weapuse == "bat": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = (monster_damage + rand2) - rand3 mdmg >= 1 rand = random.randint(5, 11) pdmg = rand + wpndmg print monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Dealing", mdmg - rand3, "Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) elif weapuse == "club": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = monster_damage + rand2 mdmg >= 1 rand = random.randint(6, 12) pdmg = rand + wpndmg print monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) elif weapuse == "axe": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = (monster_damage + rand2) - rand3 mdmg >= 1 rand = random.randint(8, 13) pdmg = rand + wpndmg print monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) elif weapuse == "sword": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = (monster_damage + rand2) - rand3 mdmg >= 1 rand = random.randint(9, 16) pdmg = rand + wpndmg print "The", monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) elif weapuse == "greatsword": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = (monster_damage + rand2) - rand3 mdmg >= 1 rand = random.randint(14, 21) pdmg = rand + wpndmg print "The", monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) elif weapuse == "dragonsbane": while character_hp > 0 and MONSTERS[monchoice] > 0: mdmg = (monster_damage + rand2) - rand3 mdmg >= 1 if monchoice == "dragon": rand = random.randint(23, 47) else: rand = random.ranint(4, 7) pdmg = rand + wpndmg print "The", monchoice, "has", MONSTERS[monchoice], "health left\n\n" time.sleep(1.5) print "The", monchoice, "attacked YOU. Your armor hopefully protected you." character_hp -= mdmg if character_hp <= 0: gameOver() print name, ", you have", character_hp, "health remaining." time.sleep(1.5) print "\nYou attacked the", monchoice, "with your", weapuse, "dealing", pdmg, "damage!" MONSTERS[monchoice] -= pdmg time.sleep(1.5) else: print name, "\nYou dont have that!" while weapuse not in weapons: weapuse = raw_input("Which weapon will you use for this fight?\n\n").lower() print "\nGreat choice", name, "! You will use the", weapuse, "against the", monchoice, ".\n" if MONSTERS[monchoice] <= 0: if monchoice == "dragon": rand1 = random.randint(-24, 108) elif monchoice == "rat": rand1 = random.randint(-79, -74) elif monchoice == "goblin": rand1 = random.randint(-32, 73) elif monchoice == "skeleton": rand1 = random.randint(2, 132) elif monchoice == "zombie": rand1 = random.randint(-3, 68) elif monchoice == "wolf": rand1 = random.randint(-74, -12) print "\nYou have finished the", monchoice,"!\nYou have earned", monster_payout + rand1, "gold." character_hp = 125 gold += monster_payout + rand1 "\nYou now have", gold, "gold.\nYou have been healed.\n" if monchoice == "dragon": win() del MONSTERS[monchoice] game()
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