对于我要编写的游戏,我有这个严重的错误。目前,这只是骨头,我正在尝试为玩家战斗的敌人之一编码信息。
class Enemy():
def __init__(self):
super(). __init__ (
self.name = "Goblin" +
self.healthpoints = 12 + # on this line
self.damage = 3)
def isAlive(self):
return self.hp > 0
self.name = "Goblin" +
is a syntax error. You aren't adding anything to"Goblin"
. The reason it is complaining about the line after is that it is trying to addself.healthpoints = 12
to"Goblin"
and you can't add assignment statements.