moved PokemonMoves to their own json

This commit is contained in:
appelemac 2016-04-02 23:17:42 +02:00
parent 4a758b412f
commit ca17101586
11 changed files with 335 additions and 30 deletions

View File

@ -26,7 +26,6 @@ namespace NadekoBot.Classes
conn.CreateTable<CurrencyState>();
conn.CreateTable<CurrencyTransaction>();
conn.CreateTable<Donator>();
conn.CreateTable<PokeMoves>();
conn.CreateTable<UserPokeTypes>();
conn.CreateTable<UserQuote>();
conn.CreateTable<Reminder>();

View File

@ -14,6 +14,9 @@ namespace NadekoBot.Classes.JSONModels
[JsonIgnore]
public List<Quote> Quotes { get; set; } = new List<Quote>();
[JsonIgnore]
public List<PokeMove> PokemonMoves { get; set; } = new List<PokeMove>();
public List<string> RotatingStatuses { get; set; } = new List<string>();
public CommandPrefixesModel CommandPrefixes { get; set; } = new CommandPrefixesModel();
public HashSet<ulong> ServerBlacklist { get; set; } = new HashSet<ulong>();
@ -25,6 +28,7 @@ namespace NadekoBot.Classes.JSONModels
143515953525817344
};
public string[] _8BallResponses { get; set; } =
{
"Most definitely yes",
@ -78,6 +82,7 @@ namespace NadekoBot.Classes.JSONModels
public string CurrencySign { get; set; } = "🌸";
public string CurrencyName { get; set; } = "NadekoFlower";
}
public class CommandPrefixesModel
@ -127,4 +132,5 @@ namespace NadekoBot.Classes.JSONModels
public override string ToString() =>
$"{Text}\n\t*-{Author}*";
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Classes.JSONModels
{
public class PokeMove
{
public PokeMove(string n, string t)
{
name = n;
type = t;
}
public string name { get; set; } = "";
public string type { get; set; } = "";
}
}

View File

