|
@@ -7,6 +7,7 @@ using MafiaTelegramBot.CustomCollections;
|
|
|
using MafiaTelegramBot.DataBase.Entity;
|
|
|
using MafiaTelegramBot.DataBase.EntityDao;
|
|
|
using MafiaTelegramBot.Game.GameRoles;
|
|
|
+using MafiaTelegramBot.Models;
|
|
|
using MafiaTelegramBot.Resources;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using Newtonsoft.Json;
|
|
@@ -18,10 +19,13 @@ namespace MafiaTelegramBot.Game
|
|
|
public GameRooms.GameRoom.Role CurrentRole = new NoneRole();
|
|
|
public int TurnOrder = -1;
|
|
|
private string _roomName = "";
|
|
|
- public bool IsAlive = true;
|
|
|
+
|
|
|
+ private static System.Timers.Timer ActiveTime;
|
|
|
public bool IsSpeaker;
|
|
|
public bool IsPlaying;
|
|
|
public bool IsFirst;
|
|
|
+
|
|
|
+ public bool IsAlive = true;
|
|
|
public bool CanBeHealed = true;
|
|
|
public bool IsBlocked = false;
|
|
|
public bool CanBeBlockedNight = true;
|
|
@@ -40,6 +44,46 @@ namespace MafiaTelegramBot.Game
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ public async Task SetTimer()
|
|
|
+ {
|
|
|
+ ActiveTime = new System.Timers.Timer(3600000);
|
|
|
+ ActiveTime.Elapsed += async (x , y) =>
|
|
|
+ {
|
|
|
+ await Remove();
|
|
|
+ };
|
|
|
+ ActiveTime.Enabled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task Restart()
|
|
|
+ {
|
|
|
+ ActiveTime.Stop();
|
|
|
+ ActiveTime.Start();
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task StopTimer()
|
|
|
+ {
|
|
|
+ ActiveTime.Stop();
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task StartTimer()
|
|
|
+ {
|
|
|
+ ActiveTime.Start();
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task Remove()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ UserDao.ActiveUsers.Remove(Id);
|
|
|
+ ActiveTime.Dispose();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ await Console.Out.WriteLineAsync("Cant delete user!");
|
|
|
+ }
|
|
|
+ //await Bot.SendHyperLink(ChatId, "Inactive now!");
|
|
|
+ }
|
|
|
|
|
|
public static Player FromUserEntity(UserEntity b)
|
|
|
{
|