Пример #1
0
        internal static bool GetIncorrectRibbonsEgg(PKM pkm, object encounterContent)
        {
            var event3      = encounterContent as IRibbonSetEvent3;
            var event4      = encounterContent as IRibbonSetEvent4;
            var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon");

            if (event3 != null)
            {
                RibbonNames = RibbonNames.Except(event3.RibbonNames());
            }
            if (event4 != null)
            {
                RibbonNames = RibbonNames.Except(event4.RibbonNames());
            }

            foreach (object RibbonValue in RibbonNames.Select(RibbonName => ReflectUtil.GetValue(pkm, RibbonName)))
            {
                if (HasFlag(RibbonValue) || HasCount(RibbonValue))
                {
                    return(true);
                }

                bool HasFlag(object o) => o is bool z && z;
                bool HasCount(object o) => o is int z && z > 0;
            }
            return(false);
        }
Пример #2
0
        public IEnumerable <FlagPairG1Detail> GetFlagPairs()
        {
            var pz = ReflectUtil.GetPropertiesStartWithPrefix(GetType(), FlagPropertyPrefix);

            foreach (var pair in pz)
            {
                if (ReflectUtil.GetValue(this, pair) is not FlagPairG1 p)
                {
                    continue;
                }
                yield return(new FlagPairG1Detail(p, pair, EventFlags, SpawnFlags));
            }
        }
Пример #3
0
        public IEnumerable <FlagPair> GetFlagPairs()
        {
            var pz = ReflectUtil.GetPropertiesStartWithPrefix(GetType(), "Flag");

            foreach (var pair in pz)
            {
                if (!(ReflectUtil.GetValue(this, pair) is FlagPair p))
                {
                    continue;
                }
                p.Name  = pair;
                p.Event = EventFlags;
                p.Spawn = SpawnFlags;
                yield return(p);
            }
        }
Пример #4
0
        private static bool GetIncorrectRibbonsEgg(PKM pkm, object encounterContent)
        {
            var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon");

            if (encounterContent is IRibbonSetEvent3 event3)
            {
                RibbonNames = RibbonNames.Except(event3.RibbonNames());
            }
            if (encounterContent is IRibbonSetEvent4 event4)
            {
                RibbonNames = RibbonNames.Except(event4.RibbonNames());
            }

            foreach (object RibbonValue in RibbonNames.Select(RibbonName => ReflectUtil.GetValue(pkm, RibbonName)))
            {
                if (HasFlag(RibbonValue) || HasCount(RibbonValue))
                {
                    return(true);
                }
Пример #5
0
        public static IReadOnlyList <RibbonInfo> GetRibbonInfo(PKM pkm)
        {
            // Get a list of all Ribbon Attributes in the PKM
            var riblist = new List <RibbonInfo>();
            var names   = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon");

            foreach (var name in names)
            {
                object RibbonValue = ReflectUtil.GetValue(pkm, name);
                if (RibbonValue is int x)
                {
                    riblist.Add(new RibbonInfo(name, x));
                }
                if (RibbonValue is bool b)
                {
                    riblist.Add(new RibbonInfo(name, b));
                }
            }

            return(riblist);
        }
Пример #6
0
        private static bool GetIncorrectRibbonsEgg(PKM pkm, IEncounterTemplate enc)
        {
            var names = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), RibbonInfo.PropertyPrefix);

            if (enc is IRibbonSetEvent3 event3)
            {
                names = names.Except(event3.RibbonNames());
            }
            if (enc is IRibbonSetEvent4 event4)
            {
                names = names.Except(event4.RibbonNames());
            }

            foreach (var value in names.Select(name => ReflectUtil.GetValue(pkm, name)))
            {
                if (value is null)
                {
                    continue;
                }
                if (HasFlag(value) || HasCount(value))
                {
                    return(true);
                }
Пример #7
0
        private static IEnumerable <string> DumpStrings(Type t)
        {
            var props = ReflectUtil.GetPropertiesStartWithPrefix(t, string.Empty);

            return(props.Select(p => $"{p}{TranslationSplitter}{ReflectUtil.GetValue(t, p)}"));
        }