Commit ac047e40 by BellCodeEditor

save project

parent 9a581ef4
Showing with 13 additions and 4 deletions
......@@ -6,9 +6,18 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,emnry):
emnry.hp-=self.attack
if emnry.hp>0:
print(self.name,'对',emnry.name,'发起攻击,造成了',self.attack,'伤害')
print(emnry.name,'还剩下',emnry.hp,'血量')
else:
print(emnry.name,'阵亡,游戏结束。')
exit()
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
for i in range(6):
yase.combat(houyi)
houyi.combat(yase)
houyi.combat(yase)
\ 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