Ejemplo n.º 1
0
        public Api_Result <Mem_esccort_deck> Change(int deck_rid, DeckShips deckShip)
        {
            Api_Result <Mem_esccort_deck> api_Result = new Api_Result <Mem_esccort_deck>();
            Mem_esccort_deck deck           = null;
            List <int>       lastTempResult = null;

            deckShip.Clone(out lastTempResult);
            if (!Comm_UserDatas.Instance.User_EscortDeck.TryGetValue(deck_rid, out deck))
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            List <int> out_ships = null;

            deck.Ship.Clone(out out_ships);
            Dictionary <int, Mem_ship> cloneShips = deck.Ship.getMemShip().ToDictionary((Mem_ship rid) => rid.Rid, (Mem_ship obj) => obj);

            deck.Ship.Clear();
            int count = lastTempResult.Count;

            for (int i = 0; i < count; i++)
            {
                deck.Ship[i] = lastTempResult[i];
                Comm_UserDatas.Instance.User_ship[deck.Ship[i]].BlingWaitToStop();
            }
            out_ships.ForEach(delegate(int ship_rid)
            {
                if (!lastTempResult.Contains(ship_rid) && Comm_UserDatas.Instance.Temp_escortship.Contains(ship_rid))
                {
                    cloneShips[ship_rid].BlingWait(deck.Maparea_id, Mem_ship.BlingKind.WaitEscort);
                }
            });
            if (deck.Ship.Count() > 0 && deck.Disposition_status == DispositionStatus.NONE)
            {
                deck.GoArea(deck.Maparea_id);
            }
            else if (deck.Ship.Count() == 0)
            {
                deck.EscortStop();
            }
            else if (deck.Disposition_status == DispositionStatus.ARRIVAL && deck.GetBlingTurn() == 0 && deck.Ship.getMemShip().All((Mem_ship x) => x.GetBlingTurn() > 0))
            {
                deck.EscortStop();
                deck.GoArea(deck.Maparea_id);
            }
            api_Result.data = deck;
            return(api_Result);
        }
        public Api_Result <Dictionary <int, Mem_ship> > Ship(int area_id)
        {
            List <DeckShips> list             = new List <DeckShips>();
            Mem_esccort_deck mem_esccort_deck = Enumerable.FirstOrDefault <Mem_esccort_deck>(Comm_UserDatas.Instance.User_EscortDeck.get_Values(), (Mem_esccort_deck x) => x.Maparea_id == area_id);

            if (mem_esccort_deck != null)
            {
                list.Add(mem_esccort_deck.Ship);
            }
            IEnumerable <DeckShips> enumerable = Enumerable.Select <Mem_deck, DeckShips>(Enumerable.Where <Mem_deck>(Comm_UserDatas.Instance.User_deck.get_Values(), (Mem_deck deck) => deck.Area_id == area_id), (Mem_deck deck) => deck.Ship);

            if (Enumerable.Count <DeckShips>(enumerable) > 0)
            {
                list.AddRange(enumerable);
            }
            if (list.get_Count() == 0)
            {
                return(new Api_Result <Dictionary <int, Mem_ship> >
                {
                    state = Api_Result_State.Parameter_Error
                });
            }
            List <int> list2 = new List <int>();

            using (List <DeckShips> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DeckShips  current = enumerator.get_Current();
                    List <int> list3   = null;
                    current.Clone(out list3);
                    list2.AddRange(list3);
                }
            }
            return(this.Ship(list2));
        }
Ejemplo n.º 3
0
        public bool IsValidChange(int deck_rid, int deck_targetIdx, int ship_rid, DeckShips deckShip)
        {
            initEscortGroup();
            Mem_esccort_deck value = null;

            if (!Comm_UserDatas.Instance.User_EscortDeck.TryGetValue(deck_rid, out value))
            {
                return(false);
            }
            List <int> unsetShips = null;

            if (ship_rid == -2)
            {
                if (deckShip.Count() <= 1)
                {
                    return(false);
                }
                deckShip.Clone(out unsetShips);
                unsetShips.RemoveAt(0);
            }
            else if (ship_rid == -1)
            {
                unsetShips = new List <int>
                {
                    deckShip[deck_targetIdx]
                };
            }
            else
            {
                if (ship_rid == deckShip[deck_targetIdx])
                {
                    return(false);
                }
                int stype = Comm_UserDatas.Instance.User_ship[ship_rid].Stype;
                if (Mst_DataManager.Instance.Mst_stype[stype].IsSubmarine())
                {
                    return(false);
                }
                unsetShips = new List <int>
                {
                    ship_rid
                };
            }
            DeckShips out_ships = null;

            deckShip.Clone(out out_ships);
            Change_TempDeck(deck_targetIdx, ship_rid, ref out_ships);
            if (!validEscortStypeCheck(out_ships, -1))
            {
                return(false);
            }
            Mem_ndock mem_ndock = Comm_UserDatas.Instance.User_ndock.Values.FirstOrDefault((Mem_ndock x) => unsetShips.Contains(x.Ship_id) ? true : false);

            if (mem_ndock != null)
            {
                return(false);
            }
            if (unsetShips.Any(delegate(int bling_rid)
            {
                Mem_ship value3 = null;
                return(Comm_UserDatas.Instance.User_ship.TryGetValue(bling_rid, out value3) && value3.IsBlingShip());
            }))
            {
                return(false);
            }
            if (ship_rid < 0)
            {
                return(true);
            }
            if (Comm_UserDatas.Instance.User_deck.Values.Any((Mem_deck x) => x.Ship.Find(ship_rid) != -1))
            {
                return(false);
            }
            if (Comm_UserDatas.Instance.User_EscortDeck.Values.Any((Mem_esccort_deck x) => x.Rid != deck_rid && x.Ship.Find(ship_rid) != -1))
            {
                return(false);
            }
            Func <DeckShips, bool> func = delegate(DeckShips x)
            {
                int           num  = x.Count();
                List <string> list = new List <string>();
                for (int i = 0; i < num; i++)
                {
                    int ship_id = Comm_UserDatas.Instance.User_ship[x[i]].Ship_id;
                    list.Add(Mst_DataManager.Instance.Mst_ship[ship_id].Yomi);
                }
                IEnumerable <IGrouping <string, string> > source = from y in list
                                                                   group y by y;
                return((source.Count() == list.Count()) ? true : false);
            };
            Mem_ship value2 = null;

            if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, out value2))
            {
                return(false);
            }
            if (value2.IsBlingShip())
            {
                return(false);
            }
            if (value2.BlingType == Mem_ship.BlingKind.WaitDeck)
            {
                return(false);
            }
            if (value2.BlingType == Mem_ship.BlingKind.WaitEscort && value2.BlingWaitArea != value.Maparea_id)
            {
                return(false);
            }
            if (deckShip.Equals(out_ships))
            {
                return(false);
            }
            if (!func(out_ships))
            {
                return(false);
            }
            return(true);
        }