コード例 #1
0
ファイル: MoveBreed6.cs プロジェクト: ShadyRelapse-PP/PKHeX
    public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, ReadOnlySpan <int> moves, out bool valid)
    {
        var count = moves.IndexOf(0);

        if (count == 0)
        {
            valid = false; // empty moveset
            return(Array.Empty <EggSource6>());
        }
        if (count == -1)
        {
            count = moves.Length;
        }

        var learn    = GameData.GetLearnsets(version);
        var table    = GameData.GetPersonal(version);
        var index    = table.GetFormIndex(species, form);
        var learnset = learn[index];
        var egg      = MoveEgg.GetEggMoves(generation, species, form, version);

        var         actual   = new EggSource6[count];
        Span <byte> possible = stackalloc byte[count];
        var         value    = new BreedInfo <EggSource6>(actual, possible, learnset, moves, level);

        if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle)
        {
            actual[--count] = VoltTackle;
        }

        if (count == 0)
        {
            valid = VerifyBaseMoves(value);
        }
        else
        {
            bool inherit = Breeding.GetCanInheritMoves(species);
            MarkMovesForOrigin(value, egg, count, inherit);
            valid = RecurseMovesForOrigin(value, count - 1);
        }

        if (!valid)
        {
            CleanResult(actual, possible);
        }
        return(value.Actual);
    }
コード例 #2
0
ファイル: MoveBreed2.cs プロジェクト: ShadyRelapse-PP/PKHeX
    public static EggSource2[] Validate(int species, GameVersion version, ReadOnlySpan <int> moves, out bool valid)
    {
        var count = moves.IndexOf(0);

        if (count == 0)
        {
            valid = false; // empty moveset
            return(Array.Empty <EggSource2>());
        }
        if (count == -1)
        {
            count = moves.Length;
        }

        var learn    = GameData.GetLearnsets(version);
        var table    = GameData.GetPersonal(version);
        var learnset = learn[species];
        var pi       = table[species];
        var egg      = (version == GameVersion.C ? Legal.EggMovesC : Legal.EggMovesGS)[species].Moves;

        var         actual   = new EggSource2[count];
        Span <byte> possible = stackalloc byte[count];
        var         value    = new BreedInfo <EggSource2>(actual, possible, learnset, moves, level);

        {
            bool inherit = Breeding.GetCanInheritMoves(species);
            MarkMovesForOrigin(value, egg, count, inherit, pi, version);
            valid = RecurseMovesForOrigin(value, count - 1);
        }

        if (!valid)
        {
            CleanResult(actual, possible);
        }
        return(actual);
    }