Commit 019daba8 by BellCodeEditor

save project

parent f1d65b38
Showing with 52 additions and 41 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.hp=hp
self.attack=attack
#
def upgrad(self):
self.level=yase.level*2
self.hp=yase.hp*2
self.attack=yase.attack*2
#
wudi=Hero("无敌",99999999999999999999999999999999999999999999999999999,9999999999999999999999999999999999999999999)
yase=Hero("亚瑟",300,20)
#
def upgrad_yase():
yase.level=yase.level*2
yase.hp=yase.hp*2
yase.attack=yase.attack*2
#
def upgrad_wudi():
wudi.level=wudi.level*2
wudi.hp=wudi.hp*2
wudi.attack=wudi.attack*2
input_name=input("你要升级哪个英雄?无敌\亚瑟 ")
c=input("几级?")
#
if input_name=="无敌":
for i in range(int(c)):
upgrad_wudi()
print("无敌的血量为",wudi.attack)
if input_name=="亚瑟":
for i in range(int(c)):
upgrad_yase()
class Hero: # 英雄类
def __init__(self, name): # 实例属性
self.name = name
self.level = 1
self.hp = 250
self.attack = 40
self.max_hp = self.hp
print("亚瑟的血量为",wudi.attack)
# yase.upgrad()
# print("亚瑟的血量为",yase.hp)
\ No newline at end of file
def combat(self, enemy): # 攻击功能
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
exit()
class Player(): # 玩家英雄
def __init__(self,name):
self.level = 1
self.hp = 250
self.attack = 40
# info1 = self.name+"对"+enemy.name+"发起进攻,"
# info2 = "造成"+str(self.attack)+"点伤害,"
# enemy.hp -= self.attack
# if enemy.hp > 0:
# info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
# info = info1+info2+info3
# print(info)
# else:
# info3 = enemy.name+"阵亡,游戏结束"
# info = info1+info2+info3
# print(info)
# exit()
player = Player("后羿")
print("玩家的等级为:",player.level)
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack)
\ No newline at end of file
......@@ -26,13 +26,14 @@ class Player(Hero): # 玩家英
def __init__(self,name):
super().__init__(name)
self.hp = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
self.attack = 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
self.hp = 300
self.attack = 50
self.max_hp = self.hp
we=str(self.attack)+" "+str(self.attack)
print("玩家"+self.name+"创建成功!等级,生命,攻击力,为"+we)
print("玩家"+self.name+"创建成功!生命,攻击力,为"+we)
player = Player("后羿")
ya
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack)
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