コード例 #1
0
ファイル: PersonalDumper.cs プロジェクト: jan2705/pkNX
        public void AddDump(List <string> lines, PersonalTable table, int species, int form)
        {
            var    index = table.GetFormeIndex(species, form);
            var    entry = table[index];
            string name  = EntryNames[index];

            AddDump(lines, entry, index, name, species, form);
            lines.Add("");
        }
コード例 #2
0
ファイル: PersonalDumper.cs プロジェクト: jan2705/pkNX
        public List <string> Dump(PersonalTable table)
        {
            var lines = new List <string>();
            var ml    = new List <string> [Moves.Count];

            for (int i = 0; i < ml.Length; i++)
            {
                ml[i] = new List <string>();
            }
            MoveSpeciesLearn = ml;

            for (int species = 0; species <= table.MaxSpeciesID; species++)
            {
                var spec = table[species];
                for (int form = 0; form < spec.FormeCount; form++)
                {
                    AddDump(lines, table, species, form);
                }
            }
            return(lines);
        }
コード例 #3
0
ファイル: Legal.cs プロジェクト: rodcybersec/pkNX
        public static int GetRandomForme(int species, bool mega, bool alola, PersonalTable stats)
        {
            if (stats == null)
            {
                return(0);
            }
            if (stats[species].FormeCount <= 1)
            {
                return(0);
            }

            if (species == 658 && !mega) // Greninja
            {
                return(0);
            }
            if (species == 664 || species == 665 || species == 666) // vivillon
            {
                return(30);                                         // save file specific
            }
            if (species == 774)                                     // minior
            {
                return(Util.Rand.Next(7));
            }

            if (stats.TableLength == 980 && (species == 25 || species == 133)) // gg tableB -- no starters, they crash trainer battles.
            {
                return(0);                                                     // Pikachu
            }
            if (EvolveToAlolanForms.Contains(species))
            {
                return(alola ? Util.Rand.Next(2) : 0);
            }
            if (!BattleExclusiveForms.Contains(species) || mega)
            {
                return(Util.Rand.Next(stats[species].FormeCount)); // Slot-Random
            }
            return(0);
        }
コード例 #4
0
        public static int GetRandomForme(int species, bool mega, bool alola, bool galar, PersonalTable stats)
        {
            if (stats == null)
            {
                return(0);
            }
            if (stats[species].FormeCount <= 1)
            {
                return(0);
            }

            if (species == 658 && !mega) // Greninja
            {
                return(0);
            }
            if (species == 664 || species == 665 || species == 666) // vivillon
            {
                return(30);                                         // save file specific
            }
            if (species == 774)                                     // minior
            {
                return(Util.Rand.Next(7));
            }
            if (species == 890) // Eternatus
            {
                return(0);
            }

            if (galar && species == 052) // Galarian Meowth is altform 2
            {
                return(Util.Rand.Next(3));
            }
            if (galar && species == 079) // todo: remove when Kanto Slowpoke is made usable in SWSH
            {
                return(1);
            }
            if (galar && species == 555) // Galarian Darmanitan is altform 2, Galarian Zen is altform 3
            {
                return(Util.Rand.Next(4));
            }

            if (stats.TableLength == 980 && (species == 25 || species == 133)) // gg tableB -- no starters, they crash trainer battles.
            {
                return(0);                                                     // Pikachu
            }
            if (EvolveToAlolanForms.Contains(species))
            {
                return(alola ? Util.Rand.Next(2) : 0);
            }
            if (EvolveToGalarForms.Contains(species))
            {
                return(galar ? Util.Rand.Next(2) : 0);
            }
            if (!BattleExclusiveForms.Contains(species) || mega)
            {
                return(Util.Rand.Next(stats[species].FormeCount)); // Slot-Random
            }
            return(0);
        }
