How can I access a variable from another class that is not inherited? In my code I am trying to access the hitPoints
class variable from the Dragon
object with the Ranger
object in the quickShot
method.
class Dragon(object):
name = "Dragon"
hitPoints = 25
# Create the Ranger class
class Ranger(object):
name = "Ranger"
attack = 80
defence = 50
hitPoints = 100
def __init__(self):
self = self
def quickShot(self):
damage = 25
test = random.random()
if test < .8:
#I cannot access the dragon's hitPoints
Dragon.hitPoints = Dragon.hitPoints - damage
else:
pass
def concentratedShot(self):
damage = 50
chance = random.random()
if chance <= .5:
chance = True
else:
chance = False
def heartSeeker(self):
damage = 100
chance = random.random()
if chance <= .3:
chance = True
else:
chance = False