Commit b4b6cbb3 by BellCodeEditor

save project

parent 9a581ef4
Showing with 11 additions and 3 deletions
......@@ -6,9 +6,16 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,name2): # 攻击
name2.hp-=self.attack
a1=self.name+'对'+name2.name+'发起了攻击,'
a2=self.name+'造成了'+str(self.attack)+'点伤害,'
if name2.hp<0:
a3=name2+'阵亡。'
exit()
else:
a3=name2.name+'还剩下'+str(name2.hp)+'血量'
print(a1+a2+a3)
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