コード例 #1
0
        /// <summary>
        /// 处理扭蛋角色列表信息
        /// </summary>
        /// <param name="pack">封包数据结构体</param>
        /// <returns>处理结果标志</returns>
        private static int ProcessGachaLineup(PacketInfo pack)
        {
            JArray cards = (JArray)pack.data["masterGachaItemList"];

            if (cards.Count > 0)
            {
                foreach (JObject card in cards)
                {
                    LogsHelper.LogDebug(card["itemId"].ToString() + "=" + card["name"].ToString());
                }
            }
            return(E_SUCCESS);
        }
コード例 #2
0
        /// <summary>
        /// 解析封包结构体
        /// </summary>
        /// <param name="pack">封包结构体</param>
        /// <returns>解析结果</returns>
        private static int Process(PacketInfo pack)
        {
            try
            {
                //处理日服DMM用户信息-获取用户昵称
                if ((DataUtil.Game.gameServer == (int)GameInfo.ServersList.Japan || DataUtil.Game.gameServer == (int)GameInfo.ServersList.JapanR18 ||
                     DataUtil.Game.gameServer == (int)GameInfo.ServersList.TradChinese || DataUtil.Game.gameServer == (int)GameInfo.ServersList.TradChineseR18) && pack.funcUrl.IndexOf("/social/") != -1)
                {
                    if (pack.funcApi == "/rpc")
                    {
                        return(ProcessDMMUserInfo(pack));
                    }
                    else
                    {
                        return(E_FAILED);
                    }
                }
                //处理美服用户信息-获取用户昵称
                else if ((DataUtil.Game.gameServer == (int)GameInfo.ServersList.American || DataUtil.Game.gameServer == (int)GameInfo.ServersList.AmericanR18) && pack.funcUrl.IndexOf("/rpc") != -1)
                {
                    return(ProcessNutakuUserInfo(pack));
                }
                //判断是否为游戏接口封包
                else if (pack.funcUrl.IndexOf("/api/v1/") != -1)
                {
#if DEBUG
                    LogsHelper.LogDebug("【请求】" + pack.funcApi + "\r\n【响应】" + pack.rawData + "\r\n================================================================");
                    LogsHelper.LogDebug("【时间】" + DateTime.UtcNow);
#endif
                    //更新服务器时间
                    if (pack.data["serverTime"] != null)
                    {
                        DataUtil.Game.serverTime = Convert.ToDateTime(pack.data["serverTime"].ToString());
                    }
                    //确认游戏是否在线
                    if (pack.data["resultCode"] != null)
                    {
                        int status = Convert.ToInt16(pack.data["resultCode"].ToString());
                        if (status == 1)
                        {
                            DataUtil.Game.isOnline = false;
                        }
                    }
                    //----- 游戏数据处理开始 -----
                    //游戏登录
                    if (pack.funcApi == "/user/login")
                    {
                        return(ProcessPlayerLoginInfo(pack));
                    }
                    //好友列表
                    else if (pack.funcApi == "/friend/getFriendList")
                    {
                        return(ProcessFriendList(pack));
                    }
                    //花盆开花时间信息
                    else if (pack.funcApi == "/garden/getUserGardenPlant")
                    {
                        return(ProcessUserGardenPlant(pack));
                    }
                    //收获花盆
                    else if (pack.funcApi == "/garden/saveGardenPlantHarvest")
                    {
                        return(ProcessGardenPlantHarvest(pack));
                    }
                    //游戏探索
                    else if (pack.funcApi == "/searchQuest/saveSearchQuest")
                    {
                        return(ProcessPlayerSearchInfo(pack));
                    }
                    //主页BOSS战开始
                    else if (pack.funcApi == "/raidBoss/saveRaidBossStart")
                    {
                        return(ProcessRaidBossStart(pack));
                    }
                    //主页BOSS战完成
                    else if (pack.funcApi == "/raidBoss/saveRaidBossFinish")
                    {
                        return(ProcessRaidBossFinish(pack));
                    }
                    //个人BOSS战开始
                    else if (pack.funcApi == "/eventBoss/saveSummonBossStart")
                    {
                        return(ProcessSummonBossStart(pack));
                    }
                    //个人BOSS战完成
                    else if (pack.funcApi == "/eventBoss/saveSummonBossFinish")
                    {
                        return(ProcessSummonBossFinish(pack));
                    }
                    //进副本信息
                    else if (pack.funcApi == "/dungeon/saveStageStart" || pack.funcApi == "/dungeon/saveEventStageStart" || pack.funcApi == "/dungeon/saveEncounterStageStart" || pack.funcApi == "/dungeon/saveWhaleStageStart")
                    {
                        return(ProcessDungeonStageStart(pack));
                    }
                    //副本完成信息
                    else if (pack.funcApi == "/dungeon/saveStageSuccess" || pack.funcApi == "/dungeon/saveEventStageSuccess" || pack.funcApi == "/dungeon/saveEncounterStageSuccess" || pack.funcApi == "/dungeon/saveWhaleStageSuccess")
                    {
                        return(ProcessDungeonStageSuccess(pack));
                    }
                    //副本放弃信息
                    else if (pack.funcApi == "/dungeon/saveStageFailed" || pack.funcApi == "/dungeon/saveEventStageFailed" || pack.funcApi == "/dungeon/saveEncounterStageFailed" || pack.funcApi == "/dungeon/saveWhaleStageFailed")
                    {
                        return(ProcessDungeonStageFailed(pack));
                    }
                    //副本失败信息
                    else if (pack.funcApi == "/dungeon/saveStageDestroyed" || pack.funcApi == "/dungeon/saveEventStageDestroyed" || pack.funcApi == "/dungeon/saveEncounterStageDestroyed" || pack.funcApi == "/dungeon/saveWhaleStageDestroyed")
                    {
                        return(ProcessDungeonStageDestroyed(pack));
                    }
                    //获取主页BOSS列表(副本失败检查)
                    else if (pack.funcApi == "/raidBoss/getRaidBossList")
                    {
                        return(ProcessRaidBossList(pack));
                    }
                    //接受礼物盒子里的单件物品
                    else if (pack.funcApi == "/present/savePresentReceived")
                    {
                        return(ProcessPresentReceived(pack));
                    }
                    //接收礼物盒子里的全部物品
                    else if (pack.funcApi == "/present/savePresentAllReceived")
                    {
                        return(ProcessPresentReceivedAll(pack));
                    }
                    //角色合成
                    else if (pack.funcApi == "/character/saveSynthesis")
                    {
                        return(E_SUCCESS);
                    }
                    //角色进化
                    else if (pack.funcApi == "/character/saveEvolve")
                    {
                        return(E_SUCCESS);
                    }
                    //装备强化
                    else if (pack.funcApi == "/character/saveEquipmentSynthesis")
                    {
                        return(E_SUCCESS);
                    }
                    //出售角色和装备
                    else if (pack.funcApi == "/character/saveSale" || pack.funcApi == "/character/saveSaleEquipment")
                    {
                        return(ProcessSellSave(pack));
                    }
                    //扭蛋
                    else if (pack.funcApi == "/gacha/saveGacha")
                    {
                        return(ProcessGachaResult(pack));
                    }
                    //----- DEBUG处理包 -----
#if DEBUG
                    //处理蛋池卡角色名列表
                    else if (pack.funcApi == "/gacha/getPremiumGachaLineup")
                    {
                        return(ProcessGachaLineup(pack));
                    }
#endif
                    //其他不须解析的封包,只返回E_FAILED结果
                    else
                    {
                        return(E_FAILED);
                    }
                }
                //非游戏接口的封包,只返回E_FAILED结果
                else
                {
                    return(E_FAILED);
                }
            }
            //解析失败或者解析过程发生错误,返回E_FALT_ERROR
            catch
            {
                return(E_FALT_ERROR);
            }
        }