Commit 0f99a346 by BellCodeEditor

save project

parent 81cd96fd
Showing with 15 additions and 16 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name):
self.name=name self.name=name
self.hp=hp self.hp=250
self.attack=attack self.attack=40
yase=Hero("亚瑟",300,20) self.level=1
houyi=Hero("后裔",240,23) def combat(self,enemy):
print("亚瑟的血量是:",yase.hp) enemy.hp-=self.attack
print("后裔的血量是:",houyi.hp) info1=self.name+"对"+enemy.name+"发起进攻,"
info2="造成"+str(self.attack)+"伤害"
def de(): info3=enemy.name+"还剩"+str(enemy.hp)+"血量"
yase.hp+=50 info=info1+info2+info3
yase.attack+=20 print(info)
houyi.hp+=30 yase = Hero("亚瑟")
houyi.attack+=40 houyi = Hero("后裔")
de() yase.combat(houyi)
de() \ 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