Commit 74ba26f7 by BellCodeEditor

save project

parent a30bde11
Showing with 41 additions and 28 deletions
class Hero: # 英雄类 class Sans:
def __init__(self, name): # 实例属性 def __init__(self,AT,HP,HUP,AUP,name):
self.name = name self.Level = 1
self.level = 1 self.HitPoint = HP
self.hp = 250 self.Attack = AT
self.attack = 40 self.HitPoint_UpPoint=HUP
self.max_hp = self.hp self.Attack_UpPoint=AUP
self.Name = name
def Level_UP(Character):
def combat(self, enemy): # 攻击功能 Character.Level+=1
info1 = self.name+"对"+enemy.name+"发起进攻," Character.HitPoint+=0.5*Character.HitPoint_UpPoint
info2 = "造成"+str(self.attack)+"点伤害," Character.Attack+=0.25*Character.Attack_UpPoint
enemy.hp -= self.attack print(str(Character.Name)+'升级了,现等级:'+str(Character.Level))
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量" def combat(self,diren): # 攻击
info = info1+info2+info3 diren.HitPoint-=self.Attack
print(info) DataA=str(self.Name)+'发起攻击,'
DataB=str(diren.Name)+'受到'+str(self.Attack)+'点伤害,'
DataC='现在'+str(diren.Name)+'有'+str(diren.HitPoint)+'滴血.'
if diren.HitPoint>=0:
print(DataA+DataB+DataC)
else: else:
info3 = enemy.name+"阵亡,游戏结束" print(str(diren.Name)+'阵亡,游戏结束')
info = info1+info2+info3
print(info)
exit() exit()
class Player(): # 玩家英雄 def Data_Check(Hero):
def __init__(self,name): print(Hero.Name+'的等级'+str(Hero.Level)+'\n'+
??? Hero.Name+'的血量'+str(Hero.HitPoint)+'\n'+
Hero.Name+'的攻击'+str(Hero.Attack)+'\n'+
Hero.Name+'的血量成长点'+str(Hero.HitPoint_UpPoint)+'\n'+
player = Player("后羿") Hero.Name+'的攻击成长点'+str(Hero.Attack_UpPoint)+'\n')
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack) class Sanses(Sans):
def __init__(self,AT,HP,HUP,AUP,name):
super().__init__(AT,HP,HUP,AUP,name)
Outer = Sans(30,50,20,20,'Outer!Sans')
Mudder = Sans(20,40,18,16,'Mudder!Sans')
Outer.combat(Mudder)
Mudder.Data_Check()
Mudder.Level_UP()
Mudder.combat(Outer)
\ 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