Esempio n. 1
0
        private CheckResult VerifyForm(LegalityAnalysis data)
        {
            var pkm          = data.pkm;
            var PersonalInfo = data.PersonalInfo;

            int count = PersonalInfo.FormeCount;
            var form  = pkm.AltForm;

            if (count <= 1 && form == 0)
            {
                return(VALID); // no forms to check
            }
            var species        = pkm.Species;
            var EncounterMatch = data.EncounterMatch;
            var Info           = data.Info;

            if (!PersonalInfo.IsFormeWithinRange(form) && !FormConverter.IsValidOutOfBoundsForme(species, form, Info.Generation))
            {
                return(GetInvalid(string.Format(LFormInvalidRange, count - 1, form)));
            }

            if (EncounterMatch is EncounterSlot w && w.Area.Type == SlotType.FriendSafari)
            {
                VerifyFormFriendSafari(data);
            }
Esempio n. 2
0
        public override void Verify(LegalityAnalysis data)
        {
            var pkm = data.pkm;

            if (pkm.Format < 4)
            {
                return; // no forms exist
            }
            var PersonalInfo   = data.PersonalInfo;
            var EncounterMatch = data.EncounterMatch;
            var Info           = data.Info;

            int count = PersonalInfo.FormeCount;

            if (count <= 1 && pkm.AltForm == 0)
            {
                return; // no forms to check
            }
            if (!PersonalInfo.IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
            {
                data.AddLine(GetInvalid(string.Format(V304, count - 1, pkm.AltForm)));
                return;
            }

            if (EncounterMatch is EncounterSlot w && w.Type == SlotType.FriendSafari)
            {
                VerifyFormFriendSafari(data);
            }
Esempio n. 3
0
        private static IReadOnlyList <string> GetSaveFileErrata(this SaveFile sav, PKM pkm, IBasicStrings strings)
        {
            var    errata = new List <string>();
            ushort held   = (ushort)pkm.HeldItem;

            if (sav.Generation > 1 && held != 0)
            {
                string?msg = null;
                if (held > sav.MaxItemID)
                {
                    msg = MsgIndexItemGame;
                }
                else if (!pkm.CanHoldItem(sav.HeldItems))
                {
                    msg = MsgIndexItemHeld;
                }
                if (msg != null)
                {
                    var itemstr = GameInfo.Strings.GetItemStrings(pkm.Format, (GameVersion)pkm.Version);
                    errata.Add($"{msg} {(held >= itemstr.Count ? held.ToString() : itemstr[held])}");
                }
            }

            if (pkm.Species > strings.Species.Count)
            {
                errata.Add($"{MsgIndexSpeciesRange} {pkm.Species}");
            }
            else if (sav.MaxSpeciesID < pkm.Species)
            {
                errata.Add($"{MsgIndexSpeciesGame} {strings.Species[pkm.Species]}");
            }

            if (!sav.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber))
            {
                errata.Add(string.Format(LegalityCheckStrings.LFormInvalidRange, Math.Max(0, sav.Personal[pkm.Species].FormeCount - 1), pkm.AltForm));
            }

            if (pkm.Moves.Any(m => m > strings.Move.Count))
            {
                errata.Add($"{MsgIndexMoveRange} {string.Join(", ", pkm.Moves.Where(m => m > strings.Move.Count).Select(m => m.ToString()))}");
            }
            else if (pkm.Moves.Any(m => m > sav.MaxMoveID))
            {
                errata.Add($"{MsgIndexMoveGame} {string.Join(", ", pkm.Moves.Where(m => m > sav.MaxMoveID).Select(m => strings.Move[m]))}");
            }

            if (pkm.Ability > strings.Ability.Count)
            {
                errata.Add($"{MsgIndexAbilityRange} {pkm.Ability}");
            }
            else if (pkm.Ability > sav.MaxAbilityID)
            {
                errata.Add($"{MsgIndexAbilityGame} {strings.Ability[pkm.Ability]}");
            }

            return(errata);
        }
Esempio n. 4
0
        private static IReadOnlyList <string> GetSaveFileErrata(this SaveFile SAV, PKM pkm, IBasicStrings strings)
        {
            var errata = new List <string>();

            if (SAV.Generation > 1)
            {
                ushort held = (ushort)pkm.HeldItem;

                if (held > strings.Item.Count)
                {
                    errata.Add($"{MsgIndexItemRange} {held}");
                }
                else if (held > SAV.MaxItemID)
                {
                    errata.Add($"{MsgIndexItemGame} {strings.Item[held]}");
                }
                else if (!pkm.CanHoldItem(SAV.HeldItems))
                {
                    errata.Add($"{MsgIndexItemHeld} {strings.Item[held]}");
                }
            }

            if (pkm.Species > strings.Species.Count)
            {
                errata.Add($"{MsgIndexSpeciesRange} {pkm.Species}");
            }
            else if (SAV.MaxSpeciesID < pkm.Species)
            {
                errata.Add($"{MsgIndexSpeciesGame} {strings.Species[pkm.Species]}");
            }

            if (!SAV.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber))
            {
                errata.Add(string.Format(LegalityCheckStrings.V304, Math.Max(0, SAV.Personal[pkm.Species].FormeCount - 1), pkm.AltForm));
            }

            if (pkm.Moves.Any(m => m > strings.Move.Count))
            {
                errata.Add($"{MsgIndexMoveRange} {string.Join(", ", pkm.Moves.Where(m => m > strings.Move.Count).Select(m => m.ToString()))}");
            }
            else if (pkm.Moves.Any(m => m > SAV.MaxMoveID))
            {
                errata.Add($"{MsgIndexMoveGame} {string.Join(", ", pkm.Moves.Where(m => m > SAV.MaxMoveID).Select(m => strings.Move[m]))}");
            }

            if (pkm.Ability > strings.Ability.Count)
            {
                errata.Add($"{MsgIndexAbilityRange} {pkm.Ability}");
            }
            else if (pkm.Ability > SAV.MaxAbilityID)
            {
                errata.Add($"{MsgIndexAbilityGame} {strings.Ability[pkm.Ability]}");
            }

            return(errata);
        }