Commit 6111a813 by BellCodeEditor

save project

parent 9a581ef4
Showing with 21 additions and 5 deletions
......@@ -6,9 +6,25 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
m1 =print(self.name+"对"+enemy.name+"发起攻击")
m2 =print("并造成"+str(self.attack)+"单位伤害")
enemy.hp-=self.attack
if enemy.hp>0:
m3=print(enemy.name+"血量剩余"+str(enemy.hp))
print(m1+m2+m3)
else:
m3=enemy.name+"已死亡"
print(m1+m2+m3)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp = 200
self.attack = 50
player=Player("后羿")
print("玩家血量值:",player.hp)
print("玩家血量值:",player.attack)
\ 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