NadekoBot/NadekoBot.Modules.Pokemon/Services/PokemonService.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2017-07-17 19:42:36 +00:00
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
2017-07-17 19:42:36 +00:00
using NadekoBot.Modules.Pokemon.Common;
using NadekoBot.Services;
using Newtonsoft.Json;
using NLog;
2017-07-17 19:42:36 +00:00
namespace NadekoBot.Modules.Pokemon.Services
{
public class PokemonService : INService
{
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.");
}
}
}
}