|
@@ -0,0 +1,63 @@
|
|
|
|
+using System.Linq;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
+using MafiaTelegramBot.Models;
|
|
|
|
+using MafiaTelegramBot.Resources;
|
|
|
|
+using Telegram.Bot.Types.ReplyMarkups;
|
|
|
|
+
|
|
|
|
+namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
+{
|
|
|
|
+ public partial class GameRoom
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ public abstract class Channel
|
|
|
|
+ {
|
|
|
|
+ protected readonly GameRoom Room;
|
|
|
|
+
|
|
|
|
+ protected Channel(GameRoom room)
|
|
|
|
+ {
|
|
|
|
+ Room = room;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public abstract Task Send(string message, IReplyMarkup replyMarkup = null);
|
|
|
|
+ public abstract Task SendExcept(long playerId, string message, IReplyMarkup replyMarkup = null);
|
|
|
|
+ }
|
|
|
|
+ public class PlayersChannel : Channel
|
|
|
|
+ {
|
|
|
|
+ public override async Task Send(string message, IReplyMarkup replyMarkup = null)
|
|
|
|
+ {
|
|
|
|
+ var receivers = Room.Players.Values;
|
|
|
|
+ foreach (var player in receivers)
|
|
|
|
+ await Bot.SendWithMarkdown2(player.ChatId, message, replyMarkup);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public override async Task SendExcept(long playerId, string message, IReplyMarkup replyMarkup = null)
|
|
|
|
+ {
|
|
|
|
+ var receivers = Room.Players.Values.Where(p => p.Id != playerId);
|
|
|
|
+ foreach (var player in receivers)
|
|
|
|
+ await Bot.SendWithMarkdown2(player.ChatId, message, replyMarkup);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public PlayersChannel(GameRoom room) : base(room) { }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public class MafiaChannel : Channel
|
|
|
|
+ {
|
|
|
|
+ public override async Task Send(string message, IReplyMarkup replyMarkup = null)
|
|
|
|
+ {
|
|
|
|
+ var receivers = Room.Players.Values.Where(p=> p.CurrentRole.RoleKey is Roles.Don or Roles.Mafia);
|
|
|
|
+ foreach (var player in receivers)
|
|
|
|
+ await Bot.SendWithMarkdown2(player.ChatId, message, replyMarkup);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public override async Task SendExcept(long playerId, string message, IReplyMarkup replyMarkup = null)
|
|
|
|
+ {
|
|
|
|
+ var except = Room.Players.Values.Where(p => p.Id != playerId);
|
|
|
|
+ var receivers = except.Where(p=> p.CurrentRole.RoleKey is Roles.Don or Roles.Mafia);
|
|
|
|
+ foreach (var player in receivers)
|
|
|
|
+ await Bot.SendWithMarkdown2(player.ChatId, message, replyMarkup);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public MafiaChannel(GameRoom room) : base(room) { }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|