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 UseXingYun(self,usetype): ''' @param usetype: int 0四叶草1郁金香2蝴蝶兰3紫罗兰4曼陀罗 ''' self.clearWishRecord() if usetype not in [0,1,2,3,4]: return {'result':False,'msgID':651} CONS_CONFIG = {0:0,1:10,2:15,3:20,4:30} goldcons = CONS_CONFIG.get(usetype) guild = GuildManager().getGuildById(self.id) if not guild: return {'result':False,'msgID':79} if self._owner.finance.getGold()<goldcons: return {'result':False,'msgID':652} characterId = self._owner.baseInfo.id viplevel = self._owner.baseInfo._viptype nowtimes=getattr(self,'wish_%d_times'%usetype) result = dbVIP.vipCertification('wish_%d_times'%usetype, viplevel, nowtimes=nowtimes) if not result: return {'result':False,'msgID':655} setattr(self, 'wish_%d_times'%usetype, nowtimes+1) dbGuild.updateCharacterWishRecord(characterId, {'wish_%d_times'%usetype:nowtimes+1}) self._owner.finance.addGold(-goldcons) usename = self._owner.baseInfo.getName() xingyunadd = guild.UseXingYun(usetype,usename) self._owner.petShop.addXy(xingyunadd) return {'result':True}
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 updateShow(self,petId): '''设置展示的宠物的ID''' viplevel = self._owner.baseInfo._viptype if not dbVIP.vipCertification('petflow', viplevel): return {'result':False,'message':Lg().g(217)} pet = self.getPet(petId) FlowFlag = pet.getFlowFlag() if not FlowFlag: canFlow = self.checkCanFlow() if not canFlow: return {'result':False,'message':Lg().g(419)} pet.updateFlowFlag(True) return {'result':True,'message':Lg().g(420),'data':False} else: pet.updateFlowFlag(False) return {'result':True,'message':u'','data':True}
def updateShow(self, petId): '''设置展示的宠物的ID''' viplevel = self._owner.baseInfo._viptype if not dbVIP.vipCertification('petflow', viplevel): return {'result': False, 'message': Lg().g(217)} pet = self.getPet(petId) FlowFlag = pet.getFlowFlag() if not FlowFlag: canFlow = self.checkCanFlow() if not canFlow: return {'result': False, 'message': Lg().g(419)} pet.updateFlowFlag(True) return {'result': True, 'message': Lg().g(420), 'data': False} else: pet.updateFlowFlag(False) return {'result': True, 'message': u'', 'data': True}
def AddSurplustimes(self): '''添加竞技场剩余次数''' viplevel = self._owner.baseInfo._viptype nowtimes = self.buytimes if not vipCertification('arenatimes', viplevel,nowtimes = nowtimes): return {'result':False,'message':Lg().g(217)} reqGold = (self.buytimes+1)*10 if reqGold>self._owner.finance.getGold(): return {'result':False,'message':Lg().g(190)} self._owner.finance.consGold(reqGold,12)#添加剩余次数 self.buytimes +=1 self.surplustimes +=1 characterId = self._owner.baseInfo.id props = {'buytimes':1,'surplustimes':self.surplustimes} dbarena.updateCharacterArenaInfo(characterId, props) reqCoin = (self.buytimes+1)*10 info = {'bCount':self.surplustimes,'addCount':self.buytimes,'reqCoin':reqCoin} return {'result':True,'data':info}
def turnCard(self, characterId, nickname, cardId): '''副本结束翻牌 @param characterId: int 角色的id @param cardId: int 卡牌的id ''' player = PlayersManager().getPlayerByID(characterId) pushcnt = self.playersTurned.count(characterId) nowpushcnt = pushcnt + 1 viplevel = player.baseInfo.getType() # dbVIP.vipCertification('cardnum', viplevel,nowtimes = pushcnt) if not dbVIP.vipCertification('cardnum', viplevel, nowtimes=nowpushcnt): reactor.callLater(0.5, self.TurnAllCard) if nowpushcnt >= 2: cus = pushcnt * TURNCUS reGold = player.finance.getGold() - cus if reGold < 0: return {'reslt': False, 'message': Lg().g(190)} player.finance.updateGold(reGold) card = self._cards[cardId] if card.IsTurned(): return {'result': False, 'message': Lg().g(279)} card.changeIsTurned() sendList = [] playersList = [] for scence in self._owner._Scenes.values(): playersList.extend(scence._playerlist) playersList = set(playersList) for characterId in playersList: pl = PlayersManager().getPlayerByID(characterId) if pl: sendList.append(pl.dynamicId) dropItem = card.itemBound coin = card.coin if dropItem: player.pack.putNewItemInPackage(dropItem) self.pushJipinInfo(player, dropItem) else: player.finance.addCoin(coin) self.playersTurned.append(characterId) pushTurnOneCardMessage(characterId, nickname, cardId, sendList) return {'result': True, 'message': Lg().g(280)}
def flushTowerRecord(self): '''刷新爬塔记录 ''' if self.nowLayers ==1: return {'result':False,'message':Lg().g(493)} viplevel = self._owner.baseInfo._viptype if not dbVIP.vipCertification('climbtimes', viplevel,nowtimes= self.climbtimes): return {'result':False,'message':Lg().g(494)} goldcons = FLUSH_CONS.get(self.climbtimes+1) if goldcons and goldcons> self._owner.finance.getGold():#判断消耗 return {'result':False,'message':Lg().g(190)} else: self._owner.finance.consGold(goldcons,12, consDesc=u'刷新克洛塔消耗%d钻'%goldcons)#刷新克洛塔#(-goldcons)#扣除消耗的钻 self.climbtimes +=1 self.nowLayers = 1 characterId = self._owner.baseInfo.id props = {'climbtimes':self.climbtimes,'nowLayers':1} dbtower.updateCharacterTowerRecord(characterId, props) return {'result':True,'message':Lg().g(495)}
def AddSurplustimes(self): '''添加竞技场剩余次数''' viplevel = self._owner.baseInfo._viptype nowtimes = self.buytimes if not vipCertification('arenatimes', viplevel, nowtimes=nowtimes): return {'result': False, 'message': Lg().g(217)} reqGold = (self.buytimes + 1) * 10 if reqGold > self._owner.finance.getGold(): return {'result': False, 'message': Lg().g(190)} self._owner.finance.consGold(reqGold, 12) #添加剩余次数 self.buytimes += 1 self.surplustimes += 1 characterId = self._owner.baseInfo.id props = {'buytimes': 1, 'surplustimes': self.surplustimes} dbarena.updateCharacterArenaInfo(characterId, props) reqCoin = (self.buytimes + 1) * 10 info = { 'bCount': self.surplustimes, 'addCount': self.buytimes, 'reqCoin': reqCoin } return {'result': True, 'data': info}
def flushTowerRecord(self): '''刷新爬塔记录 ''' if self.nowLayers == 1: return {'result': False, 'message': Lg().g(493)} viplevel = self._owner.baseInfo._viptype if not dbVIP.vipCertification( 'climbtimes', viplevel, nowtimes=self.climbtimes): return {'result': False, 'message': Lg().g(494)} goldcons = FLUSH_CONS.get(self.climbtimes + 1) if goldcons and goldcons > self._owner.finance.getGold(): #判断消耗 return {'result': False, 'message': Lg().g(190)} else: self._owner.finance.consGold(goldcons, 12, consDesc=u'刷新克洛塔消耗%d钻' % goldcons) #刷新克洛塔#(-goldcons)#扣除消耗的钻 self.climbtimes += 1 self.nowLayers = 1 characterId = self._owner.baseInfo.id props = {'climbtimes': self.climbtimes, 'nowLayers': 1} dbtower.updateCharacterTowerRecord(characterId, props) return {'result': True, 'message': Lg().g(495)}
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}