示例#1
0
        private List <ComboItem> GetItems(int format)
        {
            var permit = Memories.GetMemoryItemParams(format);
            var asInt  = permit.Select(z => (int)z).ToArray();

            return(Util.GetCBList(s.itemlist, asInt));
        }
示例#2
0
        private List <ComboItem> GetItems(int memoryGen)
        {
            var permit = Memories.GetMemoryItemParams(memoryGen);
            var asInt  = permit.ToArray();

            return(Util.GetCBList(s.itemlist, asInt));
        }
示例#3
0
        private CheckResult VerifyCommonMemory(PKM pkm, int handler, int gen)
        {
            var memory = MemoryVariableSet.Read(pkm, handler);

            // Actionable HM moves
            int matchingMoveMemory = Array.IndexOf(Memories.MoveSpecificMemories[0], memory.MemoryID);

            if (matchingMoveMemory != -1)
            {
                // Gen8 has no HMs, so this memory can never exist.
                if (gen != 6 || (pkm.Species != (int)Species.Smeargle && !Legal.GetCanLearnMachineMove(pkm, Memories.MoveSpecificMemories[1][matchingMoveMemory], 6)))
                {
                    return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));
                }
            }

            switch (memory.MemoryID)
            {
            // {0} saw {2} carrying {1} on its back. {4} that {3}.
            case 21 when gen != 6 || !Legal.GetCanLearnMachineMove(new PK6 {
                    Species = memory.Variable, EXP = Experience.GetEXP(100, PersonalTable.XY.GetFormeIndex(memory.Variable, 0))
                }, 19, 6):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));

            case 16 when memory.Variable == 0 && !GetIsMoveKnowable(pkm, gen, memory.Variable):
            case 48 when memory.Variable == 0 && !GetIsMoveKnowable(pkm, gen, memory.Variable):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));

            // {0} was able to remember {2} at {1}'s instruction. {4} that {3}.
            case 49 when memory.Variable == 0 && !GetIsMoveLearnable(pkm, gen, memory.Variable):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));
            }

            if (gen == 6 && !Memories.CanHaveIntensity(memory.MemoryID, memory.Intensity))
            {
                if (pkm.Gen6 || (pkm.Gen7 && memory.MemoryID != 0)) // todo: memory intensity checks for gen8
                {
                    return(GetInvalid(string.Format(LMemoryIndexIntensityMin, memory.Handler, Memories.GetMinimumIntensity(memory.MemoryID))));
                }
            }

            if (gen == 6 && memory.MemoryID != 4 && !Memories.CanHaveFeeling(memory.MemoryID, memory.Feeling))
            {
                if (pkm.Gen6 || (pkm.Gen7 && memory.MemoryID != 0)) // todo: memory feeling checks for gen8
                {
                    return(GetInvalid(string.Format(LMemoryFeelInvalid, memory.Handler)));
                }
            }

            return(GetValid(string.Format(LMemoryF_0_Valid, memory.Handler)));
        }
