Example #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)));
        }
Example #2
0
        private static bool CanKnowMove(PKM pkm, MemoryVariableSet memory, int gen, LegalInfo info, bool battleOnly = false)
        {
            var move = memory.Variable;

            if (move == 0)
            {
                return(false);
            }

            if (pkm.HasMove(move))
            {
                return(true);
            }

            if (Legal.GetCanKnowMove(pkm, memory.Variable, gen, info.EvoChainsAllGens))
            {
                return(true);
            }

            var enc = info.EncounterMatch;

            if (enc is IMoveset ms && ms.Moves.Contains(move))
            {
                return(true);
            }

            if (battleOnly)
            {
                // Some moves can only be known in battle; outside of battle they aren't obtainable as a memory parameter.
                switch (move)
                {
                case 781 when pkm.Species == (int)Species.Zacian:     // Behemoth Blade
                case 782 when pkm.Species == (int)Species.Zamazenta:  // Behemoth Blade
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
 private static bool GetIsMoveKnowable(PKM pkm, int gen, int move) => Legal.GetCanKnowMove(pkm, move, gen);