|
@@ -26,7 +26,8 @@ namespace MafiaTelegramBot.Controllers
|
|
|
: new NormalGameRoom {Owner = creator, RoomName = roomName, IsPrivate = isPrivate};
|
|
|
OpenedGames.Add(roomKey, room);
|
|
|
room.Players.Add(creator.Id, creator);
|
|
|
-
|
|
|
+
|
|
|
+ room.SetTimer();
|
|
|
UserDao.GetPlayerById(creator.Id).Result.StopTimer();
|
|
|
|
|
|
return ResultCode.CodeOk;
|
|
@@ -43,7 +44,9 @@ namespace MafiaTelegramBot.Controllers
|
|
|
if (OpenedGames[roomKey].IsFilled()) return ResultCode.RoomIsFilled;
|
|
|
if (!player.SetRoomName(roomName)) return ResultCode.UserAlreadyInGame;
|
|
|
OpenedGames[roomKey].Players.Add(player.Id, player);
|
|
|
-
|
|
|
+
|
|
|
+ if (OpenedGames[roomKey].Players.Count > Constants.PLAYER_DISABLE_TIMER)
|
|
|
+ OpenedGames[roomKey].StopTimer();
|
|
|
UserDao.GetPlayerById(player.Id).Result.StopTimer();
|
|
|
|
|
|
await OpenedGames[roomKey].PlayersCh.SendExcept(player.Id, $"{player.NickName} {strings.connected_to_game}");
|
|
@@ -69,6 +72,8 @@ namespace MafiaTelegramBot.Controllers
|
|
|
player.CurrentRole = new NoneRole();
|
|
|
player.TurnOrder = -1;
|
|
|
OpenedGames[roomKey].Players.Remove(player.Id);
|
|
|
+ if (OpenedGames[roomKey].Players.Count <= Constants.PLAYER_DISABLE_TIMER)
|
|
|
+ OpenedGames[roomKey].StartTimer();
|
|
|
|
|
|
UserDao.GetPlayerById(player.Id).Result.StartTimer();
|
|
|
|
|
@@ -92,6 +97,7 @@ namespace MafiaTelegramBot.Controllers
|
|
|
await OpenedGames[roomKey].PlayersCh.Send(strings.room_dissolved, Keyboard.MainMenu);
|
|
|
foreach (var player in OpenedGames[roomKey].Players.Values) await player.RemoveGame();
|
|
|
RoomEncrypter.RemoveCode(OpenedGames[roomKey].RoomName);
|
|
|
+ OpenedGames[roomKey].DeleteTimer();
|
|
|
OpenedGames.Remove(roomKey);
|
|
|
}
|
|
|
});
|