コード例 #1
0
        public async void AddPlayerToChat(int chatId, int playerId)
        {
            GameChat gameChat = gameChats.FirstOrDefault(gc => gc.Id == chatId);

            if (gameChat != null)
            {
                string playerName = (await playersRepository.GetPlayerAsync(playerId)).Name;
                gameChat.Players.Add(new ChatPlayer(playerId, playerName));
            }
        }
コード例 #2
0
        public async Task <IActionResult> CreatePrivateChat([FromBody] dynamic requestData)
        {
            int gameId   = requestData["gameId"];
            int playerId = requestData["playerId"];

            int[]    playerIds       = requestData["playerIds"].ToObject <int[]>();
            GameChat privateGameChat = await chatRepository.CreatePrivateChat(gameId, playerId, playerIds);

            return(new OkObjectResult(new { privateGameChat, privateChatCreated = privateGameChat != null }));
        }
コード例 #3
0
        public GameChat UpdateGameChat(int chatId, ChatData chatData)
        {
            GameChat gameChat = GetChatById(chatId);

            if (gameChat != null)
            {
                gameChat.ChatDatas.Add(chatData);
            }

            return(gameChat);
        }
コード例 #4
0
        public void Create(GameChat chat)
        {
            if (chat == null)
            {
                throw new ArgumentException($"{nameof(chat)} is null");
            }

            var sqlQuery    = @"INSERT IGNORE INTO chats (Id, Name) VALUES (@Id, @Name)";
            var queryParams = new { chat.Id, chat.Name };

            dbConnectionProvider.Connection.Execute(sqlQuery, queryParams);
        }
コード例 #5
0
        public GameChat CreateGameChat(int gameId, string name = "")
        {
            GameChat gameChat = new GameChat {
                GameId = gameId, Name = name
            };

            if (gameChats.Any())
            {
                gameChat.Id = gameChats.Last().Id + 1;
            }
            else
            {
                gameChat.Id = 1;
            }
            gameChats.Add(gameChat);

            return(gameChat);
        }
コード例 #6
0
        private static void OnGameStatusChange(GameState newGameState)
        {
            if (newGameState == GameState.PreGame)
            {
                CustomTimer.CreateTimer(() =>
                {
                    GameChat.SendMessage("Начинается движуха(By ~ vk.com id223225363)");
                    GameChat.SendMessage("Информация о игроках Radiant: ");
                    for (var i = 0; i < Players.Radiant.Count; i++)
                    {
                        uint steamid = Players.Radiant[i].PlayerSteamId;
                        string name  = Players.Radiant[i].Name;
                        if (steamid != 0)
                        {
                            DotaBuffPlayer.Parse(steamid, player =>
                            {
                                GameChat.SendMessage($"[{name}]: Уровень игры: {player.Grade}; Винрейт: {player.WinRate}; Роль: {player.Role}");
                            });
                        }
                    }

                    CustomTimer.CreateTimer(() =>
                    {
                        GameChat.SendMessage("Информация о игроках Dire: ");
                        for (var i = 0; i < Players.Dire.Count; i++)
                        {
                            uint steamid = Players.Dire[i].PlayerSteamId;
                            string name  = Players.Dire[i].Name;
                            if (steamid != 0)
                            {
                                DotaBuffPlayer.Parse(steamid, player =>
                                {
                                    GameChat.SendMessage($"[{name}]: Уровень игры: {player.Grade}; Винрейт: {player.WinRate}; Роль: {player.Role}");
                                });
                            }
                        }
                    }, 10f);
                }, 5f);
            }
        }
コード例 #7
0
        public async Task <GameChat> CreatePrivateChat(int gameId, int playerId, params int[] playerIds)
        {
            if (playerIds.Distinct().Count() != 2)
            {
                return(null);
            }
            var existedPrivateChat = CheckIfPrivateChatExist(gameId, playerIds);

            if (existedPrivateChat != null)
            {
                return(existedPrivateChat);
            }

            List <ChatPlayer> chatPlayers = new List <ChatPlayer>();

            for (int i = 0; i < playerIds.Length; i++)
            {
                bool   isNew      = playerId != playerIds[i];
                string playerName = (await playersRepository.GetPlayerAsync(playerIds[i])).Name;
                chatPlayers.Add(new ChatPlayer(playerIds[i], playerName, isNew));
            }

            GameChat gameChat = new GameChat(playerId, chatPlayers.ToArray())
            {
                GameId = gameId, IsPrivate = true, Name = ""
            };

            if (gameChats.Any())
            {
                gameChat.Id = gameChats.Last().Id + 1;
            }
            else
            {
                gameChat.Id = 1;
            }

            gameChats.Add(gameChat);
            return(gameChat);
        }
コード例 #8
0
 public void CreateChat(GameChat chat)
 {
     chatMapper.Create(chat);
 }
コード例 #9
0
 public void Create(GameChat chat)
 {
     chats.Add(chat);
 }