Class Attributes Not Passing To Objects
I'm trying to create a very basic RPG-like game where you select a character, give that character a weapon, and then tell it to attack another character with damage based on the st
Solution 1:
Remember to use self
, as in your other __init__
methods, to make attributes of the instance.
def__init__(self, name):
self.name = name
self.hp = 300
...
self.weapon = None
Also, I think the other attributes should also be instance attributes, i.e., set them in the __init__
methods and use self
, e.g. self.wgt
, self.impact
, self.broken_bones
, etc.
Post a Comment for "Class Attributes Not Passing To Objects"