ですから、なぜそれが起こっているのかよくわからないという問題があります。武器クラスにあるはずのときに (Name Error global variable "value" is not defined) を取得します。
from items import *
class weapons(Item):
def __init__(self, name, attack_damage, lifesteal = 0):
super(weapons,self).__init__(name, value, quantity=1)
self.attack_damage = attack_damage
self.lifesteal = lifesteal
これは、すでに値が定義されている武器が取得するクラスです。
class Item(object):
def __init__(self, name, value, quantity=1):
self.name = name
self.raw = name.replace(" ","").lower()
self.quantity = quantity
self.value = value
self.netValue = quantity * value
def recalc(self):
self.netValue = self.quantity * self.value
私はすでにこれに似たコードを持っていますが、何らかの理由でこの値のエラーが発生しています。私はそれを含めるつもりです。
from character import*
class player(character):
def __init__(self,name,hp,maxhp,attack_damage,ability_power):
super(player,self).__init__(name, hp, maxhp)
self.attack_damage = attack_damage
self.ability_power = ability_power
プレーヤーがその要素を取得しているクラス
class character(object):
def __init__(self,name,hp,maxhp):
self.name = name
self.hp = hp
self.maxhp = maxhp
def attack(self,other):
pass
ご覧のとおり、ここで実行しました。プレーヤーを呼び出すと、このコードが機能します。