private static List <(PBESpecies, PBEForm)> GetSpecies(PBESpecies species, PBEForm form) { // Recursion BAYBEE // IDK what to name these functions so enjoy Add1 and Add2 var list = new List <(PBESpecies, PBEForm)>(); void Add1(PBESpecies s, PBEForm f) { // Do not take forms if unable to change into them (Wormadam) if (PBEDataUtils.CanChangeForm(s, true)) { foreach (PBEForm cf in PBEDataUtils.GetForms(s, true)) { Add2(s, cf); } } else { Add2(s, f); } } void Add2(PBESpecies s, PBEForm f) { foreach ((PBESpecies cs, PBEForm cf) in PBEDataProvider.Instance.GetPokemonData(s, f).PreEvolutions) { Add1(cs, cf); } list.Add((s, f)); } Add1(species, form); return(list); }
public Pokedex() { _data = new Dictionary <PBESpecies, Dictionary <PBEForm, Dictionary <PBEGender, Entry> > >((int)PBESpecies.MAX); for (var species = (PBESpecies)1; species < PBESpecies.MAX; species++) { PBEGender[] genders = GetGenderKeys(species); IReadOnlyList <PBEForm> forms = PBEDataUtils.GetForms(species, false); if (forms.Count == 0) { forms = new PBEForm[] { 0 }; } var formDict = new Dictionary <PBEForm, Dictionary <PBEGender, Entry> >(forms.Count); for (int f = 0; f < forms.Count; f++) { PBEForm form = forms[f]; var genderDict = new Dictionary <PBEGender, Entry>(genders.Length); for (int g = 0; g < genders.Length; g++) { PBEGender gender = genders[g]; genderDict.Add(gender, new Entry(species, form, gender)); } formDict.Add(form, genderDict); } _data.Add(species, formDict); } }
public static (PBESpecies, PBEForm) RandomSpecies(this IReadOnlyList <PBESpecies> eligible, bool requireUsableOutsideOfBattle) { PBESpecies species = eligible.RandomElement(); IReadOnlyList <PBEForm> forms = PBEDataUtils.GetForms(species, requireUsableOutsideOfBattle); PBEForm form = forms.Count > 0 ? forms.RandomElement() : 0; return(species, form); }
public async Task Info([Remainder] string input) { // Inputs for forms should be like "Giratina (Origin Forme)" Match m = Regex.Match(input, @"^(\S+) \((.+)\)$"); string speciesName; string?formName; if (m.Success) { speciesName = m.Groups[1].Value; formName = m.Groups[2].Value; } else { speciesName = input; formName = null; } if (!PBEDataProvider.Instance.GetSpeciesByName(speciesName, out PBESpecies? nSpecies)) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} ― Invalid species!"); return; } PBESpecies species = nSpecies.Value; speciesName = PBEDataProvider.Instance.GetSpeciesName(species).English; PBEForm form; if (formName is null) { form = 0; } else { if (!PBEDataProvider.Instance.GetFormByName(species, formName, out PBEForm? nForm)) { IReadOnlyList <PBEForm> forms = PBEDataUtils.GetForms(species, false); string str = $"{Context.User.Mention} ― Invalid form for {speciesName}"; if (forms.Count > 0) { str += ", valid forms are:\n**" + string.Join("\n", forms.Select(f => PBEDataProvider.Instance.GetFormName(species, f).English)) + "**"; } else { str += "! It has no forms!"; } await Context.Channel.SendMessageAsync(str); return; } form = nForm.Value; } formName = PBEDataUtils.HasForms(species, false) ? $" ({PBEDataProvider.Instance.GetFormName(species, form).English})" : string.Empty; IPBEPokemonData pData = PBEDataProvider.Instance.GetPokemonData(species, form); string types = $"{Utils.TypeEmotes[pData.Type1]}"; if (pData.Type2 != PBEType.None) { types += $" {Utils.TypeEmotes[pData.Type2]}"; } string ratio; switch (pData.GenderRatio) { case PBEGenderRatio.M7_F1: ratio = "87.5% Male, 12.5% Female"; break; case PBEGenderRatio.M3_F1: ratio = "75% Male, 25% Female"; break; case PBEGenderRatio.M1_F1: ratio = "50% Male, 50% Female"; break; case PBEGenderRatio.M1_F3: ratio = "25% Male, 75% Female"; break; case PBEGenderRatio.M0_F1: ratio = "100% Female"; break; case PBEGenderRatio.M1_F0: ratio = "100% Male"; break; case PBEGenderRatio.M0_F0: ratio = "Genderless Species"; break; default: throw new InvalidDataException(nameof(pData.GenderRatio)); } string weaknesses = string.Empty, resistances = string.Empty, immunities = string.Empty; for (PBEType atk = PBEType.None + 1; atk < PBEType.MAX; atk++) { float d = PBETypeEffectiveness.GetEffectiveness(atk, pData); if (d <= 0) { if (immunities != string.Empty) { immunities += ' '; } immunities += Utils.TypeEmotes[atk]; } else if (d < 1) { if (resistances != string.Empty) { resistances += ' '; } resistances += Utils.TypeEmotes[atk]; } if (d > 1) { if (weaknesses != string.Empty) { weaknesses += ' '; } weaknesses += Utils.TypeEmotes[atk]; } } if (weaknesses == string.Empty) { weaknesses = "No Weaknesses"; } if (resistances == string.Empty) { resistances = "No Resistances"; } if (immunities == string.Empty) { immunities = "No Immunities"; } EmbedBuilder embed = new EmbedBuilder() .WithAuthor(Context.User) .WithColor(Utils.GetColor(pData.Type1, pData.Type2)) .WithTitle($"{speciesName}{formName} ― {PBEDefaultDataProvider.Instance.GetSpeciesCategory(species).English}") .WithUrl(Utils.URL) .WithDescription(PBEDefaultDataProvider.Instance.GetSpeciesEntry(species).English.Replace('\n', ' ')) .AddField("Types", types, true) .AddField("Gender Ratio", ratio, true) .AddField("Weight", $"{pData.Weight:N1} kg", true) .AddField("Abilities", string.Join(", ", pData.Abilities.Select(a => PBEDataProvider.Instance.GetAbilityName(a).English)), false) .AddField("HP", pData.BaseStats.HP, true) .AddField("Attack", pData.BaseStats.Attack, true) .AddField("Defense", pData.BaseStats.Defense, true) .AddField("Special Attack", pData.BaseStats.SpAttack, true) .AddField("Special Defense", pData.BaseStats.SpDefense, true) .AddField("Speed", pData.BaseStats.Speed, true) .AddField("Type Weaknesses", weaknesses, true) .AddField("Type Resistances", resistances, true) .AddField("Type Immunities", immunities, true) .WithImageUrl(Utils.GetPokemonSprite(species, form, PBEDataProvider.GlobalRandom.RandomShiny(), PBEDataProvider.GlobalRandom.RandomGender(pData.GenderRatio), false, false)); await Context.Channel.SendMessageAsync(string.Empty, embed : embed.Build()); }