コード例 #5
0
ファイル: Legal.cs プロジェクト: shyunsek/pkNX
        public static int GetRandomForme(int species, bool mega, bool alola, bool galar, PersonalTable stats)
        {
            if (stats == null)
            {
                return(0);
            }
            if (stats[species].FormeCount <= 1)
            {
                return(0);
            }

            if (species == (int)Species.Unown || species == (int)Species.Deerling || species == (int)Species.Sawsbuck)
            {
                return(31); // Random
            }
            if ((species == (int)Species.Greninja && !mega) || species == (int)Species.Eternatus)
            {
                return(0);
            }
            if (species == (int)Species.Scatterbug || species == (int)Species.Spewpa || species == (int)Species.Vivillon)
            {
                return(30); // save file specific
            }
            if (species == (int)Species.Minior)
            {
                return(Util.Rand.Next(7)); // keep the core color a surprise
            }
            if (galar)
            {
                switch ((Species)species)
                {
                case Species.Meowth:
                    return(Util.Rand.Next(3));    // Kanto, Alola, Galar

                case Species.Darmanitan:
                    return(Util.Rand.Next(4));    // Standard, Zen, Galar Standard, Galar Zen

                case Species.Slowbro:
                {
                    int form = Util.Rand.Next(2);         // Slowbro-1 is Mega and Slowbro-2 is Galar, so only return 0 or 2
                    if (form == 1)
                    {
                        form++;
                    }
                    return(form);
                }
                }
            }

            if (stats.TableLength == 980 && (species == (int)Species.Pikachu || species == (int)Species.Eevee)) // gg tableB -- no starters, they crash trainer battles.
            {
                return(0);
            }
            if (stats.TableLength == 1181 && species == (int)Species.Pikachu) // SWSH -- disallow Partner Pikachu from LGPE, but allow World Cap
            {
                int form = Util.Rand.Next(9);
                if (form == 8)
                {
                    form++;
                }
                return(form);
            }
            if (EvolveToAlolanForms.Contains(species))
            {
                return(alola ? Util.Rand.Next(2) : 0);
            }
            if (EvolveToGalarForms.Contains(species))
            {
                return(galar ? Util.Rand.Next(2) : 0);
            }
            if (!BattleExclusiveForms.Contains(species) || mega)
            {
                return(Util.Rand.Next(stats[species].FormeCount)); // Slot-Random
            }
            return(0);
        }
