2017-07-17 19:42:36 +00:00
|
|
|
|
using System.Collections.Concurrent;
|
2017-05-27 17:42:23 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2017-07-17 19:42:36 +00:00
|
|
|
|
using NadekoBot.Modules.Pokemon.Common;
|
2017-10-13 04:14:54 +00:00
|
|
|
|
using NadekoBot.Core.Services;
|
2017-07-17 19:42:36 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using NLog;
|
2017-05-27 17:42:23 +00:00
|
|
|
|
|
2017-07-17 19:42:36 +00:00
|
|
|
|
namespace NadekoBot.Modules.Pokemon.Services
|
2017-05-27 17:42:23 +00:00
|
|
|
|
{
|
2017-07-15 03:04:16 +00:00
|
|
|
|
public class PokemonService : INService
|
2017-05-27 17:42:23 +00:00
|
|
|
|
{
|
|
|
|
|
public readonly List<PokemonType> PokemonTypes = new List<PokemonType>();
|
|
|
|
|
public readonly ConcurrentDictionary<ulong, PokeStats> Stats = new ConcurrentDictionary<ulong, PokeStats>();
|
|
|
|
|
|
|
|
|
|
public const string PokemonTypesFile = "data/pokemon_types.json";
|
|
|
|
|
|
|
|
|
|
private Logger _log { get; }
|
|
|
|
|
|
|
|
|
|
public PokemonService()
|
|
|
|
|
{
|
|
|
|
|
_log = LogManager.GetCurrentClassLogger();
|
|
|
|
|
if (File.Exists(PokemonTypesFile))
|
|
|
|
|
{
|
|
|
|
|
PokemonTypes = JsonConvert.DeserializeObject<List<PokemonType>>(File.ReadAllText(PokemonTypesFile));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PokemonTypes = new List<PokemonType>();
|
|
|
|
|
_log.Warn(PokemonTypesFile + " is missing. Pokemon types not loaded.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|