Commit cb926610 by BellCodeEditor

save project

parent 4daabbb5
Showing with 8 additions and 16 deletions
...@@ -4,21 +4,13 @@ class Hero(): ...@@ -4,21 +4,13 @@ class Hero():
self.hp = hp self.hp = hp
self.attack = attack self.attack = attack
self.level = level self.level = level
def upgrade(self):
self.level = self.level+1
self.hp = self.hp+50
self.attack = self.attack+30
yase=Hero("亚瑟",300,20,1) yase=Hero("亚瑟",300,20,1)
def upgrade():
yase.level = yase.level+1
yase.hp = yase.hp+50
yase.attack = yase.attack+30
upgrade()
upgrade()
houyi=Hero("后羿",260,24,1) houyi=Hero("后羿",260,24,1)
def npgrade(): yase.upgrade()
houyi.level = houyi.level+1 print("亚瑟等级为:",yase.level)
houyi.hp = houyi.hp+25
houyi.attack = houyi.attack+55
npgrade()
npgrade()
npgrade()
npgrade()
print("亚瑟血量为:",yase.hp) print("亚瑟血量为:",yase.hp)
print("后羿血量为:",houyi.hp) print("亚瑟攻击为:",yase.attack)
\ No newline at end of file \ 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