Exemple #1
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.GetFormeIndex(memory.Variable, 0))
                }, 19, 6):
                return(GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)));

            case 16 when memory.Variable == 0 && !Legal.GetCanKnowMove(pkm, gen, memory.Variable, info.EvoChainsAllGens[gen]):
            case 48 when memory.Variable == 0 && !Legal.GetCanKnowMove(pkm, gen, memory.Variable, info.EvoChainsAllGens[gen]):
                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 && !Legal.GetCanRelearnMove(pkm, gen, memory.Variable, info.EvoChainsAllGens[gen]):
                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)));
        }
Exemple #2
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)));
        }
 private static bool GetIsMoveLearnable(PKM pkm, int gen, int move) => Legal.GetCanRelearnMove(pkm, move, gen);