コード例 #1
0
            public async Task Info([Remainder] string speciesName)
            {
                PBESpecies?nSpecies = PBELocalizedString.GetSpeciesByName(speciesName);

                if (!nSpecies.HasValue)
                {
                    await Context.Channel.SendMessageAsync($"{Context.User.Mention} Invalid species!");
                }
                else
                {
                    PBESpecies species = nSpecies.Value;
                    var        pData   = PBEPokemonData.GetData(species);
                    string     types   = pData.Type1.ToString();
                    if (pData.Type2 != PBEType.None)
                    {
                        types += ", " + pData.Type2.ToString();
                    }
                    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));
                    }

                    EmbedBuilder embed = new EmbedBuilder()
                                         .WithAuthor(Context.User)
                                         .WithColor(Utils.GetColor(pData.Type1, pData.Type2))
                                         .WithTitle($"{PBELocalizedString.GetSpeciesName(species).English} - {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[0], true)
                                         .AddField("Attack", pData.BaseStats[1], true)
                                         .AddField("Defense", pData.BaseStats[2], true)
                                         .AddField("Special Attack", pData.BaseStats[3], true)
                                         .AddField("Special Defense", pData.BaseStats[4], true)
                                         .AddField("Speed", pData.BaseStats[5], true)
                                         .WithImageUrl(Utils.GetPokemonSprite(species, PBEUtils.RandomShiny(), PBEUtils.RandomGender(pData.GenderRatio), false, false));
                    await Context.Channel.SendMessageAsync(string.Empty, embed : embed.Build());
                }
            }