Esempio n. 1
0
        public Api_Result <bool> Charge(List <int> ship_rids, Api_req_Hokyu.enumHokyuType type)
        {
            Api_Result <bool> rslt = new Api_Result <bool>();

            rslt.data = false;
            if (ship_rids == null || ship_rids.get_Count() == 0)
            {
                rslt.state = Api_Result_State.Parameter_Error;
                return(rslt);
            }
            List <Mem_ship> ships = new List <Mem_ship>();

            ship_rids.ForEach(delegate(int x)
            {
                Mem_ship mem_ship = null;
                if (!Comm_UserDatas.Instance.User_ship.TryGetValue(x, ref mem_ship))
                {
                    rslt.state = Api_Result_State.Parameter_Error;
                    return;
                }
                ships.Add(mem_ship);
            });
            if (rslt.state == Api_Result_State.Parameter_Error)
            {
                ships.Clear();
                return(rslt);
            }
            HashSet <int> hashSet = new HashSet <int>();
            int           num     = 0;

            using (List <Mem_ship> .Enumerator enumerator = ships.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Mem_ship current = enumerator.get_Current();
                    if (Mst_DataManager.Instance.Mst_ship.ContainsKey(current.Ship_id))
                    {
                        int fuel = current.Fuel;
                        int bull = current.Bull;
                        if (type == Api_req_Hokyu.enumHokyuType.Fuel || type == Api_req_Hokyu.enumHokyuType.Bull)
                        {
                            bool flag = this.ChargeDataSet(type, current);
                            if (bull < current.Bull || fuel < current.Fuel)
                            {
                                current.SumLovToCharge();
                                num++;
                            }
                            HashSet <int> hashSet2 = this.ChargeDataSet_Onslot(Api_req_Hokyu.enumHokyuType.All, current);
                            using (HashSet <int> .Enumerator enumerator2 = hashSet2.GetEnumerator())
                            {
                                while (enumerator2.MoveNext())
                                {
                                    int current2 = enumerator2.get_Current();
                                    hashSet.Add(current2);
                                }
                            }
                            if (!flag && hashSet2.Contains(-1))
                            {
                                break;
                            }
                        }
                        else if (type == Api_req_Hokyu.enumHokyuType.All)
                        {
                            bool          flag2    = this.ChargeDataSet(Api_req_Hokyu.enumHokyuType.Bull, current);
                            bool          flag3    = this.ChargeDataSet(Api_req_Hokyu.enumHokyuType.Fuel, current);
                            HashSet <int> hashSet3 = this.ChargeDataSet_Onslot(Api_req_Hokyu.enumHokyuType.All, current);
                            if (bull < current.Bull || fuel < current.Fuel)
                            {
                                current.SumLovToCharge();
                                num++;
                            }
                            using (HashSet <int> .Enumerator enumerator3 = hashSet3.GetEnumerator())
                            {
                                while (enumerator3.MoveNext())
                                {
                                    int current3 = enumerator3.get_Current();
                                    hashSet.Add(current3);
                                }
                            }
                            if (!flag2 && !flag3 && hashSet3.Contains(-1))
                            {
                                break;
                            }
                        }
                    }
                }
            }
            if (hashSet.Contains(-2))
            {
                rslt.data = false;
            }
            else
            {
                rslt.data = true;
            }
            QuestSupply questSupply = new QuestSupply(num);

            questSupply.ExecuteCheck();
            return(rslt);
        }