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.")

New syntex (it's a new post cuz I can only edit 2 times):

import random

m = random.randrange(50)+1

#main
health = 150
ehealth = 50
money = 0

def Shop():
    weapon1 = "Steel Knuckles"
    weapon2 = "Knife"
    weapon3 = "Sword"
    weapon4 = "Gun"
    weapon5 = "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:
        if z = 1:
	    c = 20
	    print"You have bought a",weapon[z]
            money = money - c
	if z = 2:
	    c = 30
	    print"You have bought a",weapon[z]
            money = money - c
	if z = 3:
	    c = 100
	    print"You have bought a",weapon[z]
            money = money - c
	if z = 4:
	    c = 300
	    print"You have bought a",weapon[z]
            money = money - c
	if z = 5:
	    c = 1000
	    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.")

Well here's version 2 of the text game. There's a lot of bugs around the shop, and also I can't figure out how to make the monster and you get full HP after the battle's over.

V.3:

import random
w = 0
m = random.randrange(50)+1
cost = 0

#main
health = 150
ehealth = 50
money = 0

def Shop():
    global money
    weapon1 = "Steel Knuckles"
    weapon2 = "Knife"
    weapon3 = "Sword"
    weapon4 = "Gun"
    weapon5 = "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 z == 1:
        cost == 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w == 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    if z == 2:
        cost == 30
        if money >= cost:
            print"You have bought",weapon2
            money = money - cost
            w == 2
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    if z == 3:
        cost == 100
    if money >= cost:
            print"You have bought",weapon3
            money = money - cost
            w == 3
            mode = "restart"
    elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    if z == 4:
        cost == 300
        if money >= cost:
            print"You have bought",weapon4
            money = money - cost
            w == 4
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    if z == 5:
        cost == 1000
        if money >= cost:
            print"You have bought",weapon5
            money = money - cost
            w == 5
            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
    if mode == "restart":
        health = 150

def Gold():
    global money

def nAttack():
    attack = random.randrange(10)+1
    return attack
    if w == 1:
        attack = random.randrange(20)+1
    elif w == 2:
        attack = random.randrange(25)+1
    elif w == 3:
        attack = random.randrange(30)+1
    elif w == 4:
        attack = random.randrange(45)+1
    elif w == 5:
        attack = random.randrange(60)+1
    

def EnemyHP():
    n = nAttack()
    global ehealth
    ehealth = ehealth - n
    print "Monster's HP is",ehealth
    if mode == "restart":
        ehealth = 100

monster = 0

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 mode == "shop":
        Shop()
    while mode == "battle":
        fight = random.randrange(10)+1
        if fight == 1:
            monster = "Dragon!"
        elif fight == 2:
            monster = "Wild Cayote!"
        elif fight == 3:
            monster == "Jaguar!"
        elif fight == 4:
            monster = "Orc Lord!"
        elif fight == 5:
            monster = "Goblin!"
        elif fight == 6:
            monster = "Crazy Robot!"
        elif fight == 7:
            monster = "Werewolf!"
        elif fight == 8:
            monster = "Vampire!"
        elif fight == 9:
            monster = "Giant Spider!"
        elif fight == 10:
            monster = "Pirate King"
        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"
        elif ehealth <= 0:
            print "You win the battle! You earn",m,"$!"
            money = money + m
            mode = "restart"


    while mode == "exit":
        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.")

I would reset the player and monster health at the start of the battle.

The weapons would make a good class, the weapon has a name, a cost and an amount of damage. Then you could make a list of weapons that could be iterated for display at the shop. When the player buys a weapon, you could update their 'current' weapon and then use the 'current' weapon when calculating damage during the battle.

The following is some sample code of how the shop might work after you create the weapon class and a list of them. The sample code does not attempt to format the list in a 'pretty' form or to validate the user input, both would be beneficial updates.

for idx in range(len(weaponlist)):
    print idx + 1, weaponlist[idx].description, weaponlist[idx].cost
z = input("Which weapon do you want?")
if money > weaponlist[z].cost:
    playerweapon = weaponlist[z]
    print "You have bought", playerweapon.description
else:
    print "You can't afford the", weaponlist[z].description

The functions that display the health (of the player and the enemy) also calculate the damage applied and as such are poorly named. (The function name does not reflect what it does.) I would tend to separate them into a couple of functions, one to display the health and another to calculate the damage for an attack and apply it.

In the current program it is possible that the player might not have enough money to even buy the lowest weapon. If they can't buy a weapon, how much damage should they do?

The fight sequence currently does not take into account the weapon being used. (There is code that appears to want to support the concept, but the damage function returns before any of that code can be executed.)

Currently there is no difference between the monsters, they all have the same health and do the same damage. Was this how you intended it to work? (If you make some of the monsters harder, might the player want to 'run away' from something that is too tough?) Should there be better rewards from fighting harder monsters?

Right now, all damages are 'flat' random chances. If the damage is 1 to 10, all of the numbers from 1 to 10 are equally likely. A lot of 'combat' games have the concept of dice for damage. Where a weapon might use 2 six-sided dice commonly shown as (2d6). This example weapon will do from 2 to 12 points of damage, but not all numbers are as likely. The extremes (2 and 12) are rare and the most common damage will be 7. This would likely apply to both player and monster damage calculations.

That's what 'w' is for. If you buy weapon1 it'll change the base damage (random number out of 10) to random number out of 20 or whatever that other number was. Any idea how I can fix the shop function because I tried it and I bought the most expensive weapon at the beginning of the game so something's definitely wrong.

The problem in the store is the mixing of assignment and test operators. You must use == for comparison and = for assignment.

You have:

if z == 1:
        cost == 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w == 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"

It should be:

if z == 1:
        cost = 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w = 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"

Try that and see if it helps.

If you have all of the indenting right, I think that should be ok. If not, post the code along with the compiler error and we'll figure it out.

Okay thanks I figured it out. Now everything works right except for the HP resetting at the beginning of every battle. Here it is:

import random
w = 0
m = random.randrange(50)+1
cost = 0

#main
health = 150
ehealth = 50
money = 0

def Shop():
    global money
    weapon1 = "Steel Knuckles"
    weapon2 = "Knife"
    weapon3 = "Sword"
    weapon4 = "Gun"
    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.
     """
    z = input("Which weapon do you want?")
    if z == 1:
        cost = 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w = 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 2:
        cost = 30
        if money >= cost:
            print"You have bought",weapon2
            money = money - cost
            w = 2
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 3:
        cost = 100
        if money >= cost:
            print"You have bought",weapon3
            money = money - cost
            w = 3
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 4:
        cost = 300
        if money >= cost:
            print"You have bought",weapon4
            money = money - cost
            w = 4
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 5:
        cost = 1000
        if money >= cost:
            print"You have bought",weapon5
            money = money - cost
            w = 5
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == "exit":
        mode = "restart"

def eAttack():
    attacke = random.randrange(15)+1
    return attacke
    if mode = "restart":
        health = 100

def HP():
    e = eAttack()
    global health
    health = health - e
    print"Your HP is",health
    if mode = "restart":
        health = 150

def Gold():
    global money

def nAttack():
    attack = random.randrange(10)+1
    return attack
    if w = 1:
        attack = random.randrange(20)+1
    elif w = 2:
        attack = random.randrange(25)+1
    elif w = 3:
        attack = random.randrange(30)+1
    elif w = 4:
        attack = random.randrange(45)+1
    elif w = 5:
        attack = random.randrange(60)+1
    

def EnemyHP():
    n = nAttack()
    global ehealth
    ehealth = ehealth - n
    print "Monster's HP is",ehealth
    if mode = "restart":
        ehealth = 100

monster = 0

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?: ")
    if mode == "shop":
        Shop()


    while mode == "battle":
        fight = random.randrange(10)+1
        if fight == 1:
            monster = "Dragon!"
        elif fight == 2:
            monster = "Wild Cayote!"
        elif fight == 3:
            monster == "Jaguar!"
        elif fight == 4:
            monster = "Orc Lord!"
        elif fight == 5:
            monster = "Goblin!"
        elif fight == 6:
            monster = "Crazy Robot!"
        elif fight == 7:
            monster = "Werewolf!"
        elif fight == 8:
            monster = "Vampire!"
        elif fight == 9:
            monster = "Giant Spider!"
        elif fight == 10:
            monster = "Pirate King"
        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"
        elif ehealth <= 0:
            print "You win the battle! You earn",m,"$!"
            money = money + m
            mode = "restart"


    if mode == "exit":
        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.")

Also I need to know of I can add images linked to a site whenever the battle mode is activated. I've been making these quick pictures in paint while trying to figure out the coding and I was bored. There are pictures of the 6 weapons and 3/10 monsters so far.

I think you should just make a reset heath function

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?: ")
    if mode == "shop":
        Shop()


    while mode == "battle":
        fight = random.randrange(10)+1
        if fight == 1:
            monster = "Dragon!"
        elif fight == 2:
            monster = "Wild Cayote!"
        elif fight == 3:
            monster == "Jaguar!"
        elif fight == 4:
            monster = "Orc Lord!"
        elif fight == 5:
            monster = "Goblin!"
        elif fight == 6:
            monster = "Crazy Robot!"
        elif fight == 7:
            monster = "Werewolf!"
        elif fight == 8:
            monster = "Vampire!"
        elif fight == 9:
            monster = "Giant Spider!"
        elif fight == 10:
            monster = "Pirate King"
        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"
        elif ehealth <= 0:
            print "You win the battle! You earn",m,"$!"
            money = money + m
            resetHP()

def resetHP():
    global health
    heath = 150

Also this code is dying to be put into a class.

My python isn't working at the moment and I gotta get to school so I can't check if the resetHP function is, well, functioning right. Here it is:

import random
w = 0
m = random.randrange(50)+1
cost = 0

#main
health = 150
ehealth = 50
money = 0

def Shop():
    global money
    weapon1 = "Steel Knuckles"
    weapon2 = "Knife"
    weapon3 = "Sword"
    weapon4 = "Gun"
    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.
     """
    z = input("Which weapon do you want?")
    if z == 1:
        cost = 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w = 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 2:
        cost = 30
        if money >= cost:
            print"You have bought",weapon2
            money = money - cost
            w = 2
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 3:
        cost = 100
        if money >= cost:
            print"You have bought",weapon3
            money = money - cost
            w = 3
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 4:
        cost = 300
        if money >= cost:
            print"You have bought",weapon4
            money = money - cost
            w = 4
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 5:
        cost = 1000
        if money >= cost:
            print"You have bought",weapon5
            money = money - cost
            w = 5
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == "exit":
        mode = "restart"

def eAttack():
    attacke = random.randrange(15)+1
    return attacke
    if mode == "restart":
        health = 100

def HP():
    e = eAttack()
    global health
    health = health - e
    print"Your HP is",health
    if mode == "restart":
        health = 150

def Gold():
    global money

def nAttack():
    attack = random.randrange(10)+1
    return attack
    if w == 1:
        attack = random.randrange(20)+1
    elif w == 2:
        attack = random.randrange(25)+1
    elif w == 3:
        attack = random.randrange(30)+1
    elif w == 4:
        attack = random.randrange(45)+1
    elif w == 5:
        attack = random.randrange(60)+1
    

def EnemyHP():
    n = nAttack()
    global ehealth
    ehealth = ehealth - n
    print "Monster's HP is",ehealth
    if mode == "restart":
        ehealth = 100

def resetHP():
    global health
    health = 150

def resetEnemyHP():
    global health
    health = 150

monster = 0

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?: ")
    if mode == "shop":
        Shop()

    if mode == "battle":
        print"You have encountered a,"monster,"What will you do?"
    while mode == "battle":
        fight = random.randrange(10)+1
        if fight == 1:
            monster = "Dragon!"
        elif fight == 2:
            monster = "Wild Cayote!"
        elif fight == 3:
            monster == "Jaguar!"
        elif fight == 4:
            monster = "Orc Lord!"
        elif fight == 5:
            monster = "Goblin!"
        elif fight == 6:
            monster = "Crazy Robot!"
        elif fight == 7:
            monster = "Werewolf!"
        elif fight == 8:
            monster = "Vampire!"
        elif fight == 9:
            monster = "Giant Spider!"
        elif fight == 10:
            monster = "Pirate King!"
        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"
            resetHP()
            resetEnemyHP()
        elif ehealth <= 0:
            print "You win the battle! You earn",m,"$!"
            money = money + m
            mode = "restart"
            resetHP()
            resetEnemyHP()
            


    if mode == "exit":
        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.")

Also I've been thinking... would a Levels and Experience-Gaining system function work or would that be too hard?

Well the game's coming along pretty nicely but I need a way to fix that HP resetting function, and I need to add pictures and the save option. Looks like it'll be done in about a couple weeks if I use my weekend time.

You can put the health reset in the main loop, just before the battle loop starts. You'll reset it more than you need to, but everyone will be full health when the battle starts.

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?: ")
    if mode == "shop":
        Shop()

    # reset health here

    while mode == "battle":
        fight = random.randrange(10)+1

In order to get pictures on the screen, you're going to have to change the program a lot. You need to use one of the python gui models to run your application and they run a lot differently than you have been so far. (I saw your other gui thread. I have used both wxPython and tkInter to fairly good success, you'll have to pick one.)

