Commit 0233c79b by BellCodeEditor

auto save

parent cfcd7a9a
Showing with 19 additions and 12 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero:
def __init__(self, name): def __init__(self,name,hp,attack):
self.level = 1 self.Name=name
self.hp = 250 self.Level=1
self.attack = 40 self.Hp=hp
self.name = name self.Attack=attack
def Hup(self,a):
def combat(): # 攻击 self.Attack+=5*a
??? self.Hp+=50*a
self.Level+=1*a
yase = Hero("垭瑟") def combat(self,enemy):
houyi= Hero("后羿") enemy.Hp-=self.Attack
info1=self.Name+'对'+enemy.Name+'发起了进攻'
info2='造成'+str(self.Attack)+'的伤害'
if enemy.Hp>0:
info3=enemy.Name+str(enemy.Hp)+'血量'
H=Hero('亚瑟',100,100)
D=Hero('后羿',55,90)
yase.combat(houyi) yase.combat(houyi)
\ 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