import turtle import time import math import random """ Hello! This game is made by Jack Kaiser and very much stil under work. I hope you enjoy! Expect to see - shop gold ranged damage more pots more classes multiple enemies weapons items use rep for perks - Somewhat Complete, could use expansion dex movement """ # Setting print("Hello traveler. I, the town elder, have seen many travelers") print("but none quite like you. I must warn you that formidable danger") print("lies ahead, but you look quite capable. So tell me, who are you?") print(" ") # Stats health = 0 meleeDMG = 0 rangedDMG = 0 dex = 0 # Input clas = input("Would you like to play as a knight, rogue, or ranger: ") # Text print(" ") print("Ah ha! I knew it!") print(" ") # Items sword = int(3) rapier = int(6) dagger = int(2) # Classes if clas == "knight" or clas == "Knight": health = 16 meleeDMG = 2 rangedDMG = 0 dex = 0 rep = 0 # Staring Equipment weap = sword hPot = 2 gold = 0 elif clas == "rogue" or clas == "Rogue": health = 10 meleeDMG = 3 rangedDMG = 2 dex = 1 rep = 0 # Staring Equipment weap = rapier hPot = 2 gold = 0 elif clas == "ranger" or clas == "Ranger": health = 13 meleeDMG = 3 rangedDMG = 5 dex = 1 rep = 0 # Staring Equipment weap = dagger hPot = 2 gold = 0 else: print("Error class if,elif,else") # Enemy 1 eHealth1 = random.randint(10,20) eMeleeDMG1 = random.randint(0,3) eRangedDMG1 = random.randint(0,5) eDex1 = random.randint(0,1) eWeap1 = sword # Describing Encounter 1 print("As you walk along the dreay road you notice a figure emerge from") print("the woods. He draws his sword and begins to charge!") print("Your current health:", health) print("The enemy's health:", eHealth1) print(" ") # Encounter 1 while health > 0 and eHealth1 > 0: pTurn = input("Do you fight or run: ") while pTurn == "fight" or pTurn == "Fight" or pTurn == "f": # Fighting turnMeleeDMG = random.randint(0,meleeDMG) + weap eHealth1 = eHealth1 - turnMeleeDMG eturnMeleeDMG = random.randint(0,eMeleeDMG1) + eWeap1 health = health - eturnMeleeDMG print("Your Health:", health) print("Enemy Health:", eHealth1) if health <= 0 and eHealth1 > 0: # Enemy wins break elif eHealth1 <= 0 and health > 0: # You wins break elif eHealth1 < 0 and health < 0: # Both die break else: # Escape print("Successful Escape!") print("Your remaining health:", health) break # End of Combat if health <= 0 and eHealth1 > 0: print(" ") print("You have perished.") end = input("Press Enter To Leave") exit() elif eHealth1 <= 0 and health > 0: print(" ") print("You have defeated the enemy.") loot = random.randint(0,1) # Loot if loot == 1: hPot = hPot + 1 lootGold = random.randint(0,3) gold = gold + lootGold rep = rep + 1 # Rep print("Current health:", health) print("Current Rep:", rep) print("Current Gold:", gold) print("Available health pots:", hPot) else: print("You have killed each other, goodjob?") end = input("Press Enter To Leave") exit() # Tutorial for Health Pots print(" ") print("!!!! Health pots provide +5 health but are not a guaranteed") print("drop. As well as only being able to use 1 per encounter. !!!!") print(" ") # Using healthPots print(" ") usehPot = input("Would you like to use a health pot: ") if usehPot == "Yes" or usehPot == "yes": hPot = hPot - 1 health = health + 5 print("Available health pots:", hPot) print("Current health:", health) elif usehPot == "No" or usehPot == "no": print("Available health pots:", hPot) print("Current health:", health) # Rep Shop print(" ") print("Welcome to the Reputation Shop. Here you can spend your rep points") print("to get buffs to different stats. Each rep point will buff the stat by 1.") print("Here are your current stats: ") print(health, ": Health") print(meleeDMG, ": Melee DMG") print(rep, "Rep Points") print(" ") repShop = input("Would you like to buff your stats: ") if repShop == "yes" or repShop == "Yes": print("You can only buff 1 stat per time at the shop.") repShopPerk = input("Would you like to buff your health or melee DMG: ") if repShopPerk == "health" or repShopPerk == "Health": health = health + 1 print("New health available:", health) elif repShopPerk == "melee DMG" or repShopPerk == "melee dmg": meleeDMG = meleeDMG + 1 print("New melee DMG:", meleeDMG) else: print("Come again.") # Gold Shop print(" ") enterShop = input("Would you like to access the shop: ") print("You currently have", gold) if enterShop == "yes" or enterShop == "Yes": print("Currently in stock we have a sword, rapier, and dagger.") print("The sword costs 2 gold and does 3 DMG.") print("The rapier costs 5 gold and does 6 DMG.") print("The dagger costs 1 gold and does 2 DMG.") enterShopWeap = input("Would you like to buy a weapon: ") if enterShopWeap == "yes" or enterShopWeap == "Yes": buyWeapItem = input("What weapon would you like to buy: ") if buyWeapItem == "sword" or buyWeapItem == "Sword": weap = sword elif buyWeapItem == "rapier" or buyWeapItem == "Rapier": weap = rapier elif buyWeapItem == "dagger" or buyWeapItem == "Dagger": weap = dagger else: print("Error buyWeapItem") else: print("Error enterShopWeap") else: print("Come again") # Closing Window print(" ") end = input("Press Enter To Leave")
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