码迷,mamicode.com
首页 > 其他好文 > 详细

组内混战第一步

时间:2018-08-01 18:21:14      阅读:185      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!