我正在学习 python 并试图根据角色的热区编写一个伤口系统。这是我写的。不要过多评价我。
class Character:
def __init__ (self, agility, strength, coordination):
self.max_agility = 100
self.max_strength = 100
self.max_coordination = 100
self.agility = agility
self.strength = strength
self.coordination = coordination
def hit (self, hit_region, wound):
self.hit_region = hit_region
self.wound = wound
#Hit Zones
l_arm=[]
r_arm=[]
l_leg=[]
r_leg=[]
hit_region_list = [l_arm , r_arm, l_leg, r_leg]
#Wound Pretty Names
healthy = "Healthy"
skin_cut = "Skin Cut"
muscle_cut = "Muscle Cut"
bone_cut = "Exposed Bone"
hit_region.append(wound)
john = Character(34, 33, 33)
john.hit(l_arm, skin_cut)
我希望 skin_cut 输入被识别为“Skin Cut”,然后添加到我定义为列表的 l_arm。但是,我总是收到名称错误(未定义 l_arm)。如果我用'wound'作为第一个参数重写方法,名称错误现在带有未定义的'wound'。这告诉我这是我错过的课程结构中的一些东西,但我不知道是什么。