Commit 514ce68c by BellCodeEditor

save project

parent 9a581ef4
Showing with 13 additions and 4 deletions
......@@ -5,10 +5,18 @@ class Hero(object):
self.hp = 250
self.attack = 40
self.name = name
def combat(): # 攻击
???
self.max_hp=self.hp
def combat(self,other): # 攻击
other.hp-=self.attack
a=self.name+"对"+other.name+"发动攻击!"
b="造成"+str(self.attack)+"点伤害"
if other.hp>0:
c=other.name+"还剩"+str(other.hp)+"血量"
print(a+b+c)
else:
c=other.name+"ko,the end"
print(a+b+c)
exit()
yase = Hero("垭瑟")
houyi= Hero("后羿")
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