Commit 255b130a by BellCodeEditor

save project

parent 9a581ef4
Showing with 14 additions and 5 deletions
...@@ -6,9 +6,19 @@ class Hero(object): ...@@ -6,9 +6,19 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(): # 攻击 def combat(self,e):
??? e.hp-=self.attack
i1=self.name_+"打"+e.name
i2="造成"+str(self.attack)
if e.hp>0:
i3=e.name+"剩"+str(e.hp)
i=i1+i2+i3 # 攻击
print(i)
else:
print(e.name+"死了")
i=i1+i2+i3
print(i)
exit()
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