Exemplo n.º 1
0
        internal Logger(KanColleProxy proxy)
        {
            this.shipmats = new int[5];

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/createitem")
            .Select(x =>
            {
                SvData <kcsapi_createitem> result;
                return(SvData.TryParse(x, out result) ? result : null);
            })
            .Where(x => x != null && x.IsSuccess)
            .Subscribe(x => this.CreateItem(x.Data, x.RequestBody));

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/createship")
            .Select(x =>
            {
                SvData <kcsapi_createship> result;
                return(SvData.TryParse(x, out result) ? result : null);
            })
            .Where(x => x != null && x.IsSuccess)
            .Subscribe(x => this.CreateShip(x.RequestBody));

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/kdock")
            .TryParse <kcsapi_kdock[]>()
            .Subscribe(this.KDock);

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_sortie/battleresult")
            .TryParse <kcsapi_battleresult>()
            .Subscribe(this.BattleResult);
        }
Exemplo n.º 2
0
 /// <summary>
 /// FiddlerCore でフックした <see cref="Session" /> オブジェクトの <see cref="Session.ResponseBody" /> データを
 /// <see cref="SvData" /> 型にパースします。
 /// </summary>
 public static IObservable <SvData> TryParse(this IObservable <Session> source)
 {
     return(source.Select(x =>
     {
         SvData result;
         return SvData.TryParse(x, out result) ? result : null;
     }));
 }
Exemplo n.º 3
0
        public static SvData <T> TryParse <T>(this Session x, bool IsSuccess = true)
        {
            SvData <T> result;

            return(SvData.TryParse(x, out result)
                                ? ((!IsSuccess || result.IsSuccess) ? result : null)
                                : null);
        }
Exemplo n.º 4
0
        internal Homeport(KanColleProxy proxy)
        {
            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/basic")
            .TryParse <kcsapi_basic>()
            .Subscribe(x => this.Admiral = new Admiral(x));

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/material")
            .TryParse <kcsapi_material[]>()
            .Subscribe(x => this.Materials = new Materials(x.Select(m => new Material(m)).ToArray()));

            this.Ships  = new MemberTable <Ship>();
            this.Fleets = new MemberTable <Fleet>();
            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/ship")
            .Select(x => { SvData <kcsapi_ship2[]> result; return(SvData.TryParse(x, out result) ? result : null); })
            .Where(x => x != null && x.IsSuccess)
            .Subscribe(x => this.Ships = new MemberTable <Ship>(x.Data.Select(s => new Ship(this, s))));

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/ship2")
            .Select(x => { SvData <kcsapi_ship2[]> result; return(SvData.TryParse(x, out result) ? result : null); })
            .Where(x => x != null && x.IsSuccess)
            .Subscribe(x =>
            {
                this.Ships = new MemberTable <Ship>(x.Data.Select(s => new Ship(this, s)));
                this.UpdateFleets(x.Fleets);
            });
            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/ship3")
            .TryParse <kcsapi_ship3>()
            .Subscribe(x =>
            {
                this.Ships = new MemberTable <Ship>(x.api_ship_data.Select(s => new Ship(this, s)));
                this.UpdateFleets(x.api_deck_data);
            });

            this.SlotItems = new MemberTable <SlotItem>();
            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/slotitem")
            .TryParse <kcsapi_slotitem[]>()
            .Subscribe(x => this.SlotItems = new MemberTable <SlotItem>(x.Select(s => new SlotItem(s))));

            this.UseItems = new MemberTable <UseItem>();
            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/useitem")
            .TryParse <kcsapi_useitem[]>()
            .Subscribe(x => this.UseItems = new MemberTable <UseItem>(x.Select(s => new UseItem(s))));

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/deck")
            .TryParse <kcsapi_deck[]>()
            .Subscribe(this.UpdateFleets);

            proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_get_member/deck_port")
            .TryParse <kcsapi_deck[]>()
            .Subscribe(this.UpdateFleets);

            this.Dockyard   = new Dockyard(proxy);
            this.Repairyard = new Repairyard(this, proxy);
            this.Quests     = new Quests(proxy);
            this.Logger     = new Logger(proxy);
        }
Exemplo n.º 5
0
        /// <summary>
        /// FiddlerCore でフックした <see cref="Session" /> オブジェクトの <see cref="Session.ResponseBody" /> データを
        /// <see cref="SvData" /> 型にパースします。
        /// </summary>
        public static IObservable <SvData> TryParse(this IObservable <Session> source)
        {
            Func <Session, SvData> converter = session =>
            {
                SvData result;
                return(SvData.TryParse(session, out result) ? result : null);
            };

            return(source.Select(converter).Where(x => x != null && x.IsSuccess));
        }
        public void Initialieze()
        {
            var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy());

            /*
             * var basic = proxy.api_get_member_basic.TryParse<kcsapi_basic>().FirstAsync().ToTask();
             * var kdock = proxy.api_get_member_kdock.TryParse<kcsapi_kdock[]>().FirstAsync().ToTask();
             * var sitem = proxy.api_get_member_slot_item.TryParse<kcsapi_slotitem[]>().FirstAsync().ToTask();
             */
            var requireInfo = proxy.api_get_member_require_info.TryParse <kcsapi_require_info>().FirstAsync().ToTask();


            this.Updater      = new Updater();
            this.Translations = new Translations();

            proxy.api_start2.FirstAsync().Subscribe(async session =>
            {
                var timeout = Task.Delay(TimeSpan.FromSeconds(20));
                //var canInitialize = await Task.WhenAny(new Task[] { basic, kdock, sitem }.WhenAll(), timeout) != timeout;
                var canInitialize = await Task.WhenAny(new Task[] { requireInfo }.WhenAll(), timeout) != timeout;

                // タイムアウト仕掛けてるのは、今後のアップデートで basic, kdock, slot_item のいずれかが来なくなったときに
                // 起動できなくなる (IsStarted を true にできなくなる) のを防ぐため
                // -----
                // ま、そんな規模の変更があったらそもそもまともに動作せんだろうがな ☝(◞‸◟)☝ 野良ツールはつらいよ

                SvData <kcsapi_start2> svd;
                if (!SvData.TryParse(session, out svd))
                {
                    return;
                }

                this.Master = new Master(svd.Data);
                if (this.Homeport == null)
                {
                    this.Homeport = new Homeport(proxy);
                }

                if (canInitialize)
                {
                    /*
                     * this.Homeport.UpdateAdmiral((await basic).Data);
                     * this.Homeport.Itemyard.Update((await sitem).Data);
                     * this.Homeport.Dockyard.Update((await kdock).Data);
                     */
                    var data = await requireInfo;
                    this.Homeport.UpdateAdmiral(data.Data.api_basic);
                    this.Homeport.Itemyard.Update(data.Data.api_slot_item);
                    this.Homeport.Dockyard.Update(data.Data.api_kdock);
                }

                this.IsStarted = true;
            });
        }
Exemplo n.º 7
0
        public void Initialieze()
        {
            this.Translations  = new Translations();
            this.WebTranslator = new WebTranslator();
            this.Updater       = new Updater();

            var proxy             = this.Proxy ?? (this.Proxy = new KanColleProxy());
            var requireInfoSource = proxy.api_get_member_require_info
                                    .TryParse <kcsapi_require_info>()
                                    .FirstAsync()
                                    .ToTask();

            proxy.api_start2.FirstAsync().Subscribe(async session =>
            {
                var timeout       = Task.Delay(TimeSpan.FromSeconds(20));
                var canInitialize = await Task.WhenAny(requireInfoSource, timeout) != timeout;

                SvData <kcsapi_start2> svd;
                if (!SvData.TryParse(session, out svd))
                {
                    return;
                }

                this.Master = new Master(svd.Data);
                if (this.Homeport == null)
                {
                    this.Homeport = new Homeport(proxy);
                }

                if (canInitialize)
                {
                    var requireInfo = await requireInfoSource;
                    this.Homeport.UpdateAdmiral(requireInfo.Data.api_basic);
                    this.Homeport.Itemyard.Update(requireInfo.Data.api_slot_item);
                    this.Homeport.Dockyard.Update(requireInfo.Data.api_kdock);
                }

                this.IsStarted = true;
            });
            this.Logger = new Logger(proxy);
        }
