Commit 15778c16 by BellCodeEditor

save project

parent ac43a558
Showing with 43 additions and 5 deletions
......@@ -10,11 +10,48 @@ class Hero:
self.HP=self.HP+350
self.att=self.att+250
def combat(self,enemy):
y=Hero("澜",1,1000,500)
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.att)+"点伤害"
enemy.HP-=self.att
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(Hero):
def __init__(self,name,l):
super().__init__(name,1,-1,-1)
self.HP = 1000
self.att = 500
self.l = l
print(self.name+"创建成功,英雄类型为"+self.l)
print("当前等级、血量、攻击力分别为:",self.level,self.HP,self.att)
y=Player("澜","刺客")
o=Hero("白起",1,5000,100)
y.upgrade()
o.upgrade()
print(y.att)
print(o.att)
y.upgrade()
y.upgrade()
y.upgrade()
y.upgrade()
y.combat(o)
o.combat(y)
o.combat(y)
o.combat(y)
o.combat(y)
y.upgrade()
o.upgrade()
y.upgrade()
y.upgrade()
y.upgrade()
y.upgrade()
y.combat(o)
y.combat(o)
y.combat(o)
y.combat(o)
o.combat(o)
\ 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