public object Convert(IList <object> values, Type targetType, object parameter, CultureInfo culture) { var species = (PBESpecies)values[0]; if (!PBEDataUtils.HasForms(species, true)) { return(AvaloniaProperty.UnsetValue); } PBEForm form = true ? 0 : (PBEForm)values[1]; // TODO var localized = PBELocalizedString.GetFormName(species, form); return(StringRenderer.Render(localized.ToString(), parameter?.ToString())); }
public static string CustomPokemonToString(PBEBattlePokemon pkmn, bool useKnownInfo) { var sb = new StringBuilder(); string GetTeamNickname(PBEBattlePokemon p) { return($"{p.Trainer.Name}'s {(useKnownInfo ? p.KnownNickname : p.Nickname)}"); } void AddStatChanges() { PBEStat[] statChanges = pkmn.GetChangedStats(); if (statChanges.Length > 0) { var statStrs = new List <string>(7); if (Array.IndexOf(statChanges, PBEStat.Attack) != -1) { statStrs.Add($"[A] x{PBEBattle.GetStatChangeModifier(pkmn.AttackChange, false):0.00}"); } if (Array.IndexOf(statChanges, PBEStat.Defense) != -1) { statStrs.Add($"[D] x{PBEBattle.GetStatChangeModifier(pkmn.DefenseChange, false):0.00}"); } if (Array.IndexOf(statChanges, PBEStat.SpAttack) != -1) { statStrs.Add($"[SA] x{PBEBattle.GetStatChangeModifier(pkmn.SpAttackChange, false):0.00}"); } if (Array.IndexOf(statChanges, PBEStat.SpDefense) != -1) { statStrs.Add($"[SD] x{PBEBattle.GetStatChangeModifier(pkmn.SpDefenseChange, false):0.00}"); } if (Array.IndexOf(statChanges, PBEStat.Speed) != -1) { statStrs.Add($"[S] x{PBEBattle.GetStatChangeModifier(pkmn.SpeedChange, false):0.00}"); } if (Array.IndexOf(statChanges, PBEStat.Accuracy) != -1) { statStrs.Add($"[AC] x{PBEBattle.GetStatChangeModifier(pkmn.AccuracyChange, true):0.00}"); } if (Array.IndexOf(statChanges, PBEStat.Evasion) != -1) { statStrs.Add($"[E] x{PBEBattle.GetStatChangeModifier(pkmn.EvasionChange, true):0.00}"); } sb.AppendLine($"Stat changes: {string.Join(", ", statStrs)}"); } } void AddStatus1() { if (pkmn.Status1 != PBEStatus1.None) { sb.AppendLine($"Main status: {pkmn.Status1}"); if (pkmn.Status1 == PBEStatus1.Asleep) { sb.AppendLine($"Asleep turns: {pkmn.Status1Counter}"); } else if (pkmn.Status1 == PBEStatus1.BadlyPoisoned) { sb.AppendLine($"Toxic counter: {pkmn.Status1Counter}"); } } } void AddStatus2(PBEStatus2 status2) { status2 &= ~PBEStatus2.Flinching; // Don't show flinching sb.AppendLine($"Volatile status: {status2}"); if (status2.HasFlag(PBEStatus2.Disguised)) { sb.AppendLine($"Disguised as: {pkmn.DisguisedAsPokemon.Nickname}"); } if (pkmn.Battle.BattleFormat != PBEBattleFormat.Single) { if (status2.HasFlag(PBEStatus2.Infatuated)) { sb.AppendLine($"Infatuated with: {GetTeamNickname(pkmn.InfatuatedWithPokemon)}"); } if (status2.HasFlag(PBEStatus2.LeechSeed)) { sb.AppendLine($"Seeded position: {pkmn.SeededTeam.CombinedName}'s {pkmn.SeededPosition}"); } if (status2.HasFlag(PBEStatus2.LockOn)) { sb.AppendLine($"Taking aim at: {GetTeamNickname(pkmn.LockOnPokemon)}"); } } } if (useKnownInfo) { var pData = PBEPokemonData.GetData(pkmn.KnownSpecies, pkmn.KnownForm); string formStr = PBEDataUtils.HasForms(pkmn.KnownSpecies, false) ? $" ({PBELocalizedString.GetFormName(pkmn.KnownSpecies, pkmn.KnownForm)})" : string.Empty; sb.AppendLine($"{pkmn.KnownNickname}/{pkmn.KnownSpecies}{formStr} {(pkmn.KnownStatus2.HasFlag(PBEStatus2.Transformed) ? pkmn.Gender.ToSymbol() : pkmn.KnownGender.ToSymbol())} Lv.{pkmn.Level}"); sb.AppendLine($"HP: {pkmn.HPPercentage:P2}"); sb.Append($"Known types: {PBELocalizedString.GetTypeName(pkmn.KnownType1)}"); if (pkmn.KnownType2 != PBEType.None) { sb.Append($"/{PBELocalizedString.GetTypeName(pkmn.KnownType2)}"); } sb.AppendLine(); if (pkmn.FieldPosition != PBEFieldPosition.None) { sb.AppendLine($"Position: {pkmn.Team.CombinedName}'s {pkmn.FieldPosition}"); } AddStatus1(); if (pkmn.FieldPosition != PBEFieldPosition.None) { if (pkmn.KnownStatus2 != PBEStatus2.None) { AddStatus2(pkmn.KnownStatus2); } } PBEDataUtils.GetStatRange(pData, PBEStat.HP, pkmn.Level, pkmn.Battle.Settings, out ushort lowHP, out ushort highHP); PBEDataUtils.GetStatRange(pData, PBEStat.Attack, pkmn.Level, pkmn.Battle.Settings, out ushort lowAttack, out ushort highAttack); PBEDataUtils.GetStatRange(pData, PBEStat.Defense, pkmn.Level, pkmn.Battle.Settings, out ushort lowDefense, out ushort highDefense); PBEDataUtils.GetStatRange(pData, PBEStat.SpAttack, pkmn.Level, pkmn.Battle.Settings, out ushort lowSpAttack, out ushort highSpAttack); PBEDataUtils.GetStatRange(pData, PBEStat.SpDefense, pkmn.Level, pkmn.Battle.Settings, out ushort lowSpDefense, out ushort highSpDefense); PBEDataUtils.GetStatRange(pData, PBEStat.Speed, pkmn.Level, pkmn.Battle.Settings, out ushort lowSpeed, out ushort highSpeed); sb.AppendLine($"Stat range: [HP] {lowHP}-{highHP}, [A] {lowAttack}-{highAttack}, [D] {lowDefense}-{highDefense}, [SA] {lowSpAttack}-{highSpAttack}, [SD] {lowSpDefense}-{highSpDefense}, [S] {lowSpeed}-{highSpeed}, [W] {pkmn.KnownWeight:0.0}"); if (pkmn.FieldPosition != PBEFieldPosition.None) { AddStatChanges(); } if (pkmn.KnownAbility == PBEAbility.MAX) { sb.AppendLine($"Possible abilities: {string.Join(", ", pData.Abilities.Select(a => PBELocalizedString.GetAbilityName(a).ToString()))}"); } else { sb.AppendLine($"Known ability: {PBELocalizedString.GetAbilityName(pkmn.KnownAbility)}"); } sb.AppendLine($"Known item: {(pkmn.KnownItem == (PBEItem)ushort.MaxValue ? "???" : PBELocalizedString.GetItemName(pkmn.KnownItem).ToString())}"); sb.Append("Known moves: "); for (int i = 0; i < pkmn.Battle.Settings.NumMoves; i++) { PBEBattleMoveset.PBEBattleMovesetSlot slot = pkmn.KnownMoves[i]; PBEMove move = slot.Move; int pp = slot.PP; int maxPP = slot.MaxPP; if (i > 0) { sb.Append(", "); } sb.Append(move == PBEMove.MAX ? "???" : PBELocalizedString.GetMoveName(move).ToString()); if (move != PBEMove.None && move != PBEMove.MAX) { sb.Append($" ({pp}{(maxPP == 0 ? ")" : $"/{maxPP})")}"); } } }
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; } PBESpecies?nSpecies = PBELocalizedString.GetSpeciesByName(speciesName); if (!nSpecies.HasValue) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} ― Invalid species!"); } else { PBESpecies species = nSpecies.Value; speciesName = PBELocalizedString.GetSpeciesName(species).English; PBEForm?nForm = formName == null ? 0 : PBELocalizedString.GetFormByName(species, formName); if (!nForm.HasValue) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} ― Invalid form for {speciesName}!"); } else { PBEForm form = nForm.Value; formName = PBEDataUtils.HasForms(species, false) ? $" ({PBELocalizedString.GetFormName(species, form).English})" : string.Empty; var pData = PBEPokemonData.GetData(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 ArgumentOutOfRangeException(nameof(pData.GenderRatio)); } string weaknesses = string.Empty, resistances = string.Empty, immunities = string.Empty; for (PBEType atk = PBEType.None + 1; atk < PBEType.MAX; atk++) { double 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} ― {PBELocalizedString.GetSpeciesCategory(species).English}") .WithUrl(Utils.URL) .WithDescription(PBELocalizedString.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 => PBELocalizedString.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, PBERandom.RandomShiny(), PBERandom.RandomGender(pData.GenderRatio), false, false)); await Context.Channel.SendMessageAsync(string.Empty, embed : embed.Build()); } } }