Commit c28a2893 by BellCodeEditor

save project

parent 1752bb84
Showing with 18 additions and 7 deletions
...@@ -5,7 +5,7 @@ class Hero(object): ...@@ -5,7 +5,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
m1 =print(self.name+"对"+enemy.name+"发起攻击") m1 =print(self.name+"对"+enemy.name+"发起攻击")
m2 =print("并造成"+str(self.attack)+"单位伤害") m2 =print("并造成"+str(self.attack)+"单位伤害")
...@@ -17,14 +17,26 @@ class Hero(object): ...@@ -17,14 +17,26 @@ class Hero(object):
m3=enemy.name+"已死亡" m3=enemy.name+"已死亡"
print(m1+m2+m3) print(m1+m2+m3)
yase = Hero("垭瑟")
#yase = Hero("垭瑟")
class Player(Hero): class Player(Hero):
def __init__(self,name): def __init__(self,name,herotype):
super().__init__(name) super().__init__(name)
self.hp = 200 self.hp = 200
self.attack = 50 self.attack = 50
self.herotype = herotype
print("运行角色 OK,玩家"+self.name+" 已创建")
print("当前血量/攻击值:"+str(self.hp)+"/"+str(self.attack)+"\n"+"- "*15)
player=Player("后羿")
print("玩家血量值:",player.hp) class Cpt(Player):
print("玩家血量值:",player.attack) def __init__(self,name,herotype):
\ No newline at end of file super().__init__(name,herotype)
self.herotype = herotype
print("运行程序 OK,电脑"+self.name+" 已生成")
print("设置血量/攻击值为 "+str(self.hp)+"/"+str(self.attack)+"\n"+"- "*15)
player=Player("后羿","射手")
computer=Cpt("垭瑟","None")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment