Esempio n. 1
0
        public bool ProcessGetKuaFuBossStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                KuaFuBossSceneInfo  sceneItem = null;
                KuaFuBossGameStates timeState = KuaFuBossGameStates.None;
                int result  = (int)KuaFuBossGameStates.None;
                int groupId = 0;
                RuntimeData.RoleId2JoinGroup.TryGetValue(client.ClientData.RoleID, out groupId);

                CheckCondition(client, ref sceneItem, ref timeState);
                if (groupId > 0)
                {
                    if (timeState >= KuaFuBossGameStates.SignUp && timeState <= KuaFuBossGameStates.Wait)
                    {
                        int state = YongZheZhanChangClient.getInstance().GetKuaFuRoleState(client.ClientData.RoleID);
                        if (state >= (int)KuaFuRoleStates.SignUp)
                        {
                            result = (int)KuaFuBossGameStates.Wait;
                        }
                        else
                        {
                            result = (int)KuaFuBossGameStates.NotJoin;
                        }
                    }
                    else if (timeState == KuaFuBossGameStates.Start)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.ContainsKey(client.ClientData.RoleID))
                        {
                            result = (int)KuaFuBossGameStates.Start;
                        }
                    }
                }
                else
                {
                    if (timeState == KuaFuBossGameStates.SignUp)
                    {
                        result = (int)KuaFuBossGameStates.SignUp;
                    }
                    else if (timeState == KuaFuBossGameStates.Wait || timeState == KuaFuBossGameStates.Start)
                    {
                        // 未参加本次活动
                        result = (int)KuaFuBossGameStates.NotJoin;
                    }
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// 罗兰城战攻防竞价申请指令处理
        /// </summary>
        /// <param name="client"></param>
        /// <param name="nID"></param>
        /// <param name="bytes"></param>
        /// <param name="cmdParams"></param>
        /// <returns></returns>
        public bool ProcessKuaFuBossJoinCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result = StdErrorCode.Error_Success_No_Info;

                do
                {
                    KuaFuBossSceneInfo  sceneItem = null;
                    KuaFuBossGameStates state     = KuaFuBossGameStates.None;
                    if (!CheckMap(client))
                    {
                        result = StdErrorCode.Error_Denied_In_Current_Map;
                    }
                    else
                    {
                        result = CheckCondition(client, ref sceneItem, ref state);
                    }

                    if (state != KuaFuBossGameStates.SignUp)
                    {
                        result = StdErrorCode.Error_Not_In_valid_Time; //非报名时间
                    }
                    else if (RuntimeData.RoleId2JoinGroup.ContainsKey(client.ClientData.RoleID))
                    {
                        result = StdErrorCode.Error_Operation_Denied; // 已经报名了
                    }

                    if (result >= 0)
                    {
                        int gropuId = sceneItem.Id;
                        result = YongZheZhanChangClient.getInstance().YongZheZhanChangSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID,
                                                                                             (int)GameTypes.KuaFuBoss, gropuId, client.ClientData.CombatForce);
                        if (result > 0)
                        {
                            RuntimeData.RoleId2JoinGroup[client.ClientData.RoleID] = gropuId;
                            client.ClientData.SignUpGameType = (int)GameTypes.KuaFuBoss;
                        }
                    }
                } while (false);

                //发送结果给客户端
                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Esempio n. 3
