def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit: returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player_id = player.player_id if not rankManager.checkPlayerInRanking(player_id): rankManager.addRank(player_id) rankData = {} rankData['last_timed_reward_datetime'] = player.last_timed_reward_datetime rankData['last_timed_reward_ranknum'] = player.last_timed_reward_ranknum returnData.data = rankData str = MessageTools.encode(returnData) self.write(str) self.finish()
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit: returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player_id = player.player_id if not rankManager.checkPlayerInRanking(player_id): rankManager.addRank(player_id) if player.costResource(ResourceType.gems,10): player.last_challenge_datetime = GameTools.datetime2string(GameTools.getDatetimeNow() - datetime.timedelta(minutes = 20)) else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish()
def _process(self, params): token = params.get('token') skillID = params.get('skill_id') cost = params.get('costValue') cost = int(cost) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return if player.costResource(ResourceType.gems,cost): heroSkillData = player.getSkillInfo(skillID) heroSkillData.last_use_time = GameTools.datetime2string(GameTools.getDatetimeNow() - datetime.timedelta(days=1)) else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') shop_id = params.get('shop_id') value = params.get('value',0) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return error = pvpShopTable.playerShop(player,shop_id,value) if error != None: returnData = MessData(error) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') partner_id = params.get('partner_id') playerInfo = playerDataManager.getPlayerByToken(token) returnData = MessData() if playerInfo == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=playerInfo, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return partnerInfo = playerInfo.getPartner(partner_id) heroConstInfo = heroTable.GetHeroInfoByid(partner_id) awakeCost = heroConstInfo.awakeCost if playerInfo.costResource(ResourceType.awake_spell,awakeCost): partnerInfo.hp = heroConstInfo.max_hp partnerInfo.sleep = 0 else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish() if playerInfo != None: playerDataManager.checkNeedSave2DB(playerInfo.player_id)
def _process(self, params): token = params.get('token') pos = params.get('pos') equipment_id = params.get('equipmentid') to_quality = params.get('to_quality') to_level = params.get('to_level') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.equipmentUpgrade(pos,equipment_id,to_quality,to_level) != 0: returnData = MessData(ErrorCode.equipmentUpgradeError) # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') partner_ids = params.get('partner_ids') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) self.write(MessageTools.encode(returnData)) self.finish() return # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return for index in range(10): if index >= len(partner_ids): partner_ids.append(-1) player.selected_partners = partner_ids str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') partner_id = params.get('partner_id') order_num = params.get('order_num',1) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return errorCode = self.unlockPartner(player,partner_id,order_num) returnData = MessData(errorCode) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return returnData.data = drawHistoryManager.getDrawHistory() str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') partners_hp = params.get('partners_hp') partners_sleepStatus = params.get('sleeps',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player.synchronizationPartenrHP(partners_hp,partners_sleepStatus) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') # token验证 got_gems_num = params.get('got_gems_num') # 添加钻石数量 got_rmb_num = params.get('got_rmb_num') # 使用RMB数量 got_gems_num = int(got_gems_num) got_rmb_num = int(got_rmb_num) player = playerDataManager.getPlayerByToken(token) # 根据token获取玩家信息 returnData = MessData() # 初始化返回信息 if player == None: returnData = MessData(ErrorCode.tokenOutData) #玩家未登陆 else: # 玩家connect id检测 connect_id = params.get('connect_id', '') # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player.addResource(ResourceType.gems,got_gems_num) # 添加资源 # 更新玩家充值总数 player.recharge_total_num += got_rmb_num str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id) # 写入数据库
def _process(self, params): token = params.get('token') partner_id = params.get('partner_id') to_level = params.get('to_level') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return errCode = player.partnerUpgrade(partner_id,to_level) if errCode != None: returnData = MessData(errCode) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: player.updatePVPBuffs() playerDataManager.checkNeedSave2DB(player.player_id)
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit: returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return addChanllengeNum = player.add_chanllenge_num addChanllengeNum += 1 costGems = addChanllengeNum * 10 if player.costResource(ResourceType.gems, costGems): player.add_chanllenge_num = addChanllengeNum player.chanllenge_num += 1 else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish()
def post(self): bodyData = self.request.body params = MessageTools.decode(bodyData) token = params.get('token') cdkey = params.get('cdkey','') player = playerDataManager.getPlayerByToken(token) returnData = MessData() # 玩家登录检测 if player == None: returnData = MessData(ErrorCode.tokenOutData) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家connect id检测 connect_id = params.get('connect_id', '') # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return # 使用cdkey cdkey_data = {} cdkey_data['cdkey'] = cdkey.strip() cdkey_data['udid'] = player.udid cdkey_data['server_id'] = config.serverConfigManager.server_id sum_data = "%s%s%d%s" %(cdkey_data['cdkey'], cdkey_data['udid'], cdkey_data['server_id'], config.SECRET_KEY) cdkey_data['sign'] = hashlib.md5(sum_data.encode('utf-8')).hexdigest() url = 'http://121.41.120.248/gift/use_cdkey/' req = requests.post(url, data=json.dumps(cdkey_data)) req = json.loads(req.text) if req.get('error', False): returnData = MessData((820, "%s" % req['error']['data']['message'])) self.write(MessageTools.encode(returnData)) self.finish() return # add tools for t in req['data']: player.addResource(t['tool_id'],t['count']) returnData.data = req['data'] str = MessageTools.encode(returnData,False) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') result = dictData.get('result', 0) targetID = dictData.get('target_id') lowRank = dictData.get('lowRank',0) tap_count = dictData.get('tap_count') crital_count = dictData.get('crital_count') target_hp = dictData.get('target_hp',0) # the data need verify. player = playerDataManager.getPlayerByToken(token) returnDict = {} returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.player_id == targetID: returnData = MessData(ErrorCode.cannotAttackYourself) elif not pvpDataManger.fightFinished(player.player_id,targetID): returnData = MessData(ErrorCode.fightTargetNotMatch) elif self.verifyPVPFight(tap_count,crital_count,player,target_hp): # 玩家connect id检测 connect_id = dictData.get('connect_id', '') # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return if result == 1 and lowRank == 0: rankManager.pvpWin(player.player_id,targetID) else: pass fightRewards = pvpFightRewardTable.getPvpFightRewardByResult(result) for reward in fightRewards: type = reward.type value = reward.value player.addResource(type,value) rank_num = rankManager.getRankNumByPlayerid(player.player_id) target_num = rankManager.getRankNumByPlayerid(targetID) self.saveResult(player.player_id,targetID,result,rank_num,target_num,lowRank) rankList = rankManager.getRankList(rank_num) returnDict['rank_num'] = rank_num returnDict['rankList'] = rankList returnData.data = returnDict else: returnData = MessData(ErrorCode.pvpVerifyError) str = MessageTools.encode(returnData,False) self.write(str) self.finish()
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit: returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player_id = player.player_id cmd ="SELECT\ result.id,\ result.attacker_id,\ result.target_id,\ result.result,\ result.attacker_num,\ result.target_num ,\ result.fight_low,\ player1.`name`,\ player2.`name`\ FROM\ player_fight_result as result ,player_base_info as player1,player_base_info as player2\ WHERE (result.attacker_id = %s or result.target_id = %s )and result.attacker_id = player1.playerid and result.target_id = player2.playerid\ ORDER BY result.id\ DESC\ LIMIT 5" %(player_id,player_id) data = db_Manager.excuteQuery(cmd) returnData.data = [] for resultData in data: fightResult = FightResult(resultData) returnData.data.append(fightResult) str = MessageTools.encode(returnData) self.write(str) self.finish()
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) udid = dictData['udid'] returnData = None player = None playerID = self.getPlayeridByudid(udid) # 使用udid从数据库读取玩家ID if playerID == -1: returnData = MessData(ErrorCode.have_not_sign) # 玩家未注册 else: returnData = MessData() player = playerDataManager.getPlayerByPlayerid(playerID) # 登录成功,使用playerid获取玩家信息 if player == None: # 玩家信息未在内存中从数据库读取 player = playerDataManager.loginUseUidd(udid) player.connect_id = playerDataManager.create_connect_id(player.player_id) # 重新生成连接ID returnData.data = player player.server_date_time = GameTools.getDateTimeNowString() else: player.connect_id = playerDataManager.create_connect_id(player.player_id) # 重新生成连接ID returnData.data = player player.server_date_time = GameTools.getDateTimeNowString() if player != None: player.calculateOfflineResource() # 结算离线奖励 message = MessageTools.encode(returnData,False) if player != None: # 重置离线奖励 player.offlineCash = 0 self.write(message) self.finish()
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) udid = dictData['udid'] name = dictData['name'] cdkey = dictData.get('cdkey', '') returnData = MessData() player = None open_activate = True # 账户验证 name = name.strip() contains = name.find(';') >= 0 or name.find(' ') > 0 or len(name) == 0 charCount = len(name) max_length = gloabalBase.getValue('MAX_LENGTH_OF_NAME') max_length = int(max_length) # 长度验证 if contains or charCount > max_length: returnData = MessData(ErrorCode.name_illegal) # 非法字符验证 elif illegalWordManager.ContainIllegalWord(name): returnData = MessData(ErrorCode.name_illegal) # 是否已被使用验证 elif not playerDataManager.isSign(udid): if playerDataManager.isNameUsed(name): returnData = MessData(ErrorCode.name_used) else: playerDataManager.createAccount(udid,name) player = playerDataManager.loginUseUidd(udid) player.connect_id = playerDataManager.create_connect_id(player.player_id) # 重新生成连接ID player.revial = 1 returnData.data = player player.server_date_time = GameTools.getDateTimeNowString() # 通过 else: player = playerDataManager.loginUseUidd(udid) player.server_date_time = GameTools.getDateTimeNowString() player.connect_id = playerDataManager.create_connect_id(player.player_id) # 重新生成连接ID returnData.data = player player.calculateOfflineResource() message = MessageTools.encode(returnData,False) if player != None: # 重置离线奖励 player.offlineCash = 0 # 使用cdkey if open_activate is True: cdkey_obj.is_use = True cdkey_obj.usedtime = datetime.datetime.now() cdkey_obj.use_udid = udid cdkey_obj.save() self.write(message) self.finish()
def post(self): bodyData = self.request.body params = MessageTools.decode(bodyData) token = params.get('token') step = params.get('step','') player = playerDataManager.getPlayerByToken(token) returnData = MessData() # 玩家登录检测 if player == None: returnData = MessData(ErrorCode.tokenOutData) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家connect id检测 connect_id = params.get('connect_id', '') # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return # 步骤检测 try: tutorial = getattr(player, step) except: returnData = MessData(ErrorCode.tutorialStepError) self.write(MessageTools.encode(returnData)) self.finish() return # 步骤状态检测 if tutorial != 1: setattr(player, step, 1) if player != None: playerDataManager.checkNeedSave2DB(player.player_id) str = MessageTools.encode(returnData) self.write(str) self.finish()
def get(self): bodyData = self.get_argument('data') print('data:%s' % bodyData) dictData = MessageTools.decode(bodyData) token = dictData.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit: returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player_id = player.player_id if not rankManager.checkPlayerInRanking(player_id): rankManager.addRank(player_id) rank_num = rankManager.getRankNumByPlayerid(player_id) rankList = rankManager.getRankList(rank_num) pvpDataManger.addTargetList(player_id,rankList) # for pvpPlayerInfoInRanking in rankList: # if pvpPlayerInfoInRanking.player_id == player_id: # rankList.remove(pvpPlayerInfoInRanking) rankData = {} rankData['rank_num'] = rank_num rankData['rankList'] = rankList returnData.data = rankData str = MessageTools.encode(returnData,False) self.write(str) self.finish()
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') targetid = dictData.get('targetid',0) targetid = int(targetid) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit: returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player_id = player.player_id if not rankManager.checkPlayerInRanking(player_id): rankManager.addRank(player_id) player.updateDailyData() lastChanllengeDatetime = GameTools.string2datetime(player.last_challenge_datetime) if GameTools.getDatetimeNow() < lastChanllengeDatetime + datetime.timedelta(seconds = 60 * 4): returnData = MessData(ErrorCode.skillincd) elif player.costResource(ResourceType.chanllengeNum,1): player.last_challenge_datetime = GameTools.getDateTimeNowString() pvpDataManger.addFightStatus(player_id,targetid) else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish()
def _process(self, params): token = params.get('token') reward_type = params.get('reward_type') addValue = params.get('add_value') addValue = int (addValue) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return value = randomRewardManager.getValue(reward_type) # verify addValue at here! value = addValue max_time = gloabalBase.getValue('RandomRewardDailyMaxTimes') player.refreshTimeData() if player.random_reward_num < max_time: if reward_type ==1 or reward_type == 3: player.addResource(ResourceType.cash,value) elif reward_type == 2 or reward_type == 4: player.addResource(ResourceType.gems,value) player.random_reward_num += 1 else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def post(self): bodyData = self.request.body params = MessageTools.decode(bodyData) token = params.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() # 玩家登录检测 if player == None: returnData = MessData(ErrorCode.tokenOutData) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家connect id检测 connect_id = params.get('connect_id', '') # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return # 钻石检测 cost = gloabalBase.getValue('use_skill_cost') if player.gems < cost: returnData = MessData(ErrorCode.resourceNotEnough) self.write(MessageTools.encode(returnData)) self.finish() return player.gems -= cost str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def post(self): bodyData = self.request.body dictData = MessageTools.decode(bodyData) token = dictData.get('token') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) # elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < 60: # returnData = MessData(ErrorCode.pvpNOTUnlockNow) else: # Íæ¼Òconnect id¼ì²â connect_id = dictData.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return player_id = player.player_id if not rankManager.checkPlayerInRanking(player_id): rankManager.addRank(player_id) rank_num = rankManager.getRankNumByPlayerid(player_id) rankList = rankManager.getTopRankList() rankData = {} rankData['rank_num'] = rank_num rankData['rankList'] = rankList returnData.data = rankData str = MessageTools.encode(returnData,False) self.write(str) self.finish()
def _process(self, params): token = params.get('token') game_level = params.get('game_level') got_gems_num = params.get('revial_num') add_cash = params.get('add_cash') add_cash = int(add_cash) got_gems_num = int(got_gems_num) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return if not self.verifyLevelInfo(game_level,got_gems_num,player,add_cash): returnData = MessData(ErrorCode.shopVerifyError) else: if player.costResource(ResourceType.gems,100): player.addResource(ResourceType.cash,add_cash) else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') skillID = params.get('skillid') player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return playerSkillInfo = player.getSkillInfo(skillID) skillLevel = playerSkillInfo.skillLevel lastUseTimeStr = playerSkillInfo.last_use_time lastUseTime = GameTools.string2datetime(lastUseTimeStr) skillConstInfo = heroSkillTableManager.getHeroSkill(skillID,skillLevel) cd = skillConstInfo.cd errCode = player.useSkill(skillID) # if GameTools.getDatetimeNow() + datetime.timedelta(seconds = 90) >= lastUseTime + datetime.timedelta(seconds = cd): # errCode = player.useSkill(skillID) # else: # returnData = MessData(ErrorCode.skillincd) #in cd str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def _process(self, params): token = params.get('token') drawtimes = params.get('drawtimes',1) free_draw = params.get('free_draw',0) player = playerDataManager.getPlayerByToken(token) returnData = MessData() if player == None: returnData = MessData(ErrorCode.tokenOutData) else: # Íæ¼Òconnect id¼ì²â connect_id = params.get('connect_id', '') # Íæ¼ÒÁ¬½Óid ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return if free_draw == 1: if GameTools.getDatetimeNow() < GameTools.string2datetime(player.last_free_draw_datetime) + datetime.timedelta(hours = 23): returnData = MessData(ErrorCode.skillincd) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id) return cost = 0 if drawtimes == 1: if free_draw == 0: cost = int(gloabalBase.getValue('draw1cost')) else: cost = int(gloabalBase.getValue('draw10cost')) if player.costResource(ResourceType.gems,cost): if free_draw == 1: player.last_free_draw_datetime = GameTools.getDateTimeNowString() rewards = [] if drawtimes == 1: rewards = drawRewardManager.draw1Reward(player.game_level) else: rewards = drawRewardManager.draw10Reward(player.game_level) for resourceAndVlue in rewards: itemid = resourceAndVlue.itemid value = resourceAndVlue.value item = itemTable.getItemConstInfo(itemid) resourceId = item.buftype player.addResource(resourceId,value) if item.quliaty > 3: drawHistoryManager.pushIntoHistory(player.name,resourceAndVlue) returnData.data = rewards else: returnData = MessData(ErrorCode.resourceNotEnough) str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def post(self): bodyData = self.request.body params = MessageTools.decode(bodyData) token = params.get("token") gift_no = params.get("gift_no", 1) player = playerDataManager.getPlayerByToken(token) returnData = MessData() # 玩家登录检测 if player == None: returnData = MessData(ErrorCode.tokenOutData) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家connect id检测 connect_id = params.get("connect_id", "") # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家礼包类型检测 gift_status = player.recharge_get_gifts_status.get("%d" % gift_no, False) if gift_status is False: returnData = MessData(ErrorCode.opeventCumulativeRechargeTypeError) self.write(MessageTools.encode(returnData)) self.finish() return # 是否领取检测 if int(gift_status) != 0: returnData = MessData(ErrorCode.opeventCumulativeRechargeStatusError) self.write(MessageTools.encode(returnData)) self.finish() return # 是否达到条件检测 rewords = openServerTable.getOpeventServer(1, gift_no) if not rewords: returnData = MessData(ErrorCode.opeventCumulativeRechargeRewordsError) self.write(MessageTools.encode(returnData)) self.finish() return if player.recharge_total_num < int(rewords.condition): returnData = MessData(ErrorCode.opeventCumulativeRechargeCompletedError) self.write(MessageTools.encode(returnData)) self.finish() return # 添加奖励 if rewords.item1 > 0: player.addResource(rewords.item1, rewords.num1) if rewords.item2 > 0: item = itemTable.getItemConstInfo(rewords.item2) player.addResource(item.buftype, rewords.num2) # 修改礼包状态 player.recharge_get_gifts_status["%d" % gift_no] = 1 str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)
def post(self): bodyData = self.request.body params = MessageTools.decode(bodyData) token = params.get('token') gift_no = params.get('gift_no',0) player = playerDataManager.getPlayerByToken(token) returnData = MessData() # 玩家登录检测 if player == None: returnData = MessData(ErrorCode.tokenOutData) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家connect id检测 connect_id = params.get('connect_id', '') # 玩家连接id ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id) if ck_connectid[0] is False: returnData = MessData(ck_connectid[1]) self.write(MessageTools.encode(returnData)) self.finish() return #奖励检测 rewords = openServerTable.getOpeventServer(2, int(gift_no)) if not rewords: returnData = MessData(ErrorCode.opeventLoginRewordsError) self.write(MessageTools.encode(returnData)) self.finish() return # 玩家礼包类型检测 gift_status = player.login_get_gifts_status.get('%d' %rewords.condition, False) if gift_status is False: returnData = MessData(ErrorCode.opeventLoginRewordsTypeError) self.write(MessageTools.encode(returnData)) self.finish() return # 是否领取检测 if int(gift_status) !=0: returnData = MessData(ErrorCode.opeventLoginRewordsStatusError) self.write(MessageTools.encode(returnData)) self.finish() return # 是否达到条件检测 if player.login_num < rewords.condition: returnData = MessData(ErrorCode.opeventLoginRewordsCompletedError) self.write(MessageTools.encode(returnData)) self.finish() return # 添加奖励 if rewords.item1>0: player.addResource(rewords.item1,rewords.num1) # 修改礼包状态 player.login_get_gifts_status['%d' %rewords.condition] = 1 str = MessageTools.encode(returnData) self.write(str) self.finish() if player != None: playerDataManager.checkNeedSave2DB(player.player_id)