示例#4
0
        private void VerifyHTMemory(LegalityAnalysis data)
        {
            var pkm  = data.pkm;
            var mem  = (ITrainerMemories)pkm;
            var Info = data.Info;

            var memory = mem.HT_Memory;

            if (pkm.IsUntraded)
            {
                if (memory == 4 && WasTradedSWSHEgg(pkm))
                {
                    // Untraded link trade eggs in Gen8 have HT link trade memory applied erroneously.
                    // Verify the link trade memory later.
                }
                else
                {
                    VerifyHTMemoryNone(data, mem);
                    return;
                }
            }

            if (pkm.Format == 7)
            {
                VerifyHTMemoryTransferTo7(data, pkm, Info);
                return;
            }

            var memoryGen = pkm.Format >= 8 ? 8 : 6;

            // Bounds checking
            switch (memoryGen)
            {
            case 6 when memory > Memories.MAX_MEMORY_ID_AO:
            case 8 when memory > Memories.MAX_MEMORY_ID_SWSH || Memories.Memory_NotSWSH.Contains(memory):
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XHT)));
                break;
            }

            // Verify memory if specific to HT
            switch (memory)
            {
            // No Memory
            case 0:     // SWSH trades don't set HT memories immediately, which is hilarious.
                data.AddLine(Get(LMemoryMissingHT, memoryGen == 8 ? Severity.Fishy : Severity.Invalid));
                VerifyHTMemoryNone(data, mem);
                return;

            // {0} met {1} at... {2}. {1} threw a Poké Ball at it, and they started to travel together. {4} that {3}.
            case 1:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadCatch, L_XHT)));
                return;

            // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
            case 2:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadHatch, L_XHT)));
                return;

            // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
            case 6 when memoryGen == 6 && !Memories.GetHasPokeCenterLocation(GameVersion.Gen6, mem.HT_TextVar):
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XOT)));
                return;

            case 6 when memoryGen == 8 && mem.HT_TextVar != 0:
                data.AddLine(Get(string.Format(LMemoryArgBadLocation, L_XOT), ParseSettings.Gen8MemoryLocationTextVariable));
                return;

            // {0} was with {1} when {1} caught {2}. {4} that {3}.
            case 14:
                var result = GetCanBeCaptured(mem.HT_TextVar, memoryGen, GameVersion.Any)     // Any Game in the Handling Trainer's generation
                        ? GetValid(string.Format(LMemoryArgSpecies, L_XHT))
                        : GetInvalid(string.Format(LMemoryArgBadSpecies, L_XHT));
                data.AddLine(result);
                return;
            }

            var commonResult = VerifyCommonMemory(pkm, 1, memoryGen, Info);

            data.AddLine(commonResult);
        }
