public void HandlePlayerInfoUpdateRequest(PlayerInfoUpdateRequest request) { LobbyPlayerInfoUpdate playerInfoUpdate = request.PlayerInfoUpdate; if (request.GameType != null && request.GameType.HasValue) { SetGameType(request.GameType.Value); } if (playerInfoUpdate.CharacterType != null && playerInfoUpdate.CharacterType.HasValue) { SetCharacterType(playerInfoUpdate.CharacterType.Value); LobbyPlayerInfo playerInfo = SessionManager.GetPlayerInfo(this.AccountId); PersistedAccountData accountData = AccountManager.GetPersistedAccountData(this.AccountId); // should be automatic when account gets its data from database, but for now we modify the needed things here accountData.AccountComponent.LastCharacter = playerInfo.CharacterInfo.CharacterType; accountData.AccountComponent.SelectedBackgroundBannerID = playerInfo.BannerID; accountData.AccountComponent.SelectedForegroundBannerID = playerInfo.EmblemID; accountData.AccountComponent.SelectedRibbonID = playerInfo.RibbonID; accountData.AccountComponent.SelectedTitleID = playerInfo.TitleID; // end "should be automatic" PlayerAccountDataUpdateNotification updateNotification = new PlayerAccountDataUpdateNotification() { AccountData = accountData }; Send(updateNotification); PlayerInfoUpdateResponse response = new PlayerInfoUpdateResponse() { PlayerInfo = playerInfo, CharacterInfo = playerInfo.CharacterInfo, OriginalPlayerInfoUpdate = request.PlayerInfoUpdate, ResponseId = request.RequestId }; Send(response); } if (playerInfoUpdate.AllyDifficulty != null && playerInfoUpdate.AllyDifficulty.HasValue) { SetAllyDifficulty(playerInfoUpdate.AllyDifficulty.Value); } if (playerInfoUpdate.CharacterAbilityVfxSwaps != null && playerInfoUpdate.CharacterAbilityVfxSwaps.HasValue) { SetCharacterAbilityVfxSwaps(playerInfoUpdate.CharacterAbilityVfxSwaps.Value); } if (playerInfoUpdate.CharacterCards != null && playerInfoUpdate.CharacterCards.HasValue) { SetCharacterCards(playerInfoUpdate.CharacterCards.Value); } if (playerInfoUpdate.CharacterLoadoutChanges != null && playerInfoUpdate.CharacterLoadoutChanges.HasValue) { SetCharacterLoadoutChanges(playerInfoUpdate.CharacterLoadoutChanges.Value); } if (playerInfoUpdate.CharacterMods != null && playerInfoUpdate.CharacterMods.HasValue) { SetCharacterMods(playerInfoUpdate.CharacterMods.Value); } if (playerInfoUpdate.CharacterSkin != null && playerInfoUpdate.CharacterSkin.HasValue) { SetCharacterSkin(playerInfoUpdate.CharacterSkin.Value); } if (playerInfoUpdate.ContextualReadyState != null && playerInfoUpdate.ContextualReadyState.HasValue) { SetContextualReadyState(playerInfoUpdate.ContextualReadyState.Value); } if (playerInfoUpdate.EnemyDifficulty != null && playerInfoUpdate.EnemyDifficulty.HasValue) { SetEnemyDifficulty(playerInfoUpdate.EnemyDifficulty.Value); } if (playerInfoUpdate.LastSelectedLoadout != null && playerInfoUpdate.LastSelectedLoadout.HasValue) { SetLastSelectedLoadout(playerInfoUpdate.LastSelectedLoadout.Value); } //Console.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented)); }
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)"); } }
public async Task OnMessage(ClientConnection connection, object requestData) { /* * The clients sends this request everytime something important to loadout configuration changes * apparently it only sends in PlayerInfoUpdate the thing that was modified and everything else is is null * * ie: if the client changes freelancer, it only sends the new value of CharacterType and all other values are null */ PlayerInfoUpdateRequest request = (PlayerInfoUpdateRequest)requestData; if (request.GameType != null) { connection.SelectedGameType = request.GameType.Value; } if (request.PlayerInfoUpdate.ContextualReadyState != null) { if (request.PlayerInfoUpdate.ContextualReadyState.Value.ReadyState == ReadyState.Ready) { var practice = DummyLobbyData.CreatePracticeGameNotification(connection); Log.Print(LogType.Network, $"Responding {JsonConvert.SerializeObject(practice)}"); await connection.SendMessage(practice); var practiceGameInfo = DummyLobbyData.CreatePracticeGameInfoNotification(connection); Log.Print(LogType.Network, $"Responding {JsonConvert.SerializeObject(practiceGameInfo)}"); await connection.SendMessage(practiceGameInfo); return; } } // Change Selected Freelancer else if (request.PlayerInfoUpdate.CharacterType != null) { connection.SelectedCharacter = request.PlayerInfoUpdate.CharacterType.Value; PlayerData.SaveSelectedCharacter(connection.AccountId, (int)connection.SelectedCharacter); var accountDataUpdate = new PlayerAccountDataUpdateNotification { AccountData = PlayerUtils.GetAccountData(connection) }; Log.Print(LogType.Debug, $"Responding {JsonConvert.SerializeObject(accountDataUpdate)}"); await connection.SendMessage(accountDataUpdate); var response = new PlayerInfoUpdateResponse { CharacterInfo = DummyLobbyData.CreateLobbyCharacterInfo(connection.SelectedCharacter), OriginalPlayerInfoUpdate = request.PlayerInfoUpdate, ResponseId = request.RequestId }; await connection.SendMessage(response); return; } else if (request.PlayerInfoUpdate.CharacterSkin != null) { connection.Loadout.Skin = request.PlayerInfoUpdate.CharacterSkin.Value; } else if (request.PlayerInfoUpdate.CharacterCards != null) { connection.Loadout.Cards = request.PlayerInfoUpdate.CharacterCards.Value; } else if (request.PlayerInfoUpdate.CharacterMods != null) { connection.Loadout.Mods = request.PlayerInfoUpdate.CharacterMods.Value; } else if (request.PlayerInfoUpdate.CharacterAbilityVfxSwaps != null) { connection.Loadout.AbilityVfxSwaps = request.PlayerInfoUpdate.CharacterAbilityVfxSwaps.Value; } else if (request.PlayerInfoUpdate.CharacterLoadoutChanges != null) { // } /*if (request.PlayerInfoUpdate.CharacterType == null) * { * Log.Print(LogType.Warning, "CharacterType is null in PlayerInfoUpdateRequest"); * return; * }/ * * var accountDataUpdate = new PlayerAccountDataUpdateNotification * { * AccountData = PlayerUtils.GetAccountData(connection) * }; * accountDataUpdate.AccountData.AccountComponent.LastCharacter = request.PlayerInfoUpdate.CharacterType.Value; * Log.Print(LogType.Network, $"Responding {JsonConvert.SerializeObject(accountDataUpdate)}"); * await connection.SendMessage(accountDataUpdate); * * var response = new PlayerInfoUpdateResponse * { * CharacterInfo = DummyLobbyData.CreateLobbyCharacterInfo(request.PlayerInfoUpdate.CharacterType.Value), * // PlayerInfo = DummyLobbyData.CreateLobbyPlayerInfo(), * OriginalPlayerInfoUpdate = request.PlayerInfoUpdate, * ResponseId = request.RequestId * }; * * if (request.PlayerInfoUpdate.CharacterCards != null) * response.CharacterInfo.CharacterCards = request.PlayerInfoUpdate.CharacterCards.Value; * * if (request.PlayerInfoUpdate.CharacterMods != null) * response.CharacterInfo.CharacterMods = request.PlayerInfoUpdate.CharacterMods.Value; * * // response.PlayerInfo.PlayerId = request.PlayerInfoUpdate.PlayerId; * // response.PlayerInfo.CharacterInfo = response.CharacterInfo; * Log.Print(LogType.Network, $"Responding {JsonConvert.SerializeObject(response)}"); * await connection.SendMessage(response); */ /*try * { * var response = new PlayerInfoUpdateResponse * { * //PlayerInfo = null, * CharacterInfo = DummyLobbyData.CreateLobbyCharacterInfo(connection.SelectedCharacter), * OriginalPlayerInfoUpdate = request.PlayerInfoUpdate, * ResponseId = request.RequestId * }; * await connection.SendMessage(response); * } * catch(Exception e) { * Log.Print(LogType.Debug, e.Message); * } */ }
/// <summary> /// The client send this when there is a change in the LobbyPlayerInfo /// </summary> /// <param name="client"></param> /// <param name="request"></param> /// <returns></returns> public async static Task OnPlayerInfoUpdate(LobbyServerConnection client, PlayerInfoUpdateRequest request) { await new PlayerInfoUpdateRequestHandler().OnMessage(client, request); }