Commit 647e9df4 by BellCodeEditor

save project

parent 2cedcf19
Showing with 12 additions and 3 deletions
...@@ -5,11 +5,19 @@ class Hero(object): ...@@ -5,11 +5,19 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(self,attack,hp):
def combat(self,enemy):
enemy.hp -=self.attack
b1=self.name+"对"+enemy.name+"发起了攻击 "
b2="造成了"+str(self.attack)+"点伤害 "
if enemy.hp > 0:
b3="还剩"+str(enemy.hp)+"点血量 "
else:
b3=enemy.name+"阵亡 你赢辣!!!!!!!!!!!!!!!!!!!!!!!!!!"
c=b1+b2+b3
print(c)
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) yase.combat(houyi)
\ No newline at end of file
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