Commit 02a6741f by BellCodeEditor

save project

parent e731896d
Showing with 18 additions and 14 deletions
class Hero: class Hero:
def __init__(self, name): def __init__(self, name,herotype):
self.name = name self.name = name
self.level = 8670986985 self.level = 1
self.hp = 99999999999999999999999999 self.hp = 250
self.attack = 9876573874 self.attack = 40
self.max_hp = self.hp 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): def combat(self, enemy):
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
...@@ -21,13 +25,14 @@ class Hero: ...@@ -21,13 +25,14 @@ class Hero:
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
exit() exit()
class Player():
def __init__(self,name):
player = Player("后羿") yase = Hero("亚瑟","坦克")
print("玩家的血量值为:",player.hp) houyi = Hero("后羿","射手")
print("玩家的攻击力为:",player.attack) houyi.combat(yase)
\ No newline at end of file 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