예제 #1
0
        public static TCPProcessCmdResults ProcessAdvanceLingYuLevel(
            TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool,
            TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            string[] fields = null;
            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                fields = cmdData.Split(':');
                //角色id:翎羽Type:材料不足时消耗钻石
                if (fields.Length != 3)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                int        roleID = Convert.ToInt32(fields[0]);
                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);
                }

                int type = Convert.ToInt32(fields[1]);
                int useZuanshiIfNoMaterial = Convert.ToInt32(fields[2]);

                LingYuError lyError = LingYuManager.AdvanceLingYuLevel(client, roleID, type, useZuanshiIfNoMaterial);
                LingYuData  lyData  = null;
                lock (client.ClientData.LingYuDict)
                {
                    if (!client.ClientData.LingYuDict.TryGetValue(type, out lyData))
                    {
                        lyData       = new LingYuData();
                        lyData.Type  = type;
                        lyData.Level = DEFAULT_LINGYU_LEVEL;
                        lyData.Suit  = 0;
                    }
                }

                string strcmd = string.Format("{0}:{1}:{2}:{3}", roleID, (int)lyError, lyData.Type, lyData.Level);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessAdvanceLingYuLevel", false);
            }

            return(TCPProcessCmdResults.RESULT_DATA);
        }
예제 #2
0
 public static string Error2Str(LingYuError lyError)
 {
     if (lyError == LingYuError.Success)
     {
         return(Global.GetLang("成功"));
     }
     else if (lyError == LingYuError.NotOpen)
     {
         return(Global.GetLang("翅膀阶数或星级不满足翎羽开放条件"));
     }
     else if (lyError == LingYuError.LevelFull)
     {
         return(Global.GetLang("等级已满,无法提升"));
     }
     else if (lyError == LingYuError.NeedLevelUp)
     {
         return(Global.GetLang("必须先提升等级"));
     }
     else if (lyError == LingYuError.NeedSuitUp)
     {
         return(Global.GetLang("必须先提升品阶"));
     }
     else if (lyError == LingYuError.SuitFull)
     {
         return(Global.GetLang("品阶已满,无法提升"));
     }
     else if (lyError == LingYuError.LevelUpMaterialNotEnough)
     {
         return(Global.GetLang(" 提升等级所需材料不足"));
     }
     else if (lyError == LingYuError.LevelUpJinBiNotEnough)
     {
         return(Global.GetLang("提升等级所需金币不足"));
     }
     else if (lyError == LingYuError.SuitUpMaterialNotEnough)
     {
         return(Global.GetLang("提升品阶所需材料不足"));
     }
     else if (lyError == LingYuError.SuitUpJinBiNotEnough)
     {
         return(Global.GetLang("提升品阶所需金币不足"));
     }
     else if (lyError == LingYuError.ErrorConfig)
     {
         return(Global.GetLang("配置错误"));
     }
     else if (lyError == LingYuError.ErrorParams)
     {
         return(Global.GetLang("传来的参数错误"));
     }
     else if (lyError == LingYuError.ZuanShiNotEnough)
     {
         return(Global.GetLang("钻石不足"));
     }
     else if (lyError == LingYuError.DBSERVERERROR)
     {
         return(Global.GetLang("与dbserver通信失败"));
     }
     else
     {
         return("unknown");
     }
 }