Commit a17de1fb by BellCodeEditor

save project

parent 98ecc43c
Showing with 29 additions and 15 deletions
# 英雄角色类 class Hero:
class Hero(object): def __init__(self,name):
def __init__(self, name): self.hp=240
self.level = 1 self.gj=40
self.hp = 250 self.name=name
self.attack = 40 def combad(self,enemy):
self.name = name enemy.hp-=self.gj
info1=self.name+"对"+enemy.name+"发起进攻"
def combat(): # 攻击 info2="造成"+str(self.gj)+"点伤害"
??? if enemy.hp>0:
info3=enemy.name+"还剩下"+str(enemy.hp)+"点血量"
yase = Hero("垭瑟") info=info1+info2+info3
houyi= Hero("后羿") print(info)
yase.combat(houyi) else:
\ No newline at end of file info3=enemy.name+"阵亡,游戏结束"
info=info1+info2+info3
print(info)
exit()
class Player():
def __init__(self,name,hero_type):
super().__init__(name)
self.hp=200
self.gj=80
self.hero_type=hero_type
Player=Player("后羿")
yase=Hero("亚瑟")
houyi=Hero("后羿")
yase.combad(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