Exemplo n.º 1
0
        async Task NewGame_(DiscordChannel channel, List <DisboardPlayer> players, ConcurrentQueue <Func <Task> > messageQueue, bool isDebug = false)
        {
            var          disboardChannel    = new DisboardChannel(channel, messageQueue, STADispatcher);
            var          gameInitializeData = new DisboardGameInitData(isDebug, Client, disboardChannel, players, OnFinish, messageQueue);
            DisboardGame game = GameFactory.New(gameInitializeData);

            if (game.IsFinished)
            {
                return;
            }

            OnFinish(channel.Id);
            if (game is DisboardGameUsingDM)
            {
                var gameUsesDM = game as DisboardGameUsingDM;
                foreach (var player in players)
                {
                    if (GamesByUsers.TryGetValue(player.Id, out var existingGame) && existingGame != game)
                    {
                        player.DM("`기존에 진행중이던 게임이 있습니다. 기존 게임에 다시 참여하려면 기존 채널에서 BOT restoredm을 입력하세요.`");
                        GamesByUsers.Remove(player.Id, out _);
                    }
                    GamesByUsers.TryAdd(player.Id, gameUsesDM !);
                }
            }

            await RunInLockAndProcessMessage(game, () =>
            {
                Games.TryAdd(channel.Id, game);
            }, gameIsInGameList : false);
        }
Exemplo n.º 2
0
 internal DisboardGameInitData(bool isDebug, DiscordClient client, DisboardChannel channel, IReadOnlyList <DisboardPlayer> players, Action <ChannelIdType> onFinish, ConcurrentQueue <Func <Task> > messageQueue)
 {
     IsDebug      = isDebug;
     Client       = client;
     Channel      = channel;
     Players      = players;
     OnFinish     = onFinish;
     MessageQueue = messageQueue;
 }
Exemplo n.º 3
0
 internal DisboardPlayer(UserIdType id, string name, string nickname, string mention, DisboardChannel channel)
 {
     Id         = id;
     Name       = name;
     Nickname   = nickname;
     Mention    = mention;
     Channel    = channel;
     NextPlayer = this;
 }
Exemplo n.º 4
0
        async Task NewDebugGame(DiscordChannel discordChannel, int mockPlayerCount)
        {
            var messageQueue = new ConcurrentQueue <Func <Task> >();
            var channel      = new DisboardChannel(discordChannel, messageQueue, STADispatcher);
            var mockPlayers  = Enumerable.Range(0, mockPlayerCount).Select(_ => new MockPlayer(_, discordChannel.Guild.Owner, channel) as DisboardPlayer).ToList();

            foreach (var(index, player) in mockPlayers.Enumerate())
            {
                int nextPlayerIndex = (index == mockPlayers.Count - 1) ? 0 : index + 1;
                player.NextPlayer = mockPlayers[nextPlayerIndex];
            }
            await NewGame_(discordChannel, mockPlayers, messageQueue, isDebug : true);
        }
Exemplo n.º 5
0
 internal MockPlayer(int index, DiscordMember member, DisboardChannel channel)
     : base(member.Id, $"{index}", $"{index}", member.Mention, channel)
 {
 }
Exemplo n.º 6
0
 internal RealPlayer(DiscordMember member, DisboardChannel dMChannel)
     : base(member.Id, member.Username, member.Nickname, member.Mention, dMChannel)
 {
 }
Exemplo n.º 7
0
 void IDisboardGameFactory.OnHelp(DisboardChannel channel) => OnHelp(channel);
Exemplo n.º 8
0
 internal void OnHelp(DisboardChannel channel) => channel.Send("게임이 도움말을 제공하지 않습니다.");