def FinishedTrain(self): '''立即结束训练''' if not self.istrain: return {'result':False,'message':Lg().g(223)} viplevel = self._owner.baseInfo._viptype if not vipCertification('finishedTrain', viplevel,nowtimes= self.finishedTrain): return {'result':False,'message':Lg().g(222)} characterId = self._owner.baseInfo.id goldcons = 10*TRAINTYPE.get(self.traintype) nowgold = self._owner.finance.getGold() golddelta = nowgold - goldcons if golddelta < 0: return {'result':False,'message':Lg().g(190)} self.finishedTrain +=1 if self.finishedTrain ==1: props = {'traindate':str(datetime.datetime.now()), 'finishedTrain':self.finishedTrain} dbAfk.updateCharacterTurnRecord(characterId, props) else: props = {'finishedTrain':self.finishedTrain} dbAfk.updateCharacterTurnRecord(characterId, props) self._owner.finance.consGold(goldcons,9)#立即完成训练消耗钻 expbound = self.rewardTrainBound() self.stopTrainTimer() # sendTimerSingal(0, characterId, -1) msg = u'获得%d经验'%expbound return {'result':True,'message':msg}
def FinishedMining(self): '''立即结束挖掘''' if not self.ismining: return {'result':False,'message':Lg().g(221)} viplevel = self._owner.baseInfo._viptype if not vipCertification('finishedMining', viplevel,nowtimes= self.finishedMining): return {'result':False,'message':Lg().g(222)} characterId = self._owner.baseInfo.id goldcons = 10*MININGTYPE.get(self.miningtype) nowgold = self._owner.finance.getGold() golddelta = nowgold - goldcons if golddelta < 0: return {'result':False,'message':Lg().g(190)} self.finishedMining +=1 if self.finishedMining ==1: props = {'miningdate':str(datetime.datetime.now()), 'finishedMining':self.finishedMining} dbAfk.updateCharacterTurnRecord(characterId, props) else: props = {'finishedMining':self.finishedMining} dbAfk.updateCharacterTurnRecord(characterId, props) self._owner.finance.consGold(goldcons,5)#立即完成挖掘消耗钻 coinbound = self.rewardMiningBound() self.stopMiningTimer() msg = u'获得%d金币'%(coinbound) return {'result':True,'message':msg}
def JiaJiXunLian(self,ttype,memberId): '''加急训练''' viplevel = self._owner.baseInfo._viptype if not vipCertification('turnexptimes', viplevel,nowtimes= self.turnexptimes): return {'result':False,'message':Lg().g(219)} characterId = self._owner.baseInfo.id nowtimes = self.turnexptimes + 1 expbound = 30000#self._owner.level.getLevel()*1000 goldcons = nowtimes *2 nowgold = self._owner.finance.getGold() golddelta = nowgold - goldcons if golddelta < 0: return {'result':False,'message':Lg().g(220)} self._owner.finance.consGold(goldcons,10)#加急训练消耗钻 if ttype == 0: self._owner.level.addExp(expbound) else: self._owner.pet.getPet(memberId).level.addExp(expbound) self.turnexptimes += 1 if self.turnexptimes ==1: props = {'turnexpdate':str(datetime.datetime.now()), 'turnexptimes':self.turnexptimes} dbAfk.updateCharacterTurnRecord(characterId, props) else: props = {'turnexptimes':self.turnexptimes} dbAfk.updateCharacterTurnRecord(characterId, props) self._owner.schedule.noticeSchedule(13)#成功后的日程目标通知 return {'result':True,'data':expbound}
def dianshichengjin(self): '''点石成金''' characterId = self._owner.baseInfo.id nowtimes = self.turncointimes + 1 #VIP权限限制 viplevel = self._owner.baseInfo._viptype if not vipCertification('turncointimes', viplevel,nowtimes= self.turncointimes): return {'result':False,'message':Lg().g(215)} coinboud = 20000#self._owner.level.getLevel()*3980 goldcons = nowtimes *2 nowgold = self._owner.finance.getGold() golddelta = nowgold - goldcons if golddelta < 0: return {'result':False,'message':Lg().g(216)} self._owner.finance.consGold(goldcons,11)#点石成金消耗钻 self._owner.finance.addCoin(coinboud) self.turncointimes += 1 if self.turncointimes ==1: props = {'turncoindate':str(datetime.datetime.now()), 'turncointimes':self.turncointimes} dbAfk.updateCharacterTurnRecord(characterId, props) else: props = {'turncointimes':self.turncointimes} dbAfk.updateCharacterTurnRecord(characterId, props) return {'result':True,'data':coinboud}
def updateVIPAward(self,libaovip): '''更新已领取vip礼包的等级 @param libaovip: int vip 礼包的等级 ''' characterId = self._owner.baseInfo.id self.setViplevellibao(libaovip) dbAfk.updateCharacterTurnRecord(characterId, {'viplevellibao':libaovip})
def buyEnergy(self): '''购买体力''' viplevel = self._owner.baseInfo._viptype if not vipCertification('turnenergytimes', viplevel,nowtimes= self.turnenergytimes): return {'result':False,'message':Lg().g(217),'failType':0} characterId = self._owner.baseInfo.id energyboud = 40 goldcons = (self.turnenergytimes+1)*20 nowgold = self._owner.finance.getGold() golddelta = nowgold - goldcons if golddelta < 0: return {'result':False,'message':Lg().g(190),'failType':1} self._owner.finance.consGold(goldcons,7)#购买活力消耗钻 self._owner.attribute.addEnergy(energyboud) self.turnenergytimes += 1 if self.turnenergytimes ==1: props = {'turnenergydate':str(datetime.datetime.now()), 'turnenergytimes':self.turnenergytimes} dbAfk.updateCharacterTurnRecord(characterId, props) else: props = {'turnenergytimes':self.turnenergytimes} dbAfk.updateCharacterTurnRecord(characterId, props) return {'result':False,'message':Lg().g(218),'failType':0}