/// <summary> /// 领取活动奖励,除了冲级达人 /// </summary> /// <param name="tcpMgr"></param> /// <param name="socket"></param> /// <param name="tcpClientPool"></param> /// <param name="tcpRandKey"></param> /// <param name="pool"></param> /// <param name="nID"></param> /// <param name="data"></param> /// <param name="count"></param> /// <param name="tcpOutPacket"></param> /// <returns></returns> private static TCPProcessCmdResults GetActiveAwards(GameClient client, Server.TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, int roleID, int activityType, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; try { string strcmd = ""; Activity instActivity = Global.GetActivity((ActivityTypes)activityType); if (null == instActivity) { strcmd = string.Format("{0}:{1}:0", -1, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } //是否在领取奖励期限内 if (!instActivity.CanGiveAward()) { strcmd = string.Format("{0}:{1}:0", -10, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } // if(!instActivity. //判断背包是否够用, if (!instActivity.HasEnoughBagSpaceForAwardGoods(client)) { strcmd = string.Format("{0}:{1}:0", -20, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } string[] dbFields = null; // nDBExecuteID = 0; //Global.GetDBServerExecuteActivityAwardCmdID((ActivityTypes)activityType); Int32 nDBExecuteID = (int)TCPGameServerCmds.CMD_SPR_GETNEWZONEACTIVEAWARD; string dbCmds = Global.GetActivityRequestCmdString((ActivityTypes)activityType, client, activityType); if (nDBExecuteID <= 0 || string.IsNullOrEmpty(dbCmds)) { strcmd = string.Format("{0}:{1}:0", -4, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } //通知gamedbserver 领取奖励,gamedbserver 判断如果可以领取,设置数据库领取标志,同时计算奖励额度条件,比如排名,充值额度 Global.RequestToDBServer(tcpClientPool, pool, nDBExecuteID, dbCmds, out dbFields); if (null == dbFields || dbFields.Length != 3) { strcmd = string.Format("{0}:{1}:0", -5, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } int result = Global.SafeConvertToInt32(dbFields[0]); //gamedbserver 设置相关领取标志出错,不能领取 if (result <= 0) { strcmd = string.Format("{0}:{1}:0", result, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } //开始发放奖励,奖励分 为元宝奖励 和 物品奖励,根据不同的活动给予不同的奖励 if (!instActivity.GiveAward(client, Global.SafeConvertToInt32(dbFields[1]))) { strcmd = string.Format("{0}:{1}:0", -7, activityType); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } //if ((ActivityTypes)activityType == ActivityTypes.InputJiaSong) //{ // //充值加送公告 // Global.BroadcastJiaSongOk(client); //} strcmd = string.Format("{0}:{1}:{2}", 1, activityType, dbFields[1]); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "GetActiveAwards", false); } tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN); return(TCPProcessCmdResults.RESULT_DATA); }
/// <summary> /// 获得新区活动奖励 /// </summary> /// <param name="tcpMgr"></param> /// <param name="socket"></param> /// <param name="tcpClientPool"></param> /// <param name="pool"></param> /// <param name="nID"></param> /// <param name="data"></param> /// <param name="count"></param> /// <param name="tcpOutPacket"></param> /// <returns></returns> public static TCPProcessCmdResults ProcessGetActiveAwards(Server.TCPManager tcpMgr, TMSKSocket socket, Server.TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) //解析错误 { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID)); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN); return(TCPProcessCmdResults.RESULT_DATA); } try { string[] fields = cmdData.Split(':'); if (fields.Length != 3) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData)); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN); return(TCPProcessCmdResults.RESULT_DATA); } int roleID = Convert.ToInt32(fields[0]); int activityType = Global.SafeConvertToInt32(fields[1]); int extTag = Global.SafeConvertToInt32(fields[2]); GameClient client = GameManager.ClientMgr.FindClient(socket); if (null == client || client.ClientData.RoleID != roleID) { LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID)); return(TCPProcessCmdResults.RESULT_FAILED); } switch (activityType) { case (int)ActivityTypes.NewZoneUpLevelMadman: { return(NewZoneActiveManager.GetNewLevelUpMadmanAward(client, pool, nID, roleID, activityType, extTag, out tcpOutPacket)); } case (int)ActivityTypes.NewZoneConsumeKing: case (int)ActivityTypes.NewZoneFanli: case (int)ActivityTypes.NewZoneRechargeKing: case (int)ActivityTypes.NewZoneBosskillKing: { return(NewZoneActiveManager.GetActiveAwards(client, tcpClientPool, pool, nID, roleID, activityType, out tcpOutPacket)); } } } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false); } tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN); return(TCPProcessCmdResults.RESULT_DATA); }