标签:super code style color 战斗力 exp sel pre use
1 class Public_1: 2 def __init__(self,name,hp,exp,ce,sex = "男"): 3 self.user = name 4 self.hp = hp #血量值 5 self.exp = exp #经验值(伤害叠加) 6 self.ce = ce #战斗力(次数) 7 self.sex = sex 8 9 class Public_2: 10 def __init__(self,ad,price): 11 self.ad = ad #攻击力 12 self.price = price 13 14 class Greatgod(Public_1,Public_2): 15 """ 组内混战,天神A队""" 16 def __init__(self,name,hp,ad,exp,ce,fy,price,sex = "男"): 17 self.fy = fy #防御力 18 super(Greatgod, self).__init__(name, hp, exp, ce, sex) 19 Public_2.__init__(self,ad, price) 20 21 def attack_god(self, rookie): 22 rookie.hp -= self.ad 23 print("%s还有血量%s" % ("jia",jia.hp)) 24 25 class Rookie(Public_1,Public_2): 26 """ 组内混战,菜鸟B队""" 27 def __init__(self,name,hp,ad,exp,ce,dk,price,sex = "男"): 28 self.dk = dk # 29 #super(Rookie,self).__init__(name,hp,exp,ce,sex) 30 Public_1.__init__(self, name,hp,exp,ce,sex) 31 Public_2.__init__(self, ad, price) 32 def attack_rook(self,greatgod): 33 greatgod.hp -= self.ad 34 print("%s还有血量%s" % ("wu", wu.hp)) 35 36 class God_dragon(Public_2): 37 """ 神龙在天""" 38 def dragon(self,name): 39 name.hp -= 50 40 self.price -= 998 41 #实例化两个对象 42 #name名字 hp血量 exp经验值(伤害叠加) ce战斗力(次数) fy防御 price钱 43 jia = Greatgod(name="贾",hp=100,ad=10,exp=10,ce=5,fy=1,price=1000) 44 #name名字 hp血量 exp经验值(伤害叠加) ce战斗力(次数) dk防御 price钱 45 wu = Rookie(name="武",hp=100,ad=10,exp=10,ce=50,dk=1,price=1000) 46 47 #实例化两个武器 48 jia.dr = God_dragon(jia.ad,jia.price) 49 50 jia.dr.dragon(wu) 51 wu.attack_rook(jia) 52 jia.attack_god(wu) 53 print(jia.hp) 54 print(wu.hp)
标签:super code style color 战斗力 exp sel pre use
原文地址:https://www.cnblogs.com/pupilheart/p/9093455.html