如何创建一个更短的参数的基类

时间:2018-01-06 14:47:49

标签: python class

我的课程是:

class Champion:

    def __init__(self, secondary_bar, secondary_attributes, health, health_reg, mana, mana_reg, c_range, att_damage, att_speed, armor, magic_res, move_speed):
        self.secondary_bar = secondary_bar 
        self.secondary_attributes = secondary_attributes
        self.health = health
        self.health_reg = health_reg
        self.mana = mana
        self.mana_reg = mana_reg
        self.c_range = c_range
        self.att_damage = att_damage
        self.att_speed = att_speed
        self.armor = armor
        self.magic_res = magic_res
        self.move_speed = move_speed

    ...


class SpecificChampion(Champion):

    ...


my_champ = SpecificChampion("mana", "melee", 500, 20, 250, 20, 125, 50, 0.8, 65, 65, 320)

我想要一种更短的方式来创建第一堂课,因为在我看来它需要太多的空间。我尝试使用kwargs将它们存储在列表中,但是访问它们并将它们作为参数传递给其他函数有点令人困惑。有什么建议吗?

0 个答案:

没有答案