Commit e2845e28 by BellCodeEditor

save project

parent 9a581ef4
Showing with 22 additions and 2 deletions
......@@ -6,9 +6,28 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
i1=print(self.name+'对'+enemy.name+'发起攻击')
i2=print('造成'+str(self.attack))
enemy.hp-=attack
if enemy.hp>0:
i3=print(enemy.name+'的血量还剩'+str(enemy.hp))
print(i1+i2+i3)
else:
i3=enemy.name+'已经阵亡,游戏结束!'
self.hp-=self.attack
class Player(Hero):
def__init__(self,name):
self.level = 1
self.hp = 200
self.attack = 50
self.name = name
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
print(houyi.hp)
\ 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