Commit 179b76b6 by BellCodeEditor

save project

parent 21a66946
Showing with 21 additions and 4 deletions
......@@ -6,9 +6,27 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enermy): # 攻击
enermy.hp-=self.attack
if enermy.hp>0:
info1=self.name+"对"+enermy.name+"发动了攻击\n"
info2=enermy.name+"血量降低了"+str(self.attack)+"\n"
info3=enermy.name+"还剩余"+str(enermy.hp)+"血\n"
print(info1+info2+info3)
else:
info1=self.name+"对"+enermy.name+"发动了攻击\n"
info2=enermy.name+"血量降低了"+str(self.attack)+"\n"
info3=enermy.name+"还剩余"+str(enermy.hp)+"血\n"
print(info1+info2+info3)
print(enermy.name+"嗝屁了")
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
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