Exemplo n.º 8
0
        private LandBaseNotifier()
        {
            NotifyHost.Register("/kcsapi/api_get_member/base_air_corps", LandBaseType.Instance, s =>
            {
                SvData <base_air_corps[]> svData;
                SvData.TryParse(s, out svData);
                this._data = svData?.Data;
                return(this.CheckSituation(true));
            });
            NotifyHost.Register("/kcsapi/api_get_member/sortie_conditions", LandBaseType.Instance, s => this.CheckSituation());

            var proxy = KanColleClient.Current.Proxy;

            proxy.ApiSessionSource
            .Where(s => s.Request.PathAndQuery == "/kcsapi/api_req_air_corps/set_plane")
            .TryParse <req_air_corps_set_plane>()
            .Subscribe(d => this.SetPlane(int.Parse(d.Request["api_base_id"]), d.Data));

            proxy.ApiSessionSource
            .Where(s => s.Request.PathAndQuery == "/kcsapi/api_req_air_corps/change_name")
            .TryParse()
            .Subscribe(d => this.UpdateName(int.Parse(d.Request["api_base_id"]), d.Request["api_name"]));

            proxy.ApiSessionSource
            .Where(s => s.Request.PathAndQuery == "/kcsapi/api_req_air_corps/supply")
            .TryParse <req_air_corps_supply>()
            .Subscribe(d => this.Supply(int.Parse(d.Request["api_base_id"]), d.Data));

            proxy.ApiSessionSource
            .Where(s => s.Request.PathAndQuery == "/kcsapi/api_req_air_corps/set_action")
            .TryParse()
            .Subscribe(d => this.UpdateAction(
                           SplitParam(d.Request["api_base_id"]),
                           SplitParam(d.Request["api_action_kind"]))
                       );
        }