示例#5
0
        private CheckResult VerifyCommonMemory(PKM pkm, int handler, int gen, LegalInfo info)
        {
            var memory = MemoryVariableSet.Read((ITrainerMemories)pkm, handler);

            // Actionable HM moves
            int matchingMoveMemory = Array.IndexOf(Memories.MoveSpecificMemories[0], memory.MemoryID);

            if (matchingMoveMemory != -1)
            {
                // Gen8 has no HMs, so this memory can never exist.
                if (gen != 6 || (pkm.Species != (int)Species.Smeargle && !Legal.GetCanLearnMachineMove(pkm, Memories.MoveSpecificMemories[1][matchingMoveMemory], 6)))
                {
                    return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));
                }
            }

            switch (memory.MemoryID)
            {
            // {0} saw {2} carrying {1} on its back. {4} that {3}.
            case 21 when gen != 6 || !Legal.GetCanLearnMachineMove(new PK6 {
                    Species = memory.Variable, EXP = Experience.GetEXP(100, PersonalTable.XY.GetFormIndex(memory.Variable, 0))
                }, 19, 6):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));

            case 16 or 48 when !CanKnowMove(pkm, memory, gen, info, memory.MemoryID == 16):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));

            case 49 when memory.Variable == 0 || !Legal.GetCanRelearnMove(pkm, memory.Variable, gen, info.EvoChainsAllGens[gen]):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));

            // Dynamaxing
            // {0} battled at {1}’s side against {2} that Dynamaxed. {4} that {3}.
            case 71 when !GetCanBeCaptured(memory.Variable, 8, handler == 0 ? (GameVersion)pkm.Version : GameVersion.Any):
            // {0} battled {2} and Dynamaxed upon {1}’s instruction. {4} that {3}.
            case 72 when !((PersonalInfoSWSH)PersonalTable.SWSH[memory.Variable]).IsPresentInGame:
                return(GetInvalid(string.Format(LMemoryArgBadSpecies, handler == 0 ? L_XOT : L_XHT)));

            // Move
            // {0} studied about how to use {2} in a Box, thinking about {1}. {4} that {3}.
            // {0} practiced its cool pose for the move {2} in a Box, wishing to be praised by {1}. {4} that {3}.
            case 80 or 81 when !CanKnowMove(pkm, memory, gen, info):
                return(Get(string.Format(LMemoryArgBadMove, memory.Handler), gen == 8 ? Severity.Fishy : Severity.Invalid));

            // Species
            // {0} had a great chat about {1} with the {2} that it was in a Box with. {4} that {3}.
            // {0} became good friends with the {2} in a Box, practiced moves with it, and talked about the day that {0} would be praised by {1}. {4} that {3}.
            // {0} got in a fight with the {2} that it was in a Box with about {1}. {4} that {3}.
            case 82 or 83 or 87 when !((PersonalInfoSWSH)PersonalTable.SWSH[memory.Variable]).IsPresentInGame:
                return(GetInvalid(string.Format(LMemoryArgBadSpecies, handler == 0 ? L_XOT : L_XHT)));

            // Item
            // {0} went to a Pokémon Center with {1} to buy {2}. {4} that {3}.
            case 5 when !CanBuyItem(gen, memory.Variable):
            // {1} used {2} when {0} was in trouble. {4} that {3}.
            case 15 when !CanUseItem(gen, memory.Variable, pkm.Species):
            // {0} saw {1} using {2}. {4} that {3}.
            case 26 when !CanUseItemGeneric(gen, memory.Variable):
            // {0} planted {2} with {1} and imagined a big harvest. {4} that {3}.
            case 34 when !CanPlantBerry(gen, memory.Variable):
            // {1} had {0} hold items like {2} to help it along. {4} that {3}.
            case 40 when !CanHoldItem(gen, memory.Variable):
            // {0} was excited when {1} won prizes like {2} through Loto-ID. {4} that {3}.
            case 51 when !CanWinRotoLoto(gen, memory.Variable):
            // {0} was worried if {1} was looking for the {2} that it was holding in a Box. {4} that {3}.
            // When {0} was in a Box, it thought about the reason why {1} had it hold the {2}. {4} that {3}.
            case 84 or 88 when !Legal.HeldItems_SWSH.Contains((ushort)memory.Variable) || pkm.IsEgg:
                return(GetInvalid(string.Format(LMemoryArgBadItem, memory.Handler)));
            }

            if (gen == 6 && !Memories.CanHaveIntensity(memory.MemoryID, memory.Intensity))
            {
                if (pkm.Gen6 || (pkm.Gen7 && memory.MemoryID != 0)) // todo: memory intensity checks for gen8
                {
                    return(GetInvalid(string.Format(LMemoryIndexIntensityMin, memory.Handler, Memories.GetMinimumIntensity(memory.MemoryID))));
                }
            }

            if (gen == 6 && memory.MemoryID != 4 && !Memories.CanHaveFeeling(memory.MemoryID, memory.Feeling))
            {
                if (pkm.Gen6 || (pkm.Gen7 && memory.MemoryID != 0)) // todo: memory feeling checks for gen8
                {
                    return(GetInvalid(string.Format(LMemoryFeelInvalid, memory.Handler)));
                }
            }

            return(GetValid(string.Format(LMemoryF_0_Valid, memory.Handler)));
        }
