Commit d79942fb by BellCodeEditor

save project

parent 1bccff07
Showing with 15 additions and 6 deletions
class Hero(): class Hero():
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack,level):
self.attack = attack self.name = name
self.hp = hp self.hp = hp
self.level = level
self.attack = attack #yase=Hero('yase',300,20) self.attack = attack #yase=Hero('yase',300,20)
#hy=Hero('hy',250,23) #hy=Hero('hy',250,23)
def upgrade(self): def upgrade(self):
...@@ -14,6 +15,14 @@ class Hero(): ...@@ -14,6 +15,14 @@ class Hero():
print(self.hp) print(self.hp)
print(self.level) print(self.level)
yase = Hero(100000,20000,1) def combat(self,enermy):
yase.upgrade() enermy.hp-= self.attack
yase.check info1 = self.name+"对"+enermy.name+"发动了攻击\n"
\ No newline at end of file info2 = enermy.name+"血量降低了"+str(self.attack)+"\n"
info3 = enermy.name+"还剩余"+str(enermy.hp)+"点的血量\n"
print(info1+info2+info3)
yase = Hero("亚瑟",200,40,1)
houyi = Hero("后羿",200,400,2)
houyi.combat(yase)
\ 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