Commit 08614725 by BellCodeEditor

save project

parent f47689a4
Showing with 35 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=30000
self.attack=4000
def combat(self,enemy):
enemy.hp-=self.hp
into1=self.name+"对"+enemy.name+"发起进攻,"
into2="造成"+str(self.attack)+"点伤害,"
if enemy.hp>0:
into3=enemy.name+"还剩下"+str(enemy.hp)+"血量"
into=into1+into2+into3
print(into)
else:
into3=enemy.name+"阵亡,游戏结束"
into=into1+into+into3
print(into)
#def upgrade(self):
# self.level=self.level+1
# self.hp=self.hp+5000
# self.attack=self.attack+400
#yase=Hero("亚瑟",30000,2000)
#houyi=Hero("后羿",24000,2300)
#yase.upgrade()
#houyi.upgrade()
#print("亚瑟的血量是:",yase.hp)
#print("后羿的血量是:",houyi.hp)
\ 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