#游戏人物 class GamePerson: def __init__(self,name,category,output,skill,score=0): self.name = name self.category =category self.output = output self.skill = skill self.score = score # 偷红buff def getHongBuff(self): self.output -=300 print('%s %s释放%s偷到红buff,消耗300血量'%(self.category,self.name,self.skill)) #solo def solo(self,n=1): self.output -= 500 if self.output <=0: print('%s%s血染王者峡谷'%(self.category,self.name)) return else: if self.score==0: self.score += n print('%s %s 得到一血,消耗500血量'%(self.category,self.name)) else: self.score += n print('%s %s正在战斗,得到%d血,消耗500血量'%(self.category,self.name,self.score)) #补血 def addXue(self): self.output +=200 print('%s 释放治疗术加200血'%(self.name)) #查看英雄战斗信息 def info(self): print('%s%s还剩%d血量,拿了%d个人头'%(self.category,self.name,self.output,self.score)) kai = GamePerson('凯','战士',1000,'极刃风暴',0) kai.getHongBuff() kai.solo() kai.addXue() kai.info()