コード例 #6
0
        public IEnumerable <string> GetPrettySummary(IReadOnlyList <string> species, IReadOnlyList <string> items, IReadOnlyList <string> moves, IReadOnlyList <int> tmtrs,
                                                     IReadOnlyList <NestHoleReward8Table> drop_tables, IReadOnlyList <NestHoleReward8Table> bonus_tables, int index, PersonalTable pt = null, string[] types = null)
        {
            //yield return $"Nest ID: {TableID:X4}";
            Debug.WriteLine(index);

            yield return("{{捕捉/header/巢穴2|" + (GameVersion == 1 ? "SW" : "SH") + "}}");

            yield return($"|-\n| colspan=\"11\" class=\"bgwhite\" | Nest ID: {TableID:X4}");

            List <EncounterNest8> sortedEntries = Entries.ToList();

            sortedEntries.Sort(Xzonn.SortNest);
            List <EncounterNest8> table = new List <EncounterNest8> {
                sortedEntries[0]
            };

            uint[] Probabilities = new uint[] { 0, 0, 0, 0, 0 };
            int    i, j;

            for (i = 1; i < sortedEntries.Count; i++)
            {
                if (sortedEntries[i].Species == sortedEntries[i - 1].Species && sortedEntries[i].AltForm == sortedEntries[i - 1].AltForm && sortedEntries[i].IsGigantamax == sortedEntries[i - 1].IsGigantamax && sortedEntries[i].FlawlessIVs == sortedEntries[i - 1].FlawlessIVs && sortedEntries[i].DropTableID == sortedEntries[i - 1].DropTableID)
                {
                    for (j = 0; j < 5; j++)
                    {
                        table[table.Count - 1].Probabilities[j] += sortedEntries[i].Probabilities[j];
                    }
                }
                else
                {
                    table.Add(sortedEntries[i]);
                }
            }
            table.Sort(Xzonn.SortNest);
            for (i = 0; i < table.Count; i++)
            {
                foreach (var line in PrettySummary(table[i], table.ToArray(), i, pt, types))
                {
                    yield return($"{line}");
                }
            }
            yield return("{{捕捉/footer/巢穴2|" + (GameVersion == 1 ? "SW" : "SH") + "}}");

            /*
             * foreach (var entry in Entries)
             * {
             *  foreach (var line in PrettySummary(entry))
             *      yield return $"\t{line}";
             * }*/

            yield return(string.Empty);

            IEnumerable <string> PrettySummary(EncounterNest8 e, EncounterNest8[] table = null, int count = 0, PersonalTable pt = null, string[] types = null)
            {
                var game = GameVersion switch
                {
                    1 => "yes|no",
                    2 => "no|yes",
                    _ => throw new NotImplementedException()
                };
                int    formNum   = pt.GetFormeIndex(e.Species, e.AltForm);
                var    giga      = e.IsGigantamax ? "超极巨化" : string.Empty;
                var    form      = e.AltForm != 0 ? $"-{e.AltForm}" : string.Empty;
                string xzForm    = Xzonn.Form(formNum);
                string xzFormOut = (xzForm + giga).Length > 0 ? "|form=" + xzForm + giga : "";
                string type      = $"|type1={types[pt[formNum].Type1]}" + (pt[formNum].Type1 != pt[formNum].Type2 ? $"|type2={types[pt[formNum].Type2]}" : "");
                var    rank      = $"{e.MinRank + 1}-Star";
                string ret       = "{{捕捉/entry8/巢穴2|" + $"{e.Species:D3}{xzFormOut}|{species[e.Species]}{type}|{game}|";
                //yield return "{{" + $"" + "}}";
                //yield return $"{rank} {giga}{e.Species}-{e.AltForm} {species[e.Species]}";
                //yield return $"\tLv. {15 + (10 * e.MinRank)}-{20 + (10 * e.MaxRank)}";
                //yield return $"\tGender: {new[] { "Random", "Male", "Female", "Genderless" }[e.Gender]}";

                var ability = e.Ability switch
                {
                    2 => "100",
                    3 => "no",
                    4 => "yes",
                    _ => throw new Exception()
                };

                //yield return $"\tAbility: {ability}";
                //yield return "\tSelection Probabilities:";
                for (var i = 0; i < e.Probabilities.Length; i++)
                {
                    if (e.Probabilities[i] != 0)
                    {
                        ret += $"{e.Probabilities[i]}";
                        //yield return $"\t\t{i + 1}-Star Desired: {e.Probabilities[i]:00}%";
                    }
                    ret += "|";
                }
                ret += $"{ability}|";

                if (count == 0 || table[count - 1].FlawlessIVs != e.FlawlessIVs || table[count - 1].DropTableID != e.DropTableID || table[count - 1].BonusTableID != e.BonusTableID)
                {
                    //yield return "\tBonus Drops:";
                    foreach (var entry in GetOrderedDrops(bonus_tables, e.BonusTableID, e.FlawlessIVs))
                    {
                        ret += $"{GetItemName(entry.ItemID)}×{entry.Values[e.FlawlessIVs]}<br>";
                        //yield return $"\t\t{entry.Values[e.FlawlessIVs]} x {GetItemName(entry.ItemID)}";
                    }
                    ret = ret.Substring(0, ret.Length - 4) + "<hr>";

                    //yield return "\tDrops:";
                    foreach (var entry in GetOrderedDrops(drop_tables, e.DropTableID, e.FlawlessIVs))
                    {
                        ret += $"{GetItemName(entry.ItemID)} {entry.Values[e.FlawlessIVs]}%<br>";
                        //yield return $"\t\t{entry.Values[e.FlawlessIVs],3}% {GetItemName(entry.ItemID)}";
                    }
                    ret = ret.Substring(0, ret.Length - 4);
                    int j = 1;
                    while (count + j < table.Length && table[count + j].FlawlessIVs == e.FlawlessIVs && table[count + j].DropTableID == e.DropTableID && table[count + j].BonusTableID == e.BonusTableID)
                    {
                        j++;
                    }
                    ret += $"|{j}";
                }
                else
                {
                    ret += "|0";
                }
                ret += "}}";
                yield return(ret);
                //yield return string.Empty;
            }

            IEnumerable <INestHoleReward> GetOrderedDrops(IReadOnlyList <INestHoleRewardTable> rewards, ulong tableID, int encounterRank)
            {
                var table = rewards.First(t => t.TableID == tableID);
                var list  = table.Rewards
                            .Where(d => d.Values[encounterRank] != 0)
                            .OrderByDescending(d => d.Values[encounterRank])
                            .ThenBy(d => GetItemName(d.ItemID));

                foreach (var entry in list)
                {
                    yield return(entry);
                }
            }

            string GetItemName(uint itemID)
            {
                if (1130 <= itemID && itemID < 1230)
                { // TR
                    return("{{bag|TR " + Xzonn.TRType[(int)itemID - 1130] + $"|baglink={items[(int)itemID]}" + "}}{{TR|" + $"{(int)itemID - 1130}" + "|8}}");

                    return($"{items[(int)itemID]} {moves[tmtrs[100 + (int)itemID - 1130]]}");
                }
                return("{{bag|" + items[(int)itemID] + "|show=y}}");
            }
        }
    }