Commit 02a6741f by BellCodeEditor

save project

parent e731896d
Showing with 18 additions and 14 deletions
class Hero:
def __init__(self, name):
def __init__(self, name,herotype):
self.name = name
self.level = 8670986985
self.hp = 99999999999999999999999999
self.attack = 9876573874
self.level = 1
self.hp = 250
self.attack = 40
self.max_hp = self.hp
print("英雄"+self.name+"创建成功,"+"英雄类型:"+"\n")
self.herotype = herotype
def cure(self):
self.max_hp = self.max_hp + 60
if self.hp>250:
self.hp = self.max_hp
print(self.name+"使用了治疗术,血量增加:",str(60),"目前血量为",self.max_hp)
def combat(self, enemy):
info1 = self.name+"对"+enemy.name+"发起进攻,"
......@@ -23,11 +27,12 @@ class Hero:
exit()
class Player():
def __init__(self,name):
player = Player("后羿")
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack)
\ No newline at end of file
yase = Hero("亚瑟","坦克")
houyi = Hero("后羿","射手")
houyi.combat(yase)
yase.cure()
houyi.combat(yase)
yase.cure()
houyi.combat(yase)
yase.cure()
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