Hey guys... im new to programming and I decided to try Python. So far so good, I've been reading and all making progress. I decided to write a stupid text game just to test how i was doing. Well, I get this error when i run it (not complete just testing it and doing it as i go):
Traceback (most recent call last):
File "C:\WINDOWS\Desktop\testing.py", line 67, in -toplevel-
battle()
File "C:\WINDOWS\Desktop\testing.py", line 32, in battle
monster()
TypeError: 'int' object is not callable
This is the code i have so far:
import random
life = ""
attack = ""
monster_life = ""
monster_attack = ""
first = ""
gold = ""
choice = ""
items = ""
def battle():
monster = random.randrange(3)
if monster == 0:
print "Oh no! It's Godzilla!"
monster_life = 40
monster_attack = 10
elif monster == 1:
print "Oh... the unholy Werewolf!"
monster_life = 50
monster_attack = 15
elif monster == 2:
print "The dead walketh: tis a Vampere!"
monster_life = 55
monster_attack = 17
elif monster == 3:
print "The childrens nightmare... the BOOGEY MAN!"
monster_life = 60
monster_attack = 22
first = random.randrange(2) #defines who attacks first
if first == 0:
hero()
elif first == 1:
monster()
while (life > 0) or (monster_life > 0):
hero()
monster()
gold += 100
def hero():
print \
"""
To Attack hit a
To use a life potion hit l
"""
choice = raw_input("please choose what to do: ")
if choice == "a":
monster_life += -attack
elif choice == "l":
life += 50
def monster():
life += -monster_attack
print "\t\tWelcome to Monster"
name = raw_input("Please enter your characters's name: ")
print "Welcome", name,"!"
life = 100
attack = 25
items = ("sword",
"life potion",
"shield",
"poison")
gold = 200
print "To start with you have" , items,"in your inventory."
print "As you progress through the game you can earn money and buy items at the Shop."
print "Are you ready?"
raw_input("Hit 'Enter' to continue on your quest.")
battle()
I know that it's probably really shoddy coding, but im new and just trying to learn. If any one could help me find my problem, I would really appreciate it. Any suggestions are welcome.