Example #1
0
 public bool ProcessGetKarenBattleStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result    = 0;
         int westcount = 0;
         int eastcount = 0;
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 westcount,
                 eastcount,
                 "",
                 ""
             }), false);
             return(true);
         }
         KarenGameStates timeState = KarenGameStates.None;
         this.CheckTimeCondition(ref timeState);
         if (this.CheckCanEnterKarenBattle(client))
         {
             if (timeState == KarenGameStates.Wait)
             {
                 result = 1;
             }
             else if (timeState == KarenGameStates.Start)
             {
                 lock (this.Mutex)
                 {
                     foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict)
                     {
                         KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key);
                         if (null != fubenData)
                         {
                             JunTuanRankData rankData = this.GetJunTuanRankDataByClient(client);
                             if (null != rankData)
                             {
                                 SceneUIClasses sceneType = Global.GetMapSceneType(item.Value.MapCode);
                                 if (sceneType == SceneUIClasses.KarenWest)
                                 {
                                     westcount = fubenData.GetRoleCountWithEnter(rankData.Rank);
                                 }
                                 else
                                 {
                                     eastcount = fubenData.GetRoleCountWithEnter(rankData.Rank);
                                 }
                             }
                         }
                     }
                 }
                 result = 2;
             }
         }
         else if (timeState == KarenGameStates.Wait || timeState == KarenGameStates.Start)
         {
             JunTuanRankData RankData = this.GetJunTuanRankDataByClient(client);
             if (null != RankData)
             {
                 result = 3;
             }
             else
             {
                 result = 4;
             }
         }
         string            eastjtname = "";
         string            westjtname = "";
         List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData();
         if (null != LingDiList)
         {
             foreach (LingDiData item2 in LingDiList)
             {
                 SceneUIClasses mapType = this.ConvertCaiJiLingDiTypeToMapSceneType(item2.LingDiType);
                 if (mapType == SceneUIClasses.KarenWest)
                 {
                     westjtname = item2.JunTuanName;
                 }
                 else if (mapType == SceneUIClasses.KarenEast)
                 {
                     eastjtname = item2.JunTuanName;
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
         {
             result,
             westcount,
             eastcount,
             westjtname,
             eastjtname
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Example #2
0
 public bool ProcessKarenBattleEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result = 0;
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd <int>(nID, result, false);
             return(true);
         }
         int roleID  = Global.SafeConvertToInt32(cmdParams[0]);
         int mapCode = Global.SafeConvertToInt32(cmdParams[1]);
         KarenBattleSceneInfo sceneItem = null;
         KarenGameStates      state     = KarenGameStates.None;
         int             eastcount      = 0;
         int             westcount      = 0;
         JunTuanRankData rankData       = this.GetJunTuanRankDataByClient(client);
         if (rankData == null || !this.CheckCanEnterKarenBattle(client))
         {
             result = -5;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         if (!this.CheckMap(client))
         {
             result = -21;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         result = this.CheckTimeCondition(ref state);
         if (state != KarenGameStates.Start)
         {
             result = -2001;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         lock (this.Mutex)
         {
             if (!this.SceneDataDict.TryGetValue(mapCode, out sceneItem))
             {
                 result = -5;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict)
             {
                 KarenFuBenData fbData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key);
                 if (null != fbData)
                 {
                     SceneUIClasses sType = Global.GetMapSceneType(item.Value.MapCode);
                     if (sType == SceneUIClasses.KarenWest)
                     {
                         westcount = fbData.GetRoleCountWithEnter(rankData.Rank);
                     }
                     else
                     {
                         eastcount = fbData.GetRoleCountWithEnter(rankData.Rank);
                     }
                 }
             }
             DateTime lastEnterTime = Global.GetRoleParamsDateTimeFromDB(client, "20019");
             if (!this.GMTest && TimeUtil.NowDateTime().Ticks - lastEnterTime.Ticks < 10000000L * (long)sceneItem.EnterCD)
             {
                 GameManager.ClientMgr.NotifyImportantMsg(client, string.Format(GLang.GetLang(2615, new object[0]), sceneItem.EnterCD), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                 result = -2007;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             KuaFuServerInfo kfserverInfo = null;
             KarenFuBenData  fubenData    = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(mapCode);
             if (fubenData == null || !KuaFuManager.getInstance().TryGetValue(fubenData.ServerId, out kfserverInfo))
             {
                 result = -11000;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             if (fubenData.GetRoleCountWithEnter(rankData.Rank) >= sceneItem.MaxEnterNum)
             {
                 result = -22;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             SceneUIClasses       sceneType = Global.GetMapSceneType(sceneItem.MapCode);
             KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
             if (null != clientKuaFuServerLoginData)
             {
                 clientKuaFuServerLoginData.RoleId     = client.ClientData.RoleID;
                 clientKuaFuServerLoginData.GameId     = (long)fubenData.GameId;
                 clientKuaFuServerLoginData.GameType   = fubenData.GameType;
                 clientKuaFuServerLoginData.EndTicks   = fubenData.EndTime.Ticks;
                 clientKuaFuServerLoginData.ServerId   = client.ServerId;
                 clientKuaFuServerLoginData.ServerIp   = kfserverInfo.Ip;
                 clientKuaFuServerLoginData.ServerPort = kfserverInfo.Port;
                 clientKuaFuServerLoginData.FuBenSeqId = 0;
             }
             if (result >= 0)
             {
                 result = JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, client.ClientData.RoleID, (int)clientKuaFuServerLoginData.GameId, rankData.Rank, 4);
                 if (result >= 0)
                 {
                     GlobalNew.RecordSwitchKuaFuServerLog(client);
                     client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                 }
                 else
                 {
                     Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
         {
             result,
             0,
             westcount,
             eastcount
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }