|
@@ -1,9 +1,14 @@
|
|
|
#nullable enable
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
+using MafiaTelegramBot.CustomCollections;
|
|
|
using MafiaTelegramBot.DataBase.Entity;
|
|
|
using MafiaTelegramBot.DataBase.EntityDao;
|
|
|
using MafiaTelegramBot.Game.GameRoles;
|
|
|
using MafiaTelegramBot.Resources;
|
|
|
+using Microsoft.EntityFrameworkCore;
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
namespace MafiaTelegramBot.Game
|
|
@@ -13,6 +18,20 @@ namespace MafiaTelegramBot.Game
|
|
|
public Role CurrentRole = new NoneRole();
|
|
|
public int TurnOrder = -1;
|
|
|
private string _roomName = "";
|
|
|
+
|
|
|
+ public StatisticsList Statistics = new();
|
|
|
+
|
|
|
+ public async Task<bool> loadStatistics()
|
|
|
+ {
|
|
|
+ List<StatisticsEntity> UserStats = await UserDao.DataBase.Statistics.Where(s => s.UserId == Id).AsNoTracking().ToListAsync();
|
|
|
+ foreach (var ROLE in UserStats)
|
|
|
+ {
|
|
|
+ Statistics.Add(Enum.Parse<Roles>(ROLE.Role),ROLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public static Player FromUserEntity(UserEntity b)
|
|
|
{
|
|
|
var serialized = JsonConvert.SerializeObject(b);
|