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) 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 _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 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') 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 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') 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) 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 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') 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)