Nevermind I didn't do the indenting right. But now I'm getting a bunch of errors and I don't know what to do.
import random
class NorbertQuest(object):
def __init__(self):
self.w = 0
self.level = 1
self.m = random.randrange(50)+1+self.level*5
self.cost = 0
self.xp = 0
self.health = 150
self.ehealth = 100
self.money = 0
def Shop():
self.weapon1 = "Steel Knuckles"
self.weapon2 = "Knife"
self.weapon3 = "Sword"
self.weapon4 = "Gun"
self.weapon5 = "Rocket Launcher"
print \
"""
What'll it be?
1 - Steel Knuckles 20$
2 - Knife 30$
3 - Sword 100$
4 - Gun 300$
5 - Rocket Launcher 1000$
Type exit to quit.
"""
self.z = input("Which weapon do you want?")
if self.z == 1:
self.cost = 20
if self.money >= self.cost:
print"You have bought",self.weapon1
self.money = self.money - self.cost
self.w = 1
self.mode = "restart"
elif self.money < self.cost:
print"You don't have enough gold to buy this."
raw_input("Press [enter] to exit.")
self.mode = "restart"
elif self.z == 2:
self.cost = 30
if self.money >= self.cost:
print"You have bought",self.weapon2
self.money = self.money - self.cost
self.w = 2
self.mode = "restart"
elif self.money < self.cost:
print"You don't have enough gold to buy this."
raw_input("Press [enter] to exit.")
self.mode = "restart"
elif self.z == 3:
self.cost = 100
if money >= self.cost:
print"You have bought",self.weapon3
self.money = self.money - self.cost
self.w = 3
self.mode = "restart"
elif self.money < self.cost:
print"You don't have enough gold to buy this."
raw_input("Press [enter] to exit.")
self.mode = "restart"
elif self.z == 4:
self.cost = 300
if money >= self.cost:
print"You have bought",self.weapon4
self.money = self.money - self.cost
self.w = 4
self.mode = "restart"
elif self.money < self.cost:
print"You don't have enough gold to buy this."
raw_input("Press [enter] to exit.")
self.mode = "restart"
elif self.z == 5:
self.cost = 1000
if self.money >= self.cost:
print"You have bought",self.weapon5
self.money = self.money - self.cost
self.w = 5
self.mode = "restart"
elif self.money < self.cost:
print"You don't have enough gold to buy this."
raw_input("Press [enter] to exit.")
self.mode = "restart"
elif self.z == "exit":
self.mode = "restart"
def eAttack():
self.attacke = random.randrange(10)+self.level*10
return self.attacke
def HP():
self.e = self.eAttack()
self.health = self.health - self.e
print"Your HP is",self.health
def nAttack():
self.attack = random.randrange(10)+level*5
if self.w == 1:
self.attack = random.randrange(10)+20+level*5
elif self.w == 2:
self.attack = random.randrange(10)+35+level*5
elif self.w == 3:
self.attack = random.randrange(10)+55+level*5
elif self.w == 4:
self.attack = random.randrange(10)+80+level*5
elif self.w == 5:
self.attack = random.randrange(10)+110+level*5
return self.attack
self.tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]
def LVL():
if 1 <= self.level <= len(self.tnls):
self.tnl = self.tnls[self.level-1]
if self.tnl <= self.xp:
self.level += 1
if self.level > len(self.tnls):
self.level = 100
self.xp = 0
print("Your new level is %d! Congratulations!" % self.level)
if self.level == 100:
print("Congratulations, you beat the Demo!")
def EnemyHP():
self.n = self.nAttack()
self.ehealth = self.ehealth - self.n
print "Monster's HP is",self.ehealth
self.monster = "Giant Python!"
while True:
print \
"""
Welcome to NorbertQuest!
Type:
- [battle] to hunt monsters
- [shop] to buy weapons
- [exit] to quit the game.
"""
self.mode = raw_input("What do you want to do?: ")
if self.mode == "shop":
Shop()
if self.mode == "battle":
print"You have encountered a",self.monster,"What will you do?"
self.health = 150+self.level*100
self.ehealth = 100+self.level*125
self.m = random.randrange(50)+1+self.level*5
self.xpGain = random.randrange(25)+self.level+25
self.xp = self.xpGain + self.xp
LVL()
while self.mode == "battle":
self.fight = random.randrange(10)+1
if self.fight == 1:
self.monster = "Dragon!"
elif self.fight == 2:
self.monster = "Wild Cayote!"
elif self.fight == 3:
self.monster == "Jaguar!"
elif self.fight == 4:
self.monster = "Orc Lord!"
elif self.fight == 5:
self.monster = "Goblin!"
elif self.fight == 6:
self.monster = "Crazy Robot!"
elif self.fight == 7:
self.monster = "Werewolf!"
elif self.fight == 8:
self.monster = "Vampire!"
elif self.fight == 9:
self.monster = "Giant Spider!"
elif self.fight == 10:
self.monster = "Pirate King!"
self.turn = raw_input("Do you want to Attack or Defend?")
if"attack"in self.turn:
print"You're attacking!"
EnemyHP()
HP()
elif"defend"in self.turn:
print"You're defending!"
print"Monster's HP is",self.ehealth
print"Your HP is",self.health
else:
print"Type attack or Defend!"
if self.health <= 0:
print"You are dead!"
self.mode = "restart"
resetHP()
elif self.ehealth <= 0:
print "You win the battle! You earn",self.m,"$!"
self. money = self.money + self.m
self.mode = "restart"
resetHP()
self.m = random.randrange(50)+1+self.level*5
self.xpGain = random.randrange(25)+self.level+25
self.xp = self.xpGain + self.xp
LVL()
print"You gain",self.xpGain,"Experience Points!"
if self.mode == "exit":
self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ")
if"yes"in self.exit:
break
elif"no"in self.exit:
self.mode = "restart"
raw_input("Press [enter] to exit.")
n = NorbertQuest()
n.HP()