GameRoom.Structure.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using MafiaTelegramBot.Resources;
  5. namespace MafiaTelegramBot.Game.GameRooms
  6. {
  7. public abstract partial class GameRoom
  8. {
  9. public bool IsRunning;
  10. public bool IsDay = false;
  11. public bool IsFirstCycle = false;
  12. public int MaxPlayers = 10;
  13. private int _minPlayers = Constants.PLAYER_LIMITS_MIN;
  14. public bool IsPrivate { get; init; }
  15. public abstract bool IsExtended { get; protected set; }
  16. public bool TimerEnabled { get; set; } = true;
  17. public string RoomName { get; init; } = "NoNameRoom";
  18. public Player Owner { get; init; } = new();
  19. protected readonly List<Player> VoteUpList = new();
  20. public readonly MessageHandler MHandler;
  21. public readonly QueryHandler QHandler;
  22. public readonly MafiaChannel MafiaCh;
  23. public readonly PlayersChannel PlayersCh;
  24. private readonly Queue<Player> _turnOrder = new();
  25. public readonly Dictionary<long, Player> Players = new();
  26. public readonly Dictionary<Roles, int> Settings = new()
  27. {
  28. {Roles.Mafia, 0},
  29. {Roles.Cop, 0},
  30. {Roles.Villager, 0},
  31. {Roles.Doctor, 0},
  32. {Roles.Don, 0},
  33. {Roles.Hooker, 0},
  34. };
  35. public GameRoom()
  36. {
  37. MHandler = new MessageHandler(this);
  38. QHandler = new QueryHandler(this);
  39. MafiaCh = new MafiaChannel(this);
  40. PlayersCh = new PlayersChannel(this);
  41. }
  42. public async Task<List<Player>> GetPlayers()
  43. {
  44. return await Task.Run(() =>
  45. {
  46. var players = Players.Values.ToList();
  47. players.Remove(Owner);
  48. return players;
  49. });
  50. }
  51. public bool IsFilled()
  52. {
  53. return Players.Count == MaxPlayers;
  54. }
  55. }
  56. }