@ -9,6 +9,6 @@ namespace NadekoBot.Classes._DataModels
class UserPokeTypes : IDataModel
{
public long UserId { get; set; }
public int type { get; set; }
public string type { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Classes._DataModels
{
class PokeMoves : IDataModel
{
public string move { get; set; }
public int type { get; set; }
public long UserId { get; internal set; }
}
}

View File

@ -37,10 +37,10 @@ namespace NadekoBot.Modules.Pokemon
{
var db = DbHandler.Instance.GetAllRows<UserPokeTypes>();
Dictionary<long, int> setTypes = db.ToDictionary(x => x.UserId, y => y.type);
Dictionary<long, string> setTypes = db.ToDictionary(x => x.UserId, y => y.type);
if (setTypes.ContainsKey((long)id))
{
return PokemonTypesMain.IntToPokeType(setTypes[(long)id]);
return PokemonTypesMain.stringToPokeType(setTypes[(long)id])?? new PokemonTypes.NormalType();
}
int remainder = Math.Abs((int)(id % 18));
@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Pokemon
var enabledMoves = userType.GetMoves();
if (!enabledMoves.Contains(move.ToLowerInvariant()))
{
await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use {Prefix}listmoves to see moves you can use");
await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use `{Prefix}ml` to see moves you can use");
return;
}
@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Pokemon
.Do(async e =>
{
var userType = GetPokeType(e.User.Id);
List<string> movesList = userType.GetMoves();
var movesList = userType.GetMoves();
var str = $"**Moves for `{userType.Name}` type.**";
foreach (string m in movesList)
{
@ -298,7 +298,7 @@ namespace NadekoBot.Modules.Pokemon
DbHandler.Instance.InsertData(new UserPokeTypes
{
UserId = (long)e.User.Id,
type = targetType.Num
type = targetType.Name
});
//Now for the response

View File

@ -1,5 +1,6 @@
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels;
using NadekoBot.Classes.JSONModels;
using System.Collections.Generic;
namespace NadekoBot.Modules.Pokemon.PokeTypes.Extensions
@ -8,15 +9,15 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes.Extensions
{
public static List<string> GetMoves(this PokeType poketype)
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
var moveSet = NadekoBot.Config.PokemonMoves;
List<string> moves = new List<string>();
foreach (PokeMoves p in db)
foreach (PokeMove p in moveSet)
{
if (p.type == poketype.Num)
if (p.type == poketype.Name)
{
if (!moves.Contains(p.move))
if (!moves.Contains(p.name))
{
moves.Add(p.move);
moves.Add(p.name);
}
}
}

View File

@ -18,12 +18,12 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes
foreach (PokeType t in TypeList)
{
if (t.Name == newType)
if (t.Name == newType.ToUpperInvariant())
{
return t;
}
}
return null;
return new NormalType();
}
//These classes can use all methods (except getMoves)

View File

@ -66,6 +66,7 @@ namespace NadekoBot
{
Config = JsonConvert.DeserializeObject<Configuration>(File.ReadAllText("data/config.json"));
Config.Quotes = JsonConvert.DeserializeObject<List<Quote>>(File.ReadAllText("data/quotes.json"));
Config.PokemonMoves = JsonConvert.DeserializeObject<List<PokeMove>>(File.ReadAllText("data/moves.json"));
}
catch
{

View File

@ -131,6 +131,7 @@
<Compile Include="Classes\JSONModels\LocalizedStrings.cs" />
<Compile Include="Classes\JSONModels\MagicItem.cs" />
<Compile Include="Classes\JSONModels\MangaResult.cs" />
<Compile Include="Classes\JSONModels\PokeMove.cs" />
<Compile Include="Classes\JSONModels\_JSONModels.cs" />
<Compile Include="Classes\Leet.cs" />
<Compile Include="Classes\Music\MusicControls.cs" />
@ -150,7 +151,6 @@
<Compile Include="Classes\_DataModels\CurrencyTransactionModel.cs" />
<Compile Include="Classes\_DataModels\Donator.cs" />
<Compile Include="Classes\_DataModels\IDataModel.cs" />
<Compile Include="Classes\_DataModels\pokemoves.cs" />
<Compile Include="Classes\_DataModels\PokeTypes.cs" />
<Compile Include="Classes\_DataModels\Reminder.cs" />
<Compile Include="Classes\_DataModels\RequestModel.cs" />

View File

@ -0,0 +1,294 @@
[
{
"name": "sonic boom",
"type": "NORMAL"
},
{
"name": "quick attack",
"type": "NORMAL"
},
{
"name": "doubleslap",
"type": "NORMAL"
},
{
"name": "headbutt",
"type": "NORMAL"
},
{
"name": "incinerate",
"type": "FIRE"
},
{
"name": "ember",
"type": "FIRE"
},
{
"name": "fire punch",
"type": "FIRE"
},
{
"name": "fiery dance",
"type": "FIRE"
},
{
"name": "bubblebeam",
"type": "WATER"
},
{
"name": "dive",
"type": "WATER"
},
{
"name": "whirlpool",
"type": "WATER"
},
{
"name": "aqua tail",
"type": "WATER"
},
{
"name": "nuzzle",
"type": "ELECTRIC"
},
{
"name": "thunderbolt",
"type": "ELECTRIC"
},
{
"name": "thundershock",
"type": "ELECTRIC"
},
{
"name": "discharge",
"type": "ELECTRIC"
},
{
"name": "absorb",
"type": "GRASS"
},
{
"name": "mega drain",
"type": "GRASS"
},
{
"name": "vine whip",
"type": "GRASS"
},
{
"name": "razor leaf",
"type": "GRASS"
},
{
"name": "ice ball",
"type": "ICE"
},
{
"name": "powder snow",
"type": "ICE"
},
{
"name": "avalanche",
"type": "ICE"
},
{
"name": "icy wind",
"type": "ICE"
},
{
"name": "low kick",
"type": "FIGHTING"
},
{
"name": "force palm",
"type": "FIGHTING"
},
{
"name": "mach punch",
"type": "FIGHTING"
},
{
"name": "double kick",
"type": "FIGHTING"
},
{
"name": "acid",
"type": "POISON"
},
{
"name": "smog",
"type": "POISON"
},
{
"name": "sludge",
"type": "POISON"
},
{
"name": "poison jab",
"type": "POISON"
},
{
"name": "mud-slap",
"type": "GROUND"
},
{
"name": "boomerang",
"type": "GROUND"
},
{
"name": "bulldoze",
"type": "GROUND"
},
{
"name": "dig",
"type": "GROUND"
},
{
"name": "peck",
"type": "FLY"
},
{
"name": "pluck",
"type": "FLY"
},
{
"name": "gust",
"type": "FLY"
},
{
"name": "aerial ace",
"type": "FLY"
},
{
"name": "confusion",
"type": "PSYCHIC"
},
{
"name": "psybeam",
"type": "PSYCHIC"
},
{
"name": "psywave",
"type": "PSYCHIC"
},
{
"name": "heart stamp",
"type": "PSYCHIC"
},
{
"name": "bug bite",
"type": "BUG"
},
{
"name": "infestation",
"type": "BUG"
},
{
"name": "x-scissor",
"type": "BUG"
},
{
"name": "twineedle",
"type": "BUG"
},
{
"name": "rock throw",
"type": "ROCK"
},
{
"name": "rollout",
"type": "ROCK"
},
{
"name": "rock tomb",
"type": "ROCK"
},
{
"name": "rock blast",
"type": "ROCK"
},
{
"name": "astonish",
"type": "GHOST"
},
{
"name": "night shade",
"type": "GHOST"
},
{
"name": "lick",
"type": "GHOST"
},
{
"name": "ominous wind",
"type": "GHOST"
},
{
"name": "hex",
"type": "GHOST"
},
{
"name": "dragon tail",
"type": "DRAGON"
},
{
"name": "dragon rage",
"type": "DRAGON"
},
{
"name": "dragonbreath",
"type": "DRAGON"
},
{
"name": "twister",
"type": "DRAGON"
},
{
"name": "pursuit",
"type": "DARK"
},
{
"name": "assurance",
"type": "DARK"
},
{
"name": "bite",
"type": "DARK"
},
{
"name": "faint attack",
"type": "DARK"
},
{
"name": "bullet punch",
"type": "STEEL"
},
{
"name": "metal burst",
"type": "STEEL"
},
{
"name": "gear grind",
"type": "STEEL"
},
{
"name": "magnet bomb",
"type": "STEEL"
},
{
"name": "fairy wind",
"type": "FAIRY"
},
{
"name": "draining kiss",
"type": "FAIRY"
},
{
"name": "dazzling gleam",
"type": "FAIRY"
},
{
"name": "play rough",
"type": "FAIRY"
}
]