Exemplo n.º 9
0
        /// <summary>
        /// 解析 api_start2 数据信息
        /// </summary>item.ship_graph_sortno
        static void ParseSession(Session oSession)
        {
            SvData <kcsapi_start2> svd;

            if (!SvData.TryParse(oSession, out svd))
            {
                Log.Warning("GraphList.ParseSession()", "TryParse失败,无效的Session对象!");
                return;
            }

            var mst_shipgraph = svd.Data.api_mst_shipgraph
                                .ToDictionary(x => x.api_id);
            var mst_ship = svd.Data.api_mst_ship
                           .ToDictionary(x => x.api_id);
            var mst_stype = svd.Data.api_mst_stype
                            .ToDictionary(x => x.api_id);

            graphList.Clear();

            foreach (var _pair in mst_shipgraph)
            {
                var item  = new ship_graph_item();
                var _loc1 = _pair.Value;

                item.ship_id                  = _loc1.api_id;
                item.ship_filename            = _loc1.api_filename;
                item.ship_graph_sortno        = _loc1.api_sortno;
                item.ship_graph_boko_n_left   = _loc1.api_boko_n[0];
                item.ship_graph_boko_n_top    = _loc1.api_boko_n[1];
                item.ship_graph_boko_d_left   = _loc1.api_boko_d[0];
                item.ship_graph_boko_d_top    = _loc1.api_boko_d[1];
                item.ship_graph_map_n_left    = _loc1.api_map_n[0];
                item.ship_graph_map_n_top     = _loc1.api_map_n[1];
                item.ship_graph_map_d_left    = _loc1.api_map_d[0];
                item.ship_graph_map_d_top     = _loc1.api_map_d[1];
                item.ship_graph_battle_n_left = _loc1.api_battle_n[0];
                item.ship_graph_battle_n_top  = _loc1.api_battle_n[1];
                item.ship_graph_battle_d_left = _loc1.api_battle_d[0];
                item.ship_graph_battle_d_top  = _loc1.api_battle_d[1];
                item.ship_graph_ensyuf_n_left = _loc1.api_ensyuf_n[0];
                item.ship_graph_ensyuf_n_top  = _loc1.api_ensyuf_n[1];
                item.ship_graph_ensyuf_d_left = _loc1.api_ensyuf_d[0];
                item.ship_graph_ensyuf_d_top  = _loc1.api_ensyuf_d[1];
                item.ship_graph_ensyue_n_left = _loc1.api_ensyue_n[0];
                item.ship_graph_ensyue_n_top  = _loc1.api_ensyue_n[1];
                item.ship_graph_kaizo_n_left  = _loc1.api_kaizo_n[0];
                item.ship_graph_kaizo_n_top   = _loc1.api_kaizo_n[1];
                item.ship_graph_kaizo_d_left  = _loc1.api_kaizo_d[0];
                item.ship_graph_kaizo_d_top   = _loc1.api_kaizo_d[1];
                item.ship_graph_kaisyu_n_left = _loc1.api_kaisyu_n[0];
                item.ship_graph_kaisyu_n_top  = _loc1.api_kaisyu_n[1];
                item.ship_graph_kaisyu_d_left = _loc1.api_kaisyu_d[0];
                item.ship_graph_kaisyu_d_top  = _loc1.api_kaisyu_d[1];
                item.ship_graph_weda_left     = _loc1.api_weda[0];
                item.ship_graph_weda_top      = _loc1.api_weda[1];
                item.ship_graph_wedb_left     = _loc1.api_wedb[0];
                item.ship_graph_wedb_top      = _loc1.api_wedb[1];

                if (mst_ship.ContainsKey(item.ship_id))
                {
                    var _loc2 = mst_ship[item.ship_id];

                    item.ship_sortno  = _loc2.api_sortno;
                    item.ship_name    = _loc2.api_name;
                    item.ship_type_id = _loc2.api_stype;

                    if (mst_stype.ContainsKey(item.ship_type_id))
                    {
                        var _loc3 = mst_stype[item.ship_type_id];
                        item.ship_type_name   = _loc3.api_name;
                        item.ship_type_sortno = _loc3.api_sortno;
                    }

                    graphList.Add(item);
                    mst_ship.Remove(item.ship_id);
                }
                else
                {
#if DEBUG
                    Debug.WriteLine(@"CACHR> shipgraph->ship匹配失败
> {0} = {1} {2} {3}
", _loc1.ToString(), _loc1.api_id, _loc1.api_sortno, _loc1.api_filename);
#endif
                }
            }

#if DEBUG
            Debug.WriteLine("CACHR>	graphList = {0}, mst_shipgraph = {1}",
                            graphList.Count.ToString(),
                            mst_shipgraph.Count.ToString()
                            );
#endif
        }
Exemplo n.º 10
0
 /// <summary>
 /// FiddlerCore でフックした <see cref="Session"/> オブジェクトの <see cref="Session.ResponseBody"/> データを
 /// <typeparamref name="TResult"/> 型にパースします。
 /// </summary>
 public static IObservable <TResult> TryParse <TResult>(this IObservable <Session> source)
 {
     return(source.Select(x => { SvData <TResult> result; return SvData.TryParse(x, out result) ? result : null; })
            .Where(x => x != null && x.IsSuccess)
            .Select(x => x.Data));
 }
Exemplo n.º 11
0
 public ManagedSession TryParse()
 {
     parseEvent = (session) => SvData.TryParse(session, out this.svData);
     return(this);
 }