0
 public bool ProcessKuaFuBossJoinCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         KuaFuBossSceneInfo  sceneItem = null;
         KuaFuBossGameStates state     = KuaFuBossGameStates.None;
         int result;
         if (!this.CheckMap(client))
         {
             result = -21;
         }
         else
         {
             result = this.CheckCondition(client, ref sceneItem, ref state);
         }
         if (state != KuaFuBossGameStates.SignUp)
         {
             result = -2001;
         }
         else if (this.RuntimeData.RoleId2JoinGroup.ContainsKey(client.ClientData.RoleID))
         {
             result = -12;
         }
         if (result >= 0)
         {
             int gropuId = sceneItem.Id;
             result = YongZheZhanChangClient.getInstance().YongZheZhanChangSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID, 6, gropuId, client.ClientData.CombatForce);
             if (result > 0)
             {
                 this.RuntimeData.RoleId2JoinGroup[client.ClientData.RoleID] = gropuId;
                 client.ClientData.SignUpGameType = 6;
             }
         }
         client.sendCmd <int>(nID, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Esempio n. 4
0
 public bool ProcessKuaFuBossEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         KuaFuBossSceneInfo  sceneItem = null;
         KuaFuBossGameStates state     = KuaFuBossGameStates.None;
         int result = 0;
         if (!this.CheckMap(client))
         {
             result = -21;
         }
         else
         {
             result = this.CheckCondition(client, ref sceneItem, ref state);
         }
         if (state == KuaFuBossGameStates.Start)
         {
             KuaFuServerLoginData kuaFuServerLoginData = null;
             lock (this.RuntimeData.Mutex)
             {
                 if (this.RuntimeData.RoleIdKuaFuLoginDataDict.TryGetValue(client.ClientData.RoleID, out kuaFuServerLoginData))
                 {
                     KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                     if (null != clientKuaFuServerLoginData)
                     {
                         clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                         clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                         clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                         clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                         clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                         clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                         clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                         clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                     }
                 }
                 else
                 {
                     result = -11000;
                 }
             }
             if (result >= 0)
             {
                 result = YongZheZhanChangClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame, false);
                 if (result >= 0)
                 {
                     GlobalNew.RecordSwitchKuaFuServerLog(client);
                     client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                 }
                 else
                 {
                     Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                 }
             }
         }
         else
         {
             result = -2001;
         }
         client.sendCmd <int>(nID, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Esempio n. 5
0
        private int CheckCondition(GameClient client, ref KuaFuBossSceneInfo sceneItem, ref KuaFuBossGameStates state)
        {
            int result = 0;

            sceneItem = null;
            if (!this.IsGongNengOpened(client, true))
            {
                result = -13;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    if (!this.RuntimeData.LevelRangeSceneIdDict.TryGetValue(new RangeKey(Global.GetUnionLevel(client, false)), out sceneItem))
                    {
                        return(-12);
                    }
                }
                result = -2001;
                DateTime now = TimeUtil.NowDateTime();
                lock (this.RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpStartSecs && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpStartSecs)
                            {
                                state  = KuaFuBossGameStates.None;
                                result = -2001;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpEndSecs)
                            {
                                state  = KuaFuBossGameStates.SignUp;
                                result = 1;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i])
                            {
                                state  = KuaFuBossGameStates.Wait;
                                result = 1;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i + 1])
                            {
                                state  = KuaFuBossGameStates.Start;
                                result = 1;
                            }
                            else
                            {
                                state  = KuaFuBossGameStates.None;
                                result = -2001;
                            }
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 6
0
        public bool ProcessKuaFuBossEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                KuaFuBossSceneInfo  sceneItem = null;
                KuaFuBossGameStates state     = KuaFuBossGameStates.None;
                int result = StdErrorCode.Error_Success_No_Info;

                if (!CheckMap(client))
                {
                    result = StdErrorCode.Error_Denied_In_Current_Map;
                }
                else
                {
                    result = CheckCondition(client, ref sceneItem, ref state);
                }

                if (state == KuaFuBossGameStates.Start)
                {
                    KuaFuServerLoginData kuaFuServerLoginData = null;
                    lock (RuntimeData.Mutex)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.TryGetValue(client.ClientData.RoleID, out kuaFuServerLoginData))
                        {
                            KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                            if (null != clientKuaFuServerLoginData)
                            {
                                clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                                clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                                clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                                clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                                clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                                clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                                clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                                clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                            }
                        }
                        else
                        {
                            result = StdErrorCode.Error_Server_Busy;
                        }
                    }

                    if (result >= 0)
                    {
                        result = YongZheZhanChangClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame);
                        if (result >= 0)
                        {
                            GlobalNew.RecordSwitchKuaFuServerLog(client);
                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KF_SWITCH_SERVER, Global.GetClientKuaFuServerLoginData(client));
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                        }
                    }
                }
                else
                {
                    result = StdErrorCode.Error_Not_In_valid_Time;
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Esempio n. 7
0
        // 检查勇者战场当前处于什么时间状态
        private int CheckCondition(GameClient client, ref KuaFuBossSceneInfo sceneItem, ref KuaFuBossGameStates state)
        {
            int result = 0;

            sceneItem = null;

            do
            {
                if (!IsGongNengOpened(client, true))
                {
                    result = StdErrorCode.Error_Type_Not_Match;
                    break;
                }

                lock (RuntimeData.Mutex)
                {
                    if (!RuntimeData.LevelRangeSceneIdDict.TryGetValue(new RangeKey(Global.GetUnionLevel(client)), out sceneItem))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }
                }

                result = StdErrorCode.Error_Not_In_valid_Time;
                DateTime now = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                            now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                            now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs)
                            {
                                state  = KuaFuBossGameStates.None;
                                result = StdErrorCode.Error_Not_In_valid_Time;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - sceneItem.SignUpEndSecs)
                            {
                                state  = KuaFuBossGameStates.SignUp;
                                result = StdErrorCode.Error_Success;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i])
                            {
                                state  = KuaFuBossGameStates.Wait;
                                result = StdErrorCode.Error_Success;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i + 1])
                            {
                                state  = KuaFuBossGameStates.Start;
                                result = StdErrorCode.Error_Success;
                            }
                            else
                            {
                                state  = KuaFuBossGameStates.None;
                                result = StdErrorCode.Error_Not_In_valid_Time;
                            }
                            break;
                        }
                    }
                }
            } while (false);

            return(result);
        }