コード例 #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);
        }