コード例 #1
0
        private static EscortCheckKinds IsValidChangeEscortDeck(List <Mem_ship> escortShips, Dictionary <int, int> stype_group)
        {
            ILookup <int, Mem_ship>             lookup      = Enumerable.ToLookup <Mem_ship, int>(escortShips, (Mem_ship x) => x.Stype);
            Dictionary <int, int>               dictionary  = Enumerable.ToDictionary <int, int, int>(Enumerable.Distinct <int>(stype_group.get_Values()), (int value) => value, (int value) => 0);
            List <EscortCheckKinds>             list        = new List <EscortCheckKinds>();
            Dictionary <EscortCheckKinds, bool> dictionary2 = new Dictionary <EscortCheckKinds, bool>();

            using (IEnumerator enumerator = Enum.GetValues(typeof(EscortCheckKinds)).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    object           current          = enumerator.get_Current();
                    EscortCheckKinds escortCheckKinds = (EscortCheckKinds)((int)current);
                    list.Add(escortCheckKinds);
                    dictionary2.Add(escortCheckKinds, true);
                }
            }
            using (IEnumerator <IGrouping <int, Mem_ship> > enumerator2 = lookup.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    IGrouping <int, Mem_ship> current2 = enumerator2.get_Current();
                    int num = stype_group.get_Item(current2.get_Key());
                    dictionary.set_Item(num, Enumerable.Count <Mem_ship>(current2));
                }
            }
            int num2 = dictionary.get_Item(0);
            int num3 = dictionary.get_Item(1);

            if (num2 >= 1)
            {
                dictionary2.set_Item(EscortCheckKinds.NotEscortShip, false);
            }
            else if (escortShips.get_Item(0).Stype == 1 || escortShips.get_Item(0).Stype == 2)
            {
                dictionary2.set_Item(EscortCheckKinds.NotFlagShip, false);
            }
            for (int i = 0; i < Enumerable.Count <EscortCheckKinds>(list); i++)
            {
                if (!dictionary2.get_Item(list.get_Item(i)))
                {
                    return(list.get_Item(i));
                }
            }
            return(EscortCheckKinds.OK);
        }
コード例 #2
0
        private static EscortCheckKinds IsValidChangeEscortDeck(List <Mem_ship> escortShips, Dictionary <int, int> stype_group)
        {
            ILookup <int, Mem_ship>             lookup      = escortShips.ToLookup((Mem_ship x) => x.Stype);
            Dictionary <int, int>               dictionary  = stype_group.Values.Distinct().ToDictionary((int value) => value, (int value) => 0);
            List <EscortCheckKinds>             list        = new List <EscortCheckKinds>();
            Dictionary <EscortCheckKinds, bool> dictionary2 = new Dictionary <EscortCheckKinds, bool>();

            foreach (object value in Enum.GetValues(typeof(EscortCheckKinds)))
            {
                EscortCheckKinds escortCheckKinds = (EscortCheckKinds)(int)value;
                list.Add(escortCheckKinds);
                dictionary2.Add(escortCheckKinds, value: true);
            }
            foreach (IGrouping <int, Mem_ship> item in lookup)
            {
                int key = stype_group[item.Key];
                dictionary[key] = item.Count();
            }
            int num  = dictionary[0];
            int num2 = dictionary[1];

            if (num >= 1)
            {
                dictionary2[EscortCheckKinds.NotEscortShip] = false;
            }
            else if (escortShips[0].Stype == 1 || escortShips[0].Stype == 2)
            {
                dictionary2[EscortCheckKinds.NotFlagShip] = false;
            }
            for (int i = 0; i < list.Count(); i++)
            {
                if (!dictionary2[list[i]])
                {
                    return(list[i]);
                }
            }
            return(EscortCheckKinds.OK);
        }