示例#6
0
        private void VerifyOTMemory(LegalityAnalysis data)
        {
            var pkm  = data.pkm;
            var mem  = (ITrainerMemories)pkm;
            var Info = data.Info;

            switch (data.EncounterMatch)
            {
            case WC6 {
                    IsEgg: false
            } g when g.OTGender != 3 :
                VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
                return;

            case WC7 {
                    IsEgg: false
            } g when g.OTGender != 3 :
                VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
                return;

            case WC8 {
                    IsEgg: false
            } g when g.OTGender != 3 :
                VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
                return;

            case IMemoryOT t when t is not MysteryGift:     // Ignore Mystery Gift cases (covered above)
                VerifyOTMemoryIs(data, t.OT_Memory, t.OT_Intensity, t.OT_TextVar, t.OT_Feeling);
                return;
            }

            int memoryGen = Info.Generation;
            int memory    = mem.OT_Memory;

            if (pkm.IsEgg)
            {
                // Traded unhatched eggs in Gen8 have OT link trade memory applied erroneously.
                // They can also have the box-inspect memory!
                if (memoryGen != 8 || !((pkm.Met_Location == Locations.LinkTrade6 && memory == 4) || memory == 85))
                {
                    VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty
                    return;
                }
            }
            else if (!CanHaveMemoryForOT(pkm, memoryGen, memory))
            {
                VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty
                return;
            }

            // Bounds checking
            switch (memoryGen)
            {
            case 6 when pkm.XY && (memory > Memories.MAX_MEMORY_ID_XY || Memories.Memory_NotXY.Contains(memory)):
            case 6 when pkm.AO && (memory > Memories.MAX_MEMORY_ID_AO || Memories.Memory_NotAO.Contains(memory)):
            case 8 when pkm.SWSH && (memory > Memories.MAX_MEMORY_ID_SWSH || Memories.Memory_NotSWSH.Contains(memory)):
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XOT)));
                break;
            }

            // Verify memory if specific to OT
            switch (memory)
            {
            // No Memory
            case 0:     // SWSH trades don't set HT memories immediately, which is hilarious.
                data.AddLine(Get(LMemoryMissingOT, memoryGen == 8 ? Severity.Fishy : Severity.Invalid));
                VerifyOTMemoryIs(data, 0, 0, 0, 0);
                return;

            // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
            case 2 when !Info.EncounterMatch.EggEncounter:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadHatch, L_XOT)));
                break;

            // {0} became {1}’s friend when it arrived via Link Trade at... {2}. {4} that {3}.
            case 4 when pkm.Gen6:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadOTEgg, L_XOT)));
                return;

            // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
            case 6 when memoryGen == 6 && !Memories.GetHasPokeCenterLocation((GameVersion)pkm.Version, mem.OT_TextVar):
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XOT)));
                return;

            case 6 when memoryGen == 8 && mem.OT_TextVar != 0:
                data.AddLine(Get(string.Format(LMemoryArgBadLocation, L_XOT), ParseSettings.Gen8MemoryLocationTextVariable));
                return;

            // {0} was with {1} when {1} caught {2}. {4} that {3}.
            case 14:
                var result = GetCanBeCaptured(mem.OT_TextVar, Info.Generation, (GameVersion)pkm.Version)     // Any Game in the Handling Trainer's generation
                        ? GetValid(string.Format(LMemoryArgSpecies, L_XOT))
                        : GetInvalid(string.Format(LMemoryArgBadSpecies, L_XOT));
                data.AddLine(result);
                return;
            }

            data.AddLine(VerifyCommonMemory(pkm, 0, Info.Generation, Info));
        }