The 'save' feature is something you'll have to work on as well. First step is to decide what it is that you want to save. We don't have one yet, but does the player have a name? They have gold and a weapon, is that what we save? Do we want to keep some form of battle statistics and save them?

The basic file concepts (from your 'how do I save' thread) are how you get data into and out of the file. How your application interfaces to the files is up to you, but I recommend something like this:

  • Set variables to the default value
  • Check for the save file
  • If the save file exists, update the variables from the file

To get the save file created, the application either needs to do saves from time to time (oh, like whenever they complete a battle or shop at the store) or just save when the program exits.

So then if someone's playing this game they can save it on their hard drives? But first before that, I need to work on a Levels function so there would actually be something to save, and the Images will probably have to wait for now because I need to learn wxPython first. Thanks for the tip on adding the HP reset to the main loop.

Can someone help me with the levels function? The xp gaining thing doesn't seem to work properly. Here it is:

import random
w = 0
level = 1
m = random.randrange(50)+1+level*5
cost = 0
xp = 0


def LVL():
    global level
    global xp
    if level == 1:
        tnl = 100
        if tnl <= xp:
            level = 2
            xp = 0
            print"Your new Level is",level,"! Congratulations!"

    if level == 2:
        tnl = 250
        if tnl <= xp:
            level = 3
            xp = 0
            print"Your new Level is",level,"! Congratulations!"
            
            if level == 3:
                tnl = 450
                if tnl <= xp:
                    level = 4
                    xp = 0
                    print"Your new Level is",level,"! Congratulations!"

                    if level == 4:
                        tnl = 650
                        if tnl <= xp:
                            level = 5
                            xp = 0
                            print"Your new Level is",level,"! Congratulations!"

                            if level == 5:
                                tnl = 900
                                if tnl <= xp:
                                    level = 6
                                    xp = 0
                                    print"Your new Level is",level,"! Congratulations!"

                                    if level == 6:
                                        tnl = 1200
                                        if tnl <= xp:
                                            level = 7
                                            xp = 0
                                            print"Your new Level is",level,"! Congratulations!"

                                            if level == 7:
                                                tnl = 1550
                                                if tnl <= xp:
                                                    level = 8
                                                    xp = 0
                                                    print"Your new Level is",level,"! Congratulations!"

                                                    if level == 8:
                                                        tnl = 1950
                                                        if tnl <= xp:
                                                            level = 9
                                                            xp = 0
                                                            print"Your new Level is",level,"! Congratulations!"

                                                            if level == 9:
                                                                tnl = 2400
                                                                if tnl <= xp:
                                                                    level = 10
                                                                    xp = 0
                                                                    print"Your new Level is",level,"! Congratulations!"

                                                                    if level == 10:
                                                                        tnl = 2900
                                                                        if tnl <= xp:
                                                                            level = 100
                                                                            xp = 0
                                                                            print"Your new Level is",level,"! Congratulations!"
                                                                            print"Congratulations, you beat the Demo!"
    



