Ejemplo n.º 1
0
        public Api_Result <Hashtable> Unslot_all(int ship_rid)
        {
            Api_Result <Hashtable> result = new Api_Result <Hashtable>();
            Mem_ship     mem_ship         = Comm_UserDatas.Instance.User_ship.get_Item(ship_rid);
            Mem_shipBase mem_shipBase     = new Mem_shipBase(mem_ship);

            for (int i = 0; i < Enumerable.Count <int>(mem_shipBase.Slot); i++)
            {
                Mem_slotitem mem_slotitem = null;
                int          num          = mem_shipBase.Slot.get_Item(i);
                mem_shipBase.Slot.set_Item(i, -1);
                if (num > 0 && Comm_UserDatas.Instance.User_slot.TryGetValue(num, ref mem_slotitem))
                {
                    Mst_slotitem_cost mst_slotitem_cost = null;
                    if (Mst_DataManager.Instance.Mst_slotitem_cost.TryGetValue(mem_slotitem.Slotitem_id, ref mst_slotitem_cost))
                    {
                        int addNum = mst_slotitem_cost.GetAddNum(mem_shipBase.Onslot.get_Item(i));
                        Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Add_Material(addNum);
                    }
                    mem_slotitem.UnEquip();
                }
            }
            mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship.get_Item(mem_shipBase.Ship_id), false);
            mem_ship.TrimSlot();
            return(result);
        }