示例#7
0
        private void VerifyOTMemory(LegalityAnalysis data)
        {
            var pkm  = data.pkm;
            var mem  = (ITrainerMemories)pkm;
            var Info = data.Info;

            // If the encounter has a memory from the OT that could never have it replaced, ensure it was not modified.
            switch (data.EncounterMatch)
            {
            case WC6 {
                    IsEgg: false
            } g when g.OTGender != 3 :
                VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
                return;

            case WC7 {
                    IsEgg: false
            } g when g.OTGender != 3 :
                VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
                return;

            case WC8 {
                    IsEgg: false
            } g when g.OTGender != 3 :
                VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
                return;

            case IMemoryOT t and not MysteryGift:     // Ignore Mystery Gift cases (covered above)
                VerifyOTMemoryIs(data, t.OT_Memory, t.OT_Intensity, t.OT_TextVar, t.OT_Feeling);
                return;
            }

            int memoryGen = Info.Generation;
            int memory    = mem.OT_Memory;

            if (pkm.IsEgg)
            {
                // Traded unhatched eggs in Gen8 have OT link trade memory applied erroneously.
                // They can also have the box-inspect memory!
                if (memoryGen != 8 || !((pkm.Met_Location == Locations.LinkTrade6 && memory == 4) || memory == 85))
                {
                    VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty
                    return;
                }
            }
            else if (!CanHaveMemoryForOT(pkm, memoryGen, memory))
            {
                VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty
                return;
            }

            // Bounds checking
            var context = Memories.GetContext(memoryGen);

            if (!context.CanObtainMemoryOT((GameVersion)pkm.Version, memory))
            {
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XOT)));
            }

            // Verify memory if specific to OT
            switch (memory)
            {
            // No Memory
            case 0:     // SWSH trades don't set HT memories immediately, which is hilarious.
                data.AddLine(Get(LMemoryMissingOT, memoryGen == 8 ? Severity.Fishy : Severity.Invalid));
                VerifyOTMemoryIs(data, 0, 0, 0, 0);
                return;

            // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
            case 2 when !Info.EncounterMatch.EggEncounter:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadHatch, L_XOT)));
                break;

            // {0} became {1}’s friend when it arrived via Link Trade at... {2}. {4} that {3}.
            case 4 when Info.Generation == 6:     // gen8 applies this memory erroneously
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadOTEgg, L_XOT)));
                return;

            // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
            case 6 when !context.HasPokeCenter((GameVersion)pkm.Version, mem.OT_TextVar):
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XOT)));
                return;

            // {0} was with {1} when {1} caught {2}. {4} that {3}.
            case 14:
                var result = GetCanBeCaptured(mem.OT_TextVar, Info.Generation, (GameVersion)pkm.Version)     // Any Game in the Handling Trainer's generation
                        ? GetValid(string.Format(LMemoryArgSpecies, L_XOT))
                        : GetInvalid(string.Format(LMemoryArgBadSpecies, L_XOT));
                data.AddLine(result);
                return;
            }

            data.AddLine(VerifyCommonMemory(pkm, 0, Info.Generation, Info, context));
        }
示例#8
0
        private void VerifyHTMemory(LegalityAnalysis data)
        {
            var pkm  = data.pkm;
            var mem  = (ITrainerMemories)pkm;
            var Info = data.Info;

            var memory = mem.HT_Memory;

            if (pkm.IsUntraded)
            {
                if (memory == 4 && WasTradedSWSHEgg(pkm))
                {
                    // Untraded link trade eggs in Gen8 have HT link trade memory applied erroneously.
                    // Verify the link trade memory later.
                }
                else
                {
                    VerifyHTMemoryNone(data, mem);
                    return;
                }
            }

            if (pkm.Format == 7)
            {
                VerifyHTMemoryTransferTo7(data, pkm, Info);
                return;
            }

            var memoryGen = pkm.Format >= 8 ? 8 : 6;

            // Bounds checking
            var context = Memories.GetContext(memoryGen);

            if (!context.CanObtainMemoryHT((GameVersion)pkm.Version, memory))
            {
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XHT)));
            }

            // Verify memory if specific to HT
            switch (memory)
            {
            // No Memory
            case 0:     // SWSH memory application has an off-by-one error: [0,99] + 1 <= chance --> don't apply
                data.AddLine(Get(LMemoryMissingHT, memoryGen == 8 ? ParseSettings.Gen8MemoryMissingHT : Severity.Invalid));
                VerifyHTMemoryNone(data, mem);
                return;

            // {0} met {1} at... {2}. {1} threw a Poké Ball at it, and they started to travel together. {4} that {3}.
            case 1:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadCatch, L_XHT)));
                return;

            // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
            case 2:
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadHatch, L_XHT)));
                return;

            // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
            case 6 when !context.HasPokeCenter(GameVersion.Any, mem.HT_TextVar):
                data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XHT)));
                return;

            // {0} was with {1} when {1} caught {2}. {4} that {3}.
            case 14:
                var result = GetCanBeCaptured(mem.HT_TextVar, memoryGen, GameVersion.Any)     // Any Game in the Handling Trainer's generation
                        ? GetValid(string.Format(LMemoryArgSpecies, L_XHT))
                        : GetInvalid(string.Format(LMemoryArgBadSpecies, L_XHT));
                data.AddLine(result);
                return;
            }

            var commonResult = VerifyCommonMemory(pkm, 1, memoryGen, Info, context);

            data.AddLine(commonResult);
        }