import random
class enemyData:
health = {"Goblin": 100, "Orc": 50, "Dragon": 200}
attack = {"Goblin": 10, "Orc": 5, "Dragon": 20}
class playerData:
inventory = ["Small Potion", "Small Potion", "Small Potion", "Medium Potion", "Medium Potion", "Large Potion"]
itemAmounts = {"Small Potion": 20, "Medium Potion": 30, "Large Potion": 75}
armorBonus = {"Weapon": 1, "Helmet": 0, "Chestplate": 0, "Leggings": 0, "Boots": 0}
health = 100
damage = 10
z = random.randint(0,2)
if (z == 0):
enemyName = "Goblin"
x = enemyData.health["Goblin"]
y = enemyData.attack["Goblin"]
if (z == 1):
enemyName = "Orc"
x = enemyData.health["Orc"]
y = enemyData.attack["Orc"]
if (z == 2):
enemyName = "Dragon"
x = enemyData.health["Dragon"]
y = enemyData.attack["Dragon"]
fighting = True
waiting = True
while waiting:
answer = input("Now what? (New enemy or quit) ")
if (answer.lower() == "new enemy"):
inventory = ["Small Potion", "Small Potion", "Small Potion", "Medium Potion", "Medium Potion", "Large Potion"]
enemyData.health.update({"Goblin": 100})
enemyData.health.update({"Orc": 50})
enemyData.health.update({"Dragon": 200})
playerData.health = 100
while fighting:
print("")
print(enemyName + ":")
print("%d HP" %(x))
print("%d Attack" %(y))
print("My Health: %d" %(playerData.health))
answer = input("What do you do? (Attack, Defend, or Heal) ")
if (answer.lower() == "heal"):
if (len(playerData.inventory) == 0):
print("You Have No Items Left")
else:
print("Your healing items:")
print(playerData.inventory)
response = int(input("Which number item would you like to use? "))
playerData.health += playerData.itemAmounts[playerData.inventory[response - 1]]
playerData.inventory.remove(playerData.inventory[response - 1])
print("The %s deals %d damage!" %(enemyName, y))
playerData.health -= y
if (answer.lower() == "attack"):
crit = random.randint(0,5)
if (crit == 0):
print("Critical Hit")
x -= playerData.damage * 5
print("You deal %d x 5 damage" %(playerData.damage))
print("The %s deals %d damage!" %(enemyName, y))
playerData.health -= y
print("")
else:
x -= playerData.damage
print("You deal %d damage" %(playerData.damage))
print("The %s deals %d damage!" %(enemyName, y))
playerData.health -= y
print("")
if (answer.lower() == "defend"):
crit = random.randint(0,5)
if (crit == 0):
print("Critical Hit")
x -= playerData.damage
print("You deal full but take half damage")
playerData.health -= y / 2
print("")
else:
x -= playerData.damage / 2
playerData.health -= y / 2
print("You take and deal half damage")
print("")
if (x <= 0):
print("You killed the beast. Good Job!")
break
if (playerData.health <= 0):
print("You Died")
break
if (answer.lower() == "quit"):
print("You leave")
break
To embed this program on your website, copy the following code and paste it into your website's HTML: