Sorry wait, that only solves half of the problem. The thing i only just spotted was that you go Monster.__init__. That then means that all of Monsters methods will now be stored in self. So you can call self.getAttributesInfo
But the problem with that is there are two methods called self.getAttibutesInfo
One is in the Orc and Troll classes and the other is in the Monster class so then we have to change the name of one of them to make sure that the program does not call the method over and over and over.
I fiddled with the code and here is what i got:
#!/usr/bin/env python
import random
choice = 0
class weapon(object):
def _init_(self, attack, defense):
self.attack = self.attack
defense = self.defense
def getAttributesInfo(self):
attributes = ['Attack:' + self.attack,
'Defense:' + self.defense]
return ' '.join(attributes)
class sword(weapon):
def _init_(self):
wepon._init_(self, random.randrange(1,3), random.randrange(1,3))
def getAttributesInfo(self):
weapon.getAttributesInfo()
class axe(weapon):
def _init_(self):
weapon._init_(self, random.randrange(1,5), random.randrange(1,5))
print 'This Axe\'s Attributes are:'
print 'Attack:' + self.attack
print 'Defense:' + self.defense
def getAttributesInfo(self):
weapon.getAttributesInfo()
class player():
def _init_(self):
self.health = 10
self.defense = 4
self.base_attack = 3
self.attacking = 1
def weapon(self):
self.weapon = random.range(1,2)
if self.weapon == 1:
self.weapon = sword()
print "you got a sword."
elif self.weapon == 2:
self.weapon = axe()
print "you got an axe."
def attack(Monster):
if not self.attacking == 1:
self.attacking = 1
if self.weapon.attack > monster.defense:
hit = True
monster.health = monster.health - self.weapon.damage
print 'You hit him for ' + self.damage + 'damage!' …