Commit 556629f5 by BellCodeEditor

auto save

parent 602b46c3
Showing with 16 additions and 14 deletions
class Hero:
def __init__(self,hp,Gj):
def __init__(self,name,hp,Gj):
self.hp=hp
self.Gj=Gj
self.dj=1
#houyi=Hero(50,30)
#print(houyi.Gj)
self.name=name
def shj(self):
self.dj=self.dj+1
self.Gj=self.Gj+5
self.hp=self.hp+10
yase=Hero(100,20)
def j(self,enemy):
enemy.hp=enemy.hp-self.Gj
q1=self.name+'对'+enemy.name+'发起攻击'
q2='造成了'+str(self.Gj)+'伤害'
q3=enemy.name+'还剩'+str(enemy.hp)
q=q1+q2+q3
print(q)
class Player(Hero):
pass
yase=Hero('亚瑟',100,20)
yase.shj()
print('亚瑟生命值为:',yase.hp)
print('亚瑟攻击值为:',yase.Gj)
print('亚瑟等级为:',yase.dj)
houyi=Hero(50,40)
houyi=Player('后羿',50,40)
houyi.shj()
print('后羿生命值为:',houyi.hp)
print('后羿攻击值为:',houyi.Gj)
print('后羿等级是:',houyi.dj)
\ No newline at end of file
print(yase.name)
print(houyi.name)
yase.j(houyi)
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