Beispiel #1
0
        public async Task OnMessage(LobbyServerConnection connection, object requestData)
        {
            var request = (JoinMatchmakingQueueRequest)requestData;
            await connection.SendMessage(new JoinMatchmakingQueueResponse()
            {
                ResponseId = request.RequestId
            });

            LobbyQueueManager.AddPlayerToQueue(connection);
        }
        public async Task OnMessage(LobbyServerConnection connection, object requestData)
        {
            var request = (LeaveMatchmakingQueueRequest)requestData;

            LobbyQueueManager.RemovePlayerFromQueue(connection);
            await connection.SendMessage(new LeaveMatchmakingQueueResponse()
            {
                ResponseId = request.RequestId
            });
        }
Beispiel #3
0
        private void MakeMatchSubType(GameSubType subType)
        {
            TeamCompositionRules         composition      = subType.TeamComposition;
            List <LobbyServerConnection> availablePlayers = new List <LobbyServerConnection>(Players);
            LobbyTeamInfo teamInfo = new LobbyTeamInfo()
            {
                TeamPlayerInfo = new List <LobbyPlayerInfo>()
            };

            if (
                FillTeam(Team.TeamA, composition, subType.TeamAPlayers, subType.TeamABots, ref availablePlayers, ref teamInfo) &&
                FillTeam(Team.TeamB, composition, subType.TeamBPlayers, subType.TeamBBots, ref availablePlayers, ref teamInfo)
                )
            {
                for (int i = 0; i < teamInfo.TeamPlayerInfo.Count; i++)
                {
                    teamInfo.TeamPlayerInfo[i].PlayerId            = i + 1;
                    teamInfo.TeamPlayerInfo[i].ControllingPlayerId = i + 1; // must be non-zero for players because 0 has a special use

                    if (!teamInfo.TeamPlayerInfo[i].IsNPCBot)
                    {
                    }
                }

                LobbyGameConfig gameConfig = QueueInfo.GameConfig.Clone();
                gameConfig.RoomName = GenerateRoomName();
                gameConfig.Map      = subType.GameMapConfigs[new Random().Next(0, subType.GameMapConfigs.Count - 1)].Map;

                LobbyGameInfo gameInfo = new LobbyGameInfo()
                {
                    GameConfig            = gameConfig,
                    AcceptedPlayers       = teamInfo.TotalPlayerCount,
                    ActiveSpectators      = 0,
                    AcceptTimeout         = TimeSpan.FromSeconds(30),
                    CreateTimestamp       = DateTime.Now.Ticks,
                    GameResult            = GameResult.NoResult,
                    GameServerAddress     = "ws://127.0.0.1:6061",
                    GameStatus            = GameStatus.Launched,
                    GameServerHost        = gameConfig.RoomName,
                    GameServerProcessCode = null,
                    LoadoutSelectTimeout  = EvoSGameConfig.LoadoutSelectTimeout,
                    IsActive = true,
                    LoadoutSelectionStartTimestamp = DateTime.Now.Ticks,
                    SelectionStartTimestamp        = DateTime.Now.Ticks,
                    SelectedBotSkillTeamA          = BotDifficulty.Medium,
                    SelectedBotSkillTeamB          = BotDifficulty.Medium,
                    SelectionSubPhase = FreelancerResolutionPhaseSubType.UNDEFINED,
                    SelectionSubPhaseStartTimestamp = DateTime.Now.Ticks,
                    SelectTimeout   = TimeSpan.FromSeconds(20),
                    UpdateTimestamp = DateTime.Now.Ticks
                };

                if (GameType == GameType.Practice)
                {
                    gameInfo.AcceptTimeout = TimeSpan.Zero;
                }

                Log.Print(LogType.Debug, "Removing players from queue...");
                foreach (LobbyPlayerInfo player in teamInfo.TeamPlayerInfo)
                {
                    if (!player.IsNPCBot)
                    {
                        //Log.Print(LogType.Debug, $"found player {player.Handle}");
                        for (int i = 0; i < Players.Count; i++)
                        {
                            /*if (Players[i].PlayerInfo.GetAccountId() == player.AccountId)
                             * {
                             *  RemovePlayer(Players[i]);
                             *  break;
                             * }*/
                        }
                    }
                }
                try
                {
                    LobbyQueueManager.CreateGame(gameInfo, teamInfo);
                }
                catch (Exception)
                {
                    throw new EvosException("Error on LobbyQueueManager.CreateGame");
                }
            }
        }
Beispiel #4
0
        public async Task OnMessage(LobbyServerConnection connection, object requestData)
        {
            PlayerInfoUpdateRequest request = (PlayerInfoUpdateRequest)requestData;

            //if (request.GameType != null)
            //    connection.PlayerInfo.SetGameType(request.GameType.Value);


            // Change ReadyState
            if (request.PlayerInfoUpdate.ContextualReadyState != null)
            {
                if (request.PlayerInfoUpdate.ContextualReadyState.Value.ReadyState == ReadyState.Ready)
                {
                    //LobbyQueueManager.HandleReady(connection);
                    Log.Print(LogType.Debug, "HANDLE CHANGE READYSTATE");
                    LobbyQueueManager.AddPlayerToQueue(connection);
                }
                else
                {
                    Log.Print(LogType.Warning, "Contextual Ready state unhandled (PlayerInfoUpdateRequestHandler)");
                }
            }

            // Change Selected Freelancer
            else if (request.PlayerInfoUpdate.CharacterType != null)
            {
                //connection.PlayerInfo.SetCharacterType(request.PlayerInfoUpdate.CharacterType.Value);
                //PlayerData.SaveSelectedCharacter(connection.PlayerInfo.GetAccountId(), (int)connection.PlayerInfo.GetCharacterType());

                var accountDataUpdate = new PlayerAccountDataUpdateNotification
                {
                    AccountData = PlayerUtils.GetAccountData(connection)
                };

                await connection.SendMessage(accountDataUpdate);

                var response = new PlayerInfoUpdateResponse
                {
                    //CharacterInfo = connection.PlayerInfo.GetLobbyPlayerInfo().CharacterInfo,
                    OriginalPlayerInfoUpdate = request.PlayerInfoUpdate,
                    ResponseId = request.RequestId
                };
                await connection.SendMessage(response);

                return;
            }

            //Change Skin
            else if (request.PlayerInfoUpdate.CharacterSkin != null)
            {
                //connection.PlayerInfo.SetSkin(request.PlayerInfoUpdate.CharacterSkin.Value);
            }
            //Chnage Catalyst
            else if (request.PlayerInfoUpdate.CharacterCards != null)
            {
                //connection.PlayerInfo.SetCards(request.PlayerInfoUpdate.CharacterCards.Value);
            }
            // Chnage Mods
            else if (request.PlayerInfoUpdate.CharacterMods != null)
            {
                //connection.PlayerInfo.SetMods(request.PlayerInfoUpdate.CharacterMods.Value);
            }
            // Change Vfx
            else if (request.PlayerInfoUpdate.CharacterAbilityVfxSwaps != null)
            {
                //connection.PlayerInfo.SetAbilityVfxSwaps(request.PlayerInfoUpdate.CharacterAbilityVfxSwaps.Value);
            }
            // Chnage Loadout
            else if (request.PlayerInfoUpdate.CharacterLoadoutChanges != null)
            {
                Log.Print(LogType.Warning, "Changes in loadout not implemented yet(PlayerInfoUpdateRequestHandler.cs)");
            }
        }