Added ~poke and ~pokab commands.
This commit is contained in:
parent
0418cfba19
commit
2b7e81e68f
@ -15,6 +15,11 @@ namespace NadekoBot.Classes
|
||||
/// </summary>
|
||||
protected DiscordModule Module { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Parent module's prefix
|
||||
/// </summary>
|
||||
protected string Prefix => Module.Prefix;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of discord command,
|
||||
/// use ": base(module)" in the derived class'
|
||||
|
116
NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs
Normal file
116
NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Classes;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Commands
|
||||
{
|
||||
class PokemonSearchCommands : DiscordCommand
|
||||
{
|
||||
private static Dictionary<string, SearchPokemon> pokemons;
|
||||
private static Dictionary<string, SearchPokemonAbility> pokemonAbilities;
|
||||
|
||||
public PokemonSearchCommands(DiscordModule module) : base(module)
|
||||
{
|
||||
|
||||
pokemons = JsonConvert.DeserializeObject<Dictionary<string, SearchPokemon>>(File.ReadAllText("data/pokemon/pokemon_list.json"));
|
||||
pokemonAbilities = JsonConvert.DeserializeObject<Dictionary<string, SearchPokemonAbility>>(File.ReadAllText("data/pokemon/pokemon_abilities.json"));
|
||||
}
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
cgb.CreateCommand(Prefix + "pokemon")
|
||||
.Alias(Prefix + "poke")
|
||||
.Description("Searches for a pokemon.")
|
||||
.Parameter("pokemon", ParameterType.Unparsed)
|
||||
.Do(async e =>
|
||||
{
|
||||
var pok = e.GetArg("pokemon")?.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(pok))
|
||||
return;
|
||||
|
||||
foreach (var kvp in pokemons)
|
||||
{
|
||||
if (kvp.Key.ToUpperInvariant() == pok.ToUpperInvariant())
|
||||
{
|
||||
await e.Channel.SendMessage($"`Stats for \"{kvp.Key}\" pokemon:`\n{kvp.Value}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
await e.Channel.SendMessage("`No pokemon found.`");
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "pokemonability")
|
||||
.Alias(Prefix + "pokab")
|
||||
.Description("Searches for a pokemon ability.")
|
||||
.Parameter("abil", ParameterType.Unparsed)
|
||||
.Do(async e =>
|
||||
{
|
||||
var ab = e.GetArg("abil")?.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(ab))
|
||||
return;
|
||||
foreach (var kvp in pokemonAbilities)
|
||||
{
|
||||
if (kvp.Key.ToUpperInvariant() == ab)
|
||||
{
|
||||
await e.Channel.SendMessage($"`Info for \"{kvp.Key}\" ability:`\n{kvp.Value}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
await e.Channel.SendMessage("`No ability found.`");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchPokemon
|
||||
{
|
||||
public class GenderRatioClass
|
||||
{
|
||||
public float M { get; set; }
|
||||
public float F { get; set; }
|
||||
}
|
||||
public class BaseStatsClass
|
||||
{
|
||||
public int HP { get; set; }
|
||||
public int ATK { get; set; }
|
||||
public int DEF { get; set; }
|
||||
public int SPA { get; set; }
|
||||
public int SPD { get; set; }
|
||||
public int SPE { get; set; }
|
||||
|
||||
public override string ToString() => $@"
|
||||
**HP:** {HP,-4} **ATK:** {ATK,-4} **DEF:** {DEF,-4}
|
||||
**SPA:** {SPA,-4} **SPD:** {SPD,-4} **SPE:** {SPE,-4}";
|
||||
}
|
||||
public int Id { get; set; }
|
||||
public string Species { get; set; }
|
||||
public string[] Types { get; set; }
|
||||
public GenderRatioClass GenderRatio { get; set; }
|
||||
public BaseStatsClass BaseStats { get; set; }
|
||||
public Dictionary<string, string> Abilities { get; set; }
|
||||
public float HeightM { get; set; }
|
||||
public float WeightKg { get; set; }
|
||||
public string Color { get; set; }
|
||||
public string[] Evos { get; set; }
|
||||
public string[] EggGroups { get; set; }
|
||||
|
||||
public override string ToString() => $@"`Name:` {Species}
|
||||
`Types:` {string.Join(", ", Types)}
|
||||
`Stats:` {BaseStats}
|
||||
`Height:` {HeightM,4}m `Weight:` {WeightKg}kg
|
||||
`Abilities:` {string.Join(", ", Abilities.Values)}";
|
||||
|
||||
}
|
||||
|
||||
public class SearchPokemonAbility
|
||||
{
|
||||
public string Desc { get; set; }
|
||||
public string Name { get; set; }
|
||||
public float Rating { get; set; }
|
||||
|
||||
public override string ToString() => $@"`Name:` : {Name}
|
||||
`Rating:` {Rating}
|
||||
`Description:` {Desc}";
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace NadekoBot.Modules.Searches
|
||||
@ -31,6 +30,7 @@ namespace NadekoBot.Modules.Searches
|
||||
commands.Add(new WowJokeCommand(this));
|
||||
commands.Add(new CalcCommand(this));
|
||||
commands.Add(new OsuCommands(this));
|
||||
commands.Add(new PokemonSearchCommands(this));
|
||||
rng = new Random();
|
||||
}
|
||||
|
||||
@ -474,6 +474,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +149,7 @@
|
||||
<Compile Include="Modules\Searches\Commands\IMDB\ImdbScraper.cs" />
|
||||
<Compile Include="Classes\IncidentsHandler.cs" />
|
||||
<Compile Include="Modules\Searches\Commands\OsuCommands.cs" />
|
||||
<Compile Include="Modules\Searches\Commands\PokemonSearchCommands.cs" />
|
||||
<Compile Include="_Models\JSONModels\AnimeResult.cs" />
|
||||
<Compile Include="_Models\JSONModels\Configuration.cs" />
|
||||
<Compile Include="Modules\Searches\Commands\WowJokes.cs" />
|
||||
@ -495,6 +496,7 @@
|
||||
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
||||
<None Include="resources\images\rose_overlay.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Loading…
Reference in New Issue
Block a user