Yeah so I was bored in class cuz I didnt know the test wasn't today, so I made part of a Python game. The battling works so far, and I might need some help later on so if anyone could could help me I'd appreaciate it.
Norbert Quest:
import random
m = random.randrange(50)+1
#main
health = 150
ehealth = 50
money = 0
def Shop():
global weapon
weapon[0] = "Steel Knuckles"
weapon[1] = "Knife"
weapon[3] = "Sword"
weapon[4] = "Gun"
weapon[5] = "Rocket Launcher"
print \
"""
1 - Steel Knuckles 20$
2 - Knife 30$
3 - Sword 100$
4 - Gun 300$
5 - Rocket Launcher 1000$
"""
z = input("Which weapon do you want?")
if money >= cost:
print"You have bought a",weapon[z]
money = money - c
mode = restart
elif money < cost:
print"You don't have enough gold to buy this."
raw_input("Press [enter] to exit.")
mode = restart
def eAttack():
attacke = random.randrange(15)+1
return attacke
def HP():
e = eAttack()
global health
health = health - e
print"Your HP is",health
def Gold():
global money
def nAttack():
attack = random.randrange(10)+1
return attack
def EnemyHP():
n = nAttack()
global ehealth
ehealth = ehealth - n
print "Monster's HP is",ehealth
while True:
print \
"""
Welcome to NorbertQuest!
Type:
- [battle] to hunt monsters
- [shop] to buy weapons
- [exit] to quit the game.
"""
mode = raw_input("What do you want to do?: ")
while"battle"in mode:
turn = raw_input("Do you want to Attack or Defend?")
if"attack"in turn:
print"You're attacking!"
EnemyHP()
HP()
elif"defend"in turn:
print"You're defending!"
print"Monster's HP is",ehealth
print"Your HP is",health
else:
print"Type attack or Defend!"
if health <= 0:
print"You are dead!"
mode = restart
if ehealth <= 0:
print "You win the battle! You earn",m,"$!"
money = money + m
while"exit"in mode:
exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ")
if"yes"in exit:
break
elif"no"in exit:
mode = restart
raw_input("Press [enter] to exit.")