Ejemplo n.º 2
0
        public Api_Result <Hashtable> Unslot_all(int ship_rid)
        {
            Api_Result <Hashtable> result = new Api_Result <Hashtable>();
            Mem_ship     mem_ship         = Comm_UserDatas.Instance.User_ship[ship_rid];
            Mem_shipBase mem_shipBase     = new Mem_shipBase(mem_ship);

            for (int i = 0; i < mem_shipBase.Slot.Count(); i++)
            {
                Mem_slotitem value = null;
                int          num   = mem_shipBase.Slot[i];
                mem_shipBase.Slot[i] = -1;
                if (num > 0 && Comm_UserDatas.Instance.User_slot.TryGetValue(num, out value))
                {
                    Mst_slotitem_cost value2 = null;
                    if (Mst_DataManager.Instance.Mst_slotitem_cost.TryGetValue(value.Slotitem_id, out value2))
                    {
                        int addNum = value2.GetAddNum(mem_shipBase.Onslot[i]);
                        Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Add_Material(addNum);
                    }
                    value.UnEquip();
                }
            }
            mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship[mem_shipBase.Ship_id], enemy_flag: false);
            mem_ship.TrimSlot();
            return(result);
        }
        private bool getCombatRationResult(out Dictionary <int, List <Mst_slotitem> > useShipInfo, out List <int> givenShips)
        {
            int mapBattleCellPassCount = this.mapInstance.MapBattleCellPassCount;

            useShipInfo = null;
            givenShips  = null;
            if (mapBattleCellPassCount < 2)
            {
                return(false);
            }
            Dictionary <int, List <Mst_slotitem> > dictionary = new Dictionary <int, List <Mst_slotitem> >();
            List <int>    list    = new List <int>();
            HashSet <int> hashSet = new HashSet <int>();

            hashSet.Add(145);
            hashSet.Add(150);
            HashSet <int> searchIds = hashSet;
            Dictionary <int, List <int> > dictionary2 = new Dictionary <int, List <int> >();
            Dictionary <int, int>         dictionary3 = Enumerable.ToDictionary <int, int, int>(this.userSubInfo.get_Keys(), (int key) => key, (int value) => 0);

            for (int i = 0; i < this.userData.ShipData.get_Count(); i++)
            {
                Mem_ship mem_ship = this.userData.ShipData.get_Item(i);
                if (mem_ship.IsFight())
                {
                    Dictionary <int, List <int> > slotIndexFromId = mem_ship.GetSlotIndexFromId(searchIds);
                    if (slotIndexFromId.get_Item(145).get_Count() != 0 || slotIndexFromId.get_Item(150).get_Count() != 0)
                    {
                        if (this.isRationLotteryWinning(mapBattleCellPassCount, mem_ship.Luck))
                        {
                            List <int> rationRecoveryShips = this.getRationRecoveryShips(i);
                            if (rationRecoveryShips.get_Count() != 0)
                            {
                                dictionary.Add(mem_ship.Rid, new List <Mst_slotitem>());
                                int        num   = 0;
                                List <int> list2 = new List <int>();
                                if (slotIndexFromId.get_Item(145).get_Count() > 0)
                                {
                                    num++;
                                    int num2 = slotIndexFromId.get_Item(145).get_Count() - 1;
                                    list2.Add(slotIndexFromId.get_Item(145).get_Item(num2));
                                    dictionary.get_Item(mem_ship.Rid).Add(Mst_DataManager.Instance.Mst_Slotitem.get_Item(145));
                                }
                                if (slotIndexFromId.get_Item(150).get_Count() > 0)
                                {
                                    num += 2;
                                    int num3 = slotIndexFromId.get_Item(150).get_Count() - 1;
                                    list2.Add(slotIndexFromId.get_Item(150).get_Item(num3));
                                    dictionary.get_Item(mem_ship.Rid).Add(Mst_DataManager.Instance.Mst_Slotitem.get_Item(150));
                                }
                                Dictionary <int, int> dictionary4;
                                Dictionary <int, int> expr_23B = dictionary4 = dictionary3;
                                int num4;
                                int expr_245 = num4 = mem_ship.Rid;
                                num4 = dictionary4.get_Item(num4);
                                expr_23B.set_Item(expr_245, num4 + this.getCombatRationCondPlus(num, false));
                                dictionary2.Add(i, list2);
                                rationRecoveryShips.Remove(mem_ship.Rid);
                                list.AddRange(rationRecoveryShips);
                                using (List <int> .Enumerator enumerator = rationRecoveryShips.GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        int current = enumerator.get_Current();
                                        Dictionary <int, int> dictionary5;
                                        Dictionary <int, int> expr_29F = dictionary5 = dictionary3;
                                        int expr_2A4 = num4 = current;
                                        num4 = dictionary5.get_Item(num4);
                                        expr_29F.set_Item(expr_2A4, num4 + this.getCombatRationCondPlus(num, true));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (dictionary2.get_Count() == 0)
            {
                return(false);
            }
            List <int> list3 = new List <int>();
            Dictionary <int, Mst_ship> mst_ship = Mst_DataManager.Instance.Mst_ship;

            using (Dictionary <int, List <int> > .Enumerator enumerator2 = dictionary2.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    KeyValuePair <int, List <int> > current2 = enumerator2.get_Current();
                    Mem_ship            mem_ship2            = this.userData.ShipData.get_Item(current2.get_Key());
                    Mem_shipBase        mem_shipBase         = new Mem_shipBase(mem_ship2);
                    List <Mst_slotitem> list4 = this.userData.SlotData.get_Item(current2.get_Key());
                    using (List <int> .Enumerator enumerator3 = current2.get_Value().GetEnumerator())
                    {
                        while (enumerator3.MoveNext())
                        {
                            int current3 = enumerator3.get_Current();
                            int num5;
                            if (current3 != 2147483647)
                            {
                                num5 = mem_ship2.Slot.get_Item(current3);
                                mem_shipBase.Slot.set_Item(current3, -1);
                                list4.set_Item(current3, null);
                            }
                            else
                            {
                                num5 = mem_ship2.Exslot;
                                mem_shipBase.Exslot = -1;
                            }
                            list3.Add(num5);
                        }
                    }
                    mem_ship2.Set_ShipParam(mem_shipBase, mst_ship.get_Item(mem_shipBase.Ship_id), false);
                    mem_ship2.TrimSlot();
                    list4.RemoveAll((Mst_slotitem x) => x == null);
                }
            }
            using (Dictionary <int, int> .Enumerator enumerator4 = dictionary3.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    KeyValuePair <int, int> current4 = enumerator4.get_Current();
                    Mem_ship shipInstance            = this.userSubInfo.get_Item(current4.get_Key()).ShipInstance;
                    int      value2 = current4.get_Value();
                    shipInstance.AddRationItemCond(value2);
                }
            }
            Comm_UserDatas.Instance.Remove_Slot(list3);
            useShipInfo = dictionary;
            givenShips  = Enumerable.ToList <int>(Enumerable.Distinct <int>(list));
            return(true);
        }
Ejemplo n.º 4
0
        public Api_Result <SlotSetChkResult_Slot> SlotSet(int ship_rid, int slot_rid, int equip_idx)
        {
            Api_Result <SlotSetChkResult_Slot> api_Result = new Api_Result <SlotSetChkResult_Slot>();
            SlotSetChkResult_Slot slotSetChkResult_Slot   = this.IsValidSlotSet(ship_rid, slot_rid, equip_idx);

            if (slotSetChkResult_Slot != SlotSetChkResult_Slot.Ok)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                api_Result.data  = slotSetChkResult_Slot;
                return(api_Result);
            }
            Mem_ship     mem_ship     = Comm_UserDatas.Instance.User_ship.get_Item(ship_rid);
            Mem_slotitem mem_slotitem = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(slot_rid, ref mem_slotitem);
            int num = mem_ship.Slot.FindIndex((int x) => x == -1);

            if (num != -1 && num < equip_idx)
            {
                equip_idx = num;
            }
            Mem_shipBase mem_shipBase  = new Mem_shipBase(mem_ship);
            Mem_slotitem mem_slotitem2 = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(mem_ship.Slot.get_Item(equip_idx), ref mem_slotitem2);
            int preCost   = 0;
            int afterCost = 0;
            OnslotChangeType slotChangeCost = Mst_slotitem_cost.GetSlotChangeCost(mem_ship.Slot.get_Item(equip_idx), slot_rid, out preCost, out afterCost);
            int num2 = mem_ship.Onslot.get_Item(equip_idx);

            if (slotChangeCost == OnslotChangeType.OtherToPlane)
            {
                num2 = Mst_DataManager.Instance.Mst_ship.get_Item(mem_ship.Ship_id).Maxeq.get_Item(equip_idx);
            }
            int slotChangeBauxiteNum = Mst_slotitem_cost.GetSlotChangeBauxiteNum(slotChangeCost, preCost, afterCost, num2);

            if (slotChangeBauxiteNum < 0)
            {
                if (slotChangeCost == OnslotChangeType.PlaneToPlane)
                {
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUseHighCost;
                }
                else if (slotChangeCost == OnslotChangeType.OtherToPlane)
                {
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUse;
                    mem_shipBase.Onslot.set_Item(equip_idx, num2);
                }
                Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Sub_Material(Math.Abs(slotChangeBauxiteNum));
            }
            else
            {
                if (slotChangeCost == OnslotChangeType.PlaneOther)
                {
                    mem_shipBase.Onslot.set_Item(equip_idx, 0);
                }
                api_Result.data = SlotSetChkResult_Slot.Ok;
                Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Add_Material(slotChangeBauxiteNum);
            }
            mem_shipBase.Slot.set_Item(equip_idx, slot_rid);
            if (mem_slotitem2 != null)
            {
                mem_slotitem2.UnEquip();
            }
            if (slot_rid != -1)
            {
                mem_slotitem.Equip(ship_rid);
            }
            mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship.get_Item(mem_shipBase.Ship_id), false);
            if (slot_rid == -1)
            {
                mem_ship.TrimSlot();
            }
            return(api_Result);
        }
Ejemplo n.º 5
0
        private bool getCombatRationResult(out Dictionary <int, List <Mst_slotitem> > useShipInfo, out List <int> givenShips)
        {
            int mapBattleCellPassCount = mapInstance.MapBattleCellPassCount;

            useShipInfo = null;
            givenShips  = null;
            if (mapBattleCellPassCount < 2)
            {
                return(false);
            }
            Dictionary <int, List <Mst_slotitem> > dictionary = new Dictionary <int, List <Mst_slotitem> >();
            List <int>    list    = new List <int>();
            HashSet <int> hashSet = new HashSet <int>();

            hashSet.Add(145);
            hashSet.Add(150);
            HashSet <int> searchIds = hashSet;
            Dictionary <int, List <int> > dictionary2 = new Dictionary <int, List <int> >();
            Dictionary <int, int>         dictionary3 = userSubInfo.Keys.ToDictionary((int key) => key, (int value) => 0);

            for (int i = 0; i < userData.ShipData.Count; i++)
            {
                Mem_ship mem_ship = userData.ShipData[i];
                if (!mem_ship.IsFight())
                {
                    continue;
                }
                Dictionary <int, List <int> > slotIndexFromId = mem_ship.GetSlotIndexFromId(searchIds);
                if ((slotIndexFromId[145].Count == 0 && slotIndexFromId[150].Count == 0) || !isRationLotteryWinning(mapBattleCellPassCount, mem_ship.Luck))
                {
                    continue;
                }
                List <int> rationRecoveryShips = getRationRecoveryShips(i);
                if (rationRecoveryShips.Count != 0)
                {
                    dictionary.Add(mem_ship.Rid, new List <Mst_slotitem>());
                    int        num   = 0;
                    List <int> list2 = new List <int>();
                    if (slotIndexFromId[145].Count > 0)
                    {
                        num++;
                        int index = slotIndexFromId[145].Count - 1;
                        list2.Add(slotIndexFromId[145][index]);
                        dictionary[mem_ship.Rid].Add(Mst_DataManager.Instance.Mst_Slotitem[145]);
                    }
                    if (slotIndexFromId[150].Count > 0)
                    {
                        num += 2;
                        int index2 = slotIndexFromId[150].Count - 1;
                        list2.Add(slotIndexFromId[150][index2]);
                        dictionary[mem_ship.Rid].Add(Mst_DataManager.Instance.Mst_Slotitem[150]);
                    }
                    Dictionary <int, int> dictionary4;
                    Dictionary <int, int> dictionary5 = dictionary4 = dictionary3;
                    int rid;
                    int key2 = rid = mem_ship.Rid;
                    rid = dictionary4[rid];
                    dictionary5[key2] = rid + getCombatRationCondPlus(num, givenShip: false);
                    dictionary2.Add(i, list2);
                    rationRecoveryShips.Remove(mem_ship.Rid);
                    list.AddRange(rationRecoveryShips);
                    foreach (int item2 in rationRecoveryShips)
                    {
                        Dictionary <int, int> dictionary6;
                        Dictionary <int, int> dictionary7 = dictionary6 = dictionary3;
                        int key3 = rid = item2;
                        rid = dictionary6[rid];
                        dictionary7[key3] = rid + getCombatRationCondPlus(num, givenShip: true);
                    }
                }
            }
            if (dictionary2.Count == 0)
            {
                return(false);
            }
            List <int> list3 = new List <int>();
            Dictionary <int, Mst_ship> mst_ship = Mst_DataManager.Instance.Mst_ship;

            foreach (KeyValuePair <int, List <int> > item3 in dictionary2)
            {
                Mem_ship            mem_ship2    = userData.ShipData[item3.Key];
                Mem_shipBase        mem_shipBase = new Mem_shipBase(mem_ship2);
                List <Mst_slotitem> list4        = userData.SlotData[item3.Key];
                foreach (int item4 in item3.Value)
                {
                    int item;
                    if (item4 != int.MaxValue)
                    {
                        item = mem_ship2.Slot[item4];
                        mem_shipBase.Slot[item4] = -1;
                        list4[item4]             = null;
                    }
                    else
                    {
                        item = mem_ship2.Exslot;
                        mem_shipBase.Exslot = -1;
                    }
                    list3.Add(item);
                }
                mem_ship2.Set_ShipParam(mem_shipBase, mst_ship[mem_shipBase.Ship_id], enemy_flag: false);
                mem_ship2.TrimSlot();
                list4.RemoveAll((Mst_slotitem x) => x == null);
            }
            foreach (KeyValuePair <int, int> item5 in dictionary3)
            {
                Mem_ship shipInstance = userSubInfo[item5.Key].ShipInstance;
                int      value2       = item5.Value;
                shipInstance.AddRationItemCond(value2);
            }
            Comm_UserDatas.Instance.Remove_Slot(list3);
            useShipInfo = dictionary;
            givenShips  = list.Distinct().ToList();
            return(true);
        }
Ejemplo n.º 6
0
        public Api_Result <SlotSetChkResult_Slot> SlotSet(int ship_rid, int slot_rid, int equip_idx)
        {
            Api_Result <SlotSetChkResult_Slot> api_Result = new Api_Result <SlotSetChkResult_Slot>();
            SlotSetChkResult_Slot slotSetChkResult_Slot   = IsValidSlotSet(ship_rid, slot_rid, equip_idx);

            if (slotSetChkResult_Slot != 0)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                api_Result.data  = slotSetChkResult_Slot;
                return(api_Result);
            }
            Mem_ship     mem_ship = Comm_UserDatas.Instance.User_ship[ship_rid];
            Mem_slotitem value    = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(slot_rid, out value);
            int num = mem_ship.Slot.FindIndex((int x) => x == -1);

            if (num != -1 && num < equip_idx)
            {
                equip_idx = num;
            }
            Mem_shipBase mem_shipBase = new Mem_shipBase(mem_ship);
            Mem_slotitem value2       = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(mem_ship.Slot[equip_idx], out value2);
            int preCost   = 0;
            int afterCost = 0;
            OnslotChangeType slotChangeCost = Mst_slotitem_cost.GetSlotChangeCost(mem_ship.Slot[equip_idx], slot_rid, out preCost, out afterCost);
            int num2 = mem_ship.Onslot[equip_idx];

            if (slotChangeCost == OnslotChangeType.OtherToPlane)
            {
                num2 = Mst_DataManager.Instance.Mst_ship[mem_ship.Ship_id].Maxeq[equip_idx];
            }
            int slotChangeBauxiteNum = Mst_slotitem_cost.GetSlotChangeBauxiteNum(slotChangeCost, preCost, afterCost, num2);

            if (slotChangeBauxiteNum < 0)
            {
                switch (slotChangeCost)
                {
                case OnslotChangeType.PlaneToPlane:
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUseHighCost;
                    break;

                case OnslotChangeType.OtherToPlane:
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUse;
                    mem_shipBase.Onslot[equip_idx] = num2;
                    break;
                }
                Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Sub_Material(Math.Abs(slotChangeBauxiteNum));
            }
            else
            {
                if (slotChangeCost == OnslotChangeType.PlaneOther)
                {
                    mem_shipBase.Onslot[equip_idx] = 0;
                }
                api_Result.data = SlotSetChkResult_Slot.Ok;
                Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Add_Material(slotChangeBauxiteNum);
            }
            mem_shipBase.Slot[equip_idx] = slot_rid;
            value2?.UnEquip();
            if (slot_rid != -1)
            {
                value.Equip(ship_rid);
            }
            mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship[mem_shipBase.Ship_id], enemy_flag: false);
            if (slot_rid == -1)
            {
                mem_ship.TrimSlot();
            }
            return(api_Result);
        }