Commit 6a0a3d9c by BellCodeEditor

save project

parent 9a581ef4
Showing with 11 additions and 5 deletions
......@@ -6,9 +6,16 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,bei): # 攻击
bei.hp=bei.hp-self.attack
born1=self.name+"对"+bei.name+"发起了攻击"
born2="造成了"+str(self.attack)+"点伤害"
if bei.hp>0:
born3=self.name+"还剩下"+str(bei.hp)+"点血量"
else:
born3=bei.name+"已阵亡,游戏结束"
born=born1+born2+born3
print(born)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
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