#main
health = 150
ehealth = 50
money = 0
level = 1

def Shop():
    global money
    weapon1 = "Steel Knuckles"
    weapon2 = "Knife"
    weapon3 = "Sword"
    weapon4 = "Gun"
    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.
     """
    z = input("Which weapon do you want?")
    if z == 1:
        cost = 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w = 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 2:
        cost = 30
        if money >= cost:
            print"You have bought",weapon2
            money = money - cost
            w = 2
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 3:
        cost = 100
        if money >= cost:
            print"You have bought",weapon3
            money = money - cost
            w = 3
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 4:
        cost = 300
        if money >= cost:
            print"You have bought",weapon4
            money = money - cost
            w = 4
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == 5:
        cost = 1000
        if money >= cost:
            print"You have bought",weapon5
            money = money - cost
            w = 5
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"
    elif z == "exit":
        mode = "restart"

def eAttack():
    attacke = random.randrange(10)+level
    return attacke
    if mode == "restart":
        health = 100

def HP():
    e = eAttack()
    global health
    health = health - e
    print"Your HP is",health
    if mode == "restart":
        health = 150

def Gold():
    global money

def nAttack():
    attack = random.randrange(10)+level*5
    return attack
    if w == 1:
        attack = random.randrange(10)+20+level*5
    elif w == 2:
        attack = random.randrange(10)+35+level*5
    elif w == 3:
        attack = random.randrange(10)+55+level*5
    elif w == 4:
        attack = random.randrange(10)+80+level*5
    elif w == 5:
        attack = random.randrange(10)+110+level*5


def EnemyHP():
    n = nAttack()
    global ehealth
    ehealth = ehealth - n
    print "Monster's HP is",ehealth
    if mode == "restart":
        ehealth = 100

def resetHP():
    global health
    health = 150
    global ehealth
    health = 100

monster = "Giant Python!"

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?: ")
    if mode == "shop":
        Shop()
        
    if mode == "battle":
        print"You have encountered a",monster,"What will you do?"
        health = 150+level*100
        ehealth = 100+level*125
        m = random.randrange(50)+1+level*5
        xpGain = random.randrange(25)+level+25
        xp = xpGain + xp
        LVL()
    while mode == "battle":
        fight = random.randrange(10)+1
        if fight == 1:
            monster = "Dragon!"
        elif fight == 2:
            monster = "Wild Cayote!"
        elif fight == 3:
            monster == "Jaguar!"
        elif fight == 4:
            monster = "Orc Lord!"
        elif fight == 5:
            monster = "Goblin!"
        elif fight == 6:
            monster = "Crazy Robot!"
        elif fight == 7:
            monster = "Werewolf!"
        elif fight == 8:
            monster = "Vampire!"
        elif fight == 9:
            monster = "Giant Spider!"
        elif fight == 10:
            monster = "Pirate King!"
        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"
            resetHP()
        elif ehealth <= 0:
            print "You win the battle! You earn",m,"$!"
            money = money + m
            mode = "restart"
            resetHP()
            m = random.randrange(50)+1+level*5
            xpGain = random.randrange(25)+level+25
            xp = xpGain + xp
            LVL()
            print"You gain",xpGain,"Experience Points!"
            


    if mode == "exit":
        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.")

I would suggest this

tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]

def LVL():
    global level, xp
    if 1 <= level <= len(tnls):
        tnl = tnls[level-1]
        if tnl <= xp:
            level += 1
            if level > len(tnls):
                level = 100
            xp = 0
            print("Your new level is %d! Congratulations!" % level)
    if level == 100:
        print("Congratulations, you beat the Demo!")

you didn't want to keep indenting each new 'if level' test

They should all be at the same indent level, like if level == 1 and if level == 2 are.

(I had typed the following and thought I had posted it, but apparently not...here it is anyway)

Have you ever heard of an array or a list?

If you had a data structure that contained (or was indexed by) the level and the 'tnl' value, the LVL() function could have been implemented with a loop instead of 10 levels or if's with almost identical code that follows each of them. What do you plan to do in the 'official' version when there are more than 10 levels?

I tend to think about XP as always increasing. In my world, XP from 0 to 99 is level 1. XP from 100 to 349 would be level 2, XP 350-799 is level 3...etc.

So if I was at 97 XP and killed a monster worth 20 XP, I could be at 117 XP in level 2 instead of level 2 with zero XP. (Granted that even in your model, instead of setting XP back to zero, you just subtracted the old tnl value you would get the same result.

PS- your player attack function:

def nAttack():
    attack = random.randrange(10)+level*5
    return attack
    if w == 1:
        attack = random.randrange(10)+20+level*5
    elif w == 2:
        attack = random.randrange(10)+35+level*5
    elif w == 3:
        attack = random.randrange(10)+55+level*5
    elif w == 4:
        attack = random.randrange(10)+80+level*5
    elif w == 5:
        attack = random.randrange(10)+110+level*5

Is still not using any new weapon calculations. (The return on line 3 causes the remaining code to be ignored.) The return should be at the end.

def nAttack():
    attack = random.randrange(10)+level*5
    if w == 1:
        attack = random.randrange(10)+20+level*5
    elif w == 2:
        attack = random.randrange(10)+35+level*5
    elif w == 3:
        attack = random.randrange(10)+55+level*5
    elif w == 4:
        attack = random.randrange(10)+80+level*5
    elif w == 5:
        attack = random.randrange(10)+110+level*5
    return attack

Also, the whole shopping sequence could be shortened using a list of shop items like this for example

shop_items = [
    ("Steel Knuckles", 20),
    ("Knife", 30),         
    ("Sword", 100),        
    ("Gun", 300),          
    ("Rocket Launcher", 1000),
    ]                         

def shop_menu_lines():
    yield ''          
    yield "What'll it be ?"
    for index, pair in enumerate(shop_items):
        yield "%d - %s %d$" % (index+1, pair[0], pair[1])
    yield "Type exit to quit"                            

def shop_menu():
    return "\n    ".join(shop_menu_lines())

def Shop():
    global money, mode, w
    print(shop_menu())   
    z = raw_input("Which weapon do you want ?")
    if z == "exit":
        mode = "restart"
    else:
        try:
            z = int(z)
        except ValueError:
            z = -1
        if 1 <= z <= len(shop_items)
            weapon, cost = shop_items[z-1]
            if money >= cost:
                print("You have bought a %s" % weapon.lower())
                money -= cost
                w = z
            else:
                print("You don't have enough gold to buy a %s." % weapon.lower())
                raw_input("press [enter] to exit.")
                mode = "restart"
        else:
            z = -1
        if z < 0:
            print("Invalid choice")

For now, the Official Game is still some ways away, so this 10 level cap will be good. For the official game, there'll be an unlimited amount of levels and Higher damaging, more expensive weapons so the battles don't take hours (And trust me, they take hours if you're Level 100, I tried it). The TNL (to next level) of each level will be tnl+level*50, so for the first level, you'd have a 50 tnl, second level 150, third level 300 (It goes up from 0 by the previous TNL added to 50 times the level, so you can imagine it'll get really hard as you level up). And after it all works well, I'll work on a new function called 'Locations' (certain locations [such as a mansion or a circus or something with new enemies] will open up as you level up). It'll keep people playing (since it'll now save and they won't have to restart from level 1 every time) the game like it's a hobby instead of a 'minigame' if you will. Man it sure took long to type this. I wonder if you read it all. If you did, I'll give you a reputation, just ask me for one :).

Ugh and I don't even know how I'm gonna incorporate the pictures in all this. I might as well leave the images until I'm a better Python User. G'night folks, sleep tight, don't let the pythons bite.

Just as a side note, you could make the game a lot easier (potentially faster too) if you would let the user select things by number.

For example when selecting "battle" "shop" or "exit" if the menu was:

Available options:
    1 - Battle
    2 - Shop
    3 - Exit
What would you like to do?

The user could enter '1', '2' or '3' instead of having to type out the whole word.

The same could be applied to the battle sequence.

But even better, might be some way to more automate the battle...something like 'auto-attack' that would keep attacking until the monster was dead or you died. (Maybe you could work out a way for the player to make some input into the battle while it was in-progress?)

In my sample play, I don't believe I have ever been killed by a monster. Especially not after I upgraded my weapons.

Oh...another usability item...when you open the shop, it would be nice to tell them which weapon they're using and how much money they have so they would know what they could afford and which weapons would be an upgrade to the weapon they have.

The basic weapons are gonna need to be pimped out because the enemy's HP is gonna sky rocket was past your at the later levels. And there'll be new weapons with the new locations, and there'll be monsters with higher level then you (for example, a monster with your level + 5 or 10 so they're harder to kill and you'd need weapon upgrades.

Oh yeah and the numbers thing. I've thought about it before but I forgot to put them in. The game also needs attack spells or healing spells during a battle, and it needs armor, which I've already got an idea for(Armor = 25, defence = random.randrange(10)+Armor or another number, EnemyAttack - defence = EnemyAttack).

I simply find this thread amazing, almost 200,000 views. It is now the top viewed python thread, beating second by almost 50 000 views. Im dumfounded how this works.. some google search i think must be leading here. Or norbert has 200 000 friends :)

I simply find this thread amazing, almost 200,000 views. It is now the top viewed python thread, beating second by almost 50 000 views. Im dumfounded how this works.. some google search i think must be leading here. Or norbert has 200 000 friends :)

Yep it's the last one. ;)

I've check a bunch of google searches and if you search Python Game, Python Quest, Norbert Quest, or anything else similar to this (Including Python Levels) all leads here to Daniweb.com/NorbertQ. It's usually the first thing listed, or close to the top.

EDIT: Ugh nevermind that last one, and the first one. It's been overshadowed by Monty Python and the Quest for the Holy Grail Game searches. Other's are good though.

I need help. I couldn't really figure out that self thing you told me so I put self.variable in all the variables and it won't work. Here's the latest NorbertQuest (by the way I need a better name still):

class NorbertQuest(object):
    import self
    import random
    self.w = 0
    self.level = 1
    self.m = random.randrange(50)+1+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

    tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]

    def LVL():
        if 1 <= level <= len(tnls):
            tnl = tnls[level-1]
            if tnl <= xp:
                level += 1
                if level > len(tnls):
                    level = 100
                xp = 0
                print("Your new level is %d! Congratulations!" % level)
        if 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",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",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",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()

I keep getting this error:

Traceback (most recent call last):
  File "C:\Documents and Settings\taf\My Documents\Norbert Quest RPG v1", line 2, in <module>
    class NorbertQuest(object):
  File "C:\Documents and Settings\taf\My Documents\Norbert Quest RPG v1", line 4, in NorbertQuest
    self.w = 0
NameError: name 'self' is not defined

Ah what you have to do is have an __init__ method, this is a method that runs when the class is instantiated (when you make a variable of it)

import random
class NorbertQuest(object):
    
    def __init__(self):
        self.w = 0
        self.level = 1
        self.m = random.randrange(50)+1+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

    tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]

    def LVL():
        if 1 <= level <= len(tnls):
            tnl = tnls[level-1]
            if tnl <= xp:
                level += 1
                if level > len(tnls):
                    level = 100
                xp = 0
                print("Your new level is %d! Congratulations!" % level)
        if 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",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",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",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()

Oh and in all your functions self needs to be the first argument.

def this(self):
    #do stuff

#rather than
def this():
    #do stuff

When in a class the self argument is given automatically so when calling it you still only need to supply the ones you specify

class Test(object):
    def printforme(self, pr):
        print pr

t = Test()
t.printforme("hello")#notice i dont need to worry about self?

Hope that helps you out

I'm still getting an error. Maybe I did something wrong?

import random
class NorbertQuest(object):

    
    def __init__(self):
        self.w = 0
        self.level = 1
        self.m = random.randrange(50)+1+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[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!" % se.flevel)
        if se.flevel == 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",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",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()
This article has been dead for over six months. Start a new discussion instead.