private Task <bool> GetPlayerNameFromProfile(PlayerListEntry player) { TaskCompletionSource <bool> t = new TaskCompletionSource <bool>(); PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "getEntityDisplayName", FunctionParameter = player.EntityId, GeneratePlayStreamEvent = true }, (response) => { var result = response.FunctionResult; if (result != null) { PlayFab.Json.JsonObject obj = (PlayFab.Json.JsonObject)result; object name; obj.TryGetValue("Result", out name); player.DisplayName = name.ToString(); player.IsSelected = (player.DisplayName == currentPlayer); //player.DisplayName = result.GetType().GetProperty("DisplayName").GetValue(result, null).ToString(); } t.SetResult(true); }, PlayFabErrorHandler ); return(t.Task); }
public void GetSearchResults_GetsSearchResults_Results() { string salt1 = Player.MakeSalt(); Hash hash1 = new Hash("password", salt1); Player player1 = new Player("thebigtaco", hash1.Result, salt1); player1.Save(); string salt2 = Player.MakeSalt(); Hash hash2 = new Hash("password1", salt2); Player player2 = new Player("lydianlights", hash2.Result, salt2); player2.Save(); GameStats stats1 = new GameStats(player1.Id, 100, 1, 1000, new DateTime(2013, 10, 3)); stats1.Save(); GameStats stats2 = new GameStats(player2.Id, 100000, 100, 9999, new DateTime(2013, 10, 3)); stats2.Save(); PlayerListEntry search1 = new PlayerListEntry(player1.Id, player1.Username, stats1.Score); PlayerListEntry search2 = new PlayerListEntry(player2.Id, player2.Username, stats2.Score); Dictionary <string, PlayerListEntry> result = PlayerListEntry.GetSearchResults(""); Dictionary <string, PlayerListEntry> test = new Dictionary <string, PlayerListEntry> { { player2.Username, search2 }, { player1.Username, search1 } }; CollectionAssert.AreEqual(test, result); }
private XElement GetLivePlayerListPlayerElement(PlayerListEntry playerEntry, double currentY, byte rowIndex, IList <LivePlayerListRowAction?> actions) { const byte livePlayerAreaID = (byte)Area.LivePlayersArea; return(XElement.Parse ( FormatMessage ( LivePlayerSettings.EntryTemplate, "Y", currentY.ToString(CultureInfo.InvariantCulture), "Position", playerEntry.Position.ToString(CultureInfo.InvariantCulture), "Nickname", SecurityElement.Escape(playerEntry.Nickname ?? "[" + playerEntry.Login + "]"), "Login", SecurityElement.Escape(playerEntry.Login), "IgnoreText", actions[1] == LivePlayerListRowAction.IgnorePlayer ? LivePlayerSettings.IgnoreText : LivePlayerSettings.UnIgnoreText, "BanText", actions[3] == LivePlayerListRowAction.BanPlayer ? LivePlayerSettings.BanText : LivePlayerSettings.UnBanText, "BlackListText", actions[4] == LivePlayerListRowAction.BlackListPlayer ? LivePlayerSettings.AddToBlackListText : LivePlayerSettings.RemoveFromBlackListText, "GuestText", actions[5] == LivePlayerListRowAction.AddGuest ? LivePlayerSettings.AddGuestText : LivePlayerSettings.RemoveGuestText, "SpectatorText", actions[6] == LivePlayerListRowAction.ForceSpectator ? LivePlayerSettings.ForceSpectatorText : LivePlayerSettings.SpectatorText, "WarnAction", TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[0]).ToString(CultureInfo.InvariantCulture), "IgnoreAction", TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[1]).ToString(CultureInfo.InvariantCulture), "KickAction", TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[2]).ToString(CultureInfo.InvariantCulture), "BanAction", TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[3]).ToString(CultureInfo.InvariantCulture), "BlackListAction", TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[4]).ToString(CultureInfo.InvariantCulture), "GuestAction", TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[5]).ToString(CultureInfo.InvariantCulture), "SpectatorAction", actions[6] == null ? "-" : TMAction.CalculateActionID(ID, livePlayerAreaID, rowIndex, (byte)actions[6]).ToString(CultureInfo.InvariantCulture) ) )); }
public void GetLeaderboard_GetsLeaderboardStats_Stats() { string salt1 = Player.MakeSalt(); Hash hash1 = new Hash("password", salt1); Player player1 = new Player("thebigtaco", hash1.Result, salt1); player1.Save(); string salt2 = Player.MakeSalt(); Hash hash2 = new Hash("password1", salt2); Player player2 = new Player("lydianlights", hash2.Result, salt2); player2.Save(); GameStats stats1 = new GameStats(player1.Id, 100, 1, 1000, new DateTime(2013, 10, 3)); stats1.Save(); GameStats stats2 = new GameStats(player2.Id, 100000, 100, 9999, new DateTime(2013, 10, 3)); stats2.Save(); PlayerListEntry leaderboard1 = new PlayerListEntry(player1.Id, player1.Username, stats1.Score); PlayerListEntry leaderboard2 = new PlayerListEntry(player2.Id, player2.Username, stats2.Score); List <PlayerListEntry> result = PlayerListEntry.GetLeaderboard(); List <PlayerListEntry> test = new List <PlayerListEntry> { leaderboard2, leaderboard1 }; CollectionAssert.AreEqual(test, result); }
public void Equals_Same_True() { string salt1 = Player.MakeSalt(); Hash hash1 = new Hash("password", salt1); Player player1 = new Player("thebigtaco", hash1.Result, salt1); player1.Save(); PlayerListEntry leaderboard1 = new PlayerListEntry(player1.Id, player1.Username, 1000); PlayerListEntry leaderboard2 = new PlayerListEntry(player1.Id, player1.Username, 1000); Assert.AreEqual(leaderboard1, leaderboard2); }
private void RemovePlayerList(long eid) { PlayerListEntry entry = this.playerList[eid].PlayerListEntry; Player[] players = this.playerList.Values.ToArray(); for (int i = 0; i < players.Length; ++i) { PlayerListPacket playerListPacket = new PlayerListPacket(); playerListPacket.Type = PlayerListPacket.TYPE_REMOVE; playerListPacket.Entries = new PlayerListEntry[] { entry }; players[i].SendPacket(playerListPacket); } }
private XElement GetBanListPlayerElement(PlayerListEntry playerEntry, double currentY, byte rowIndex) { return(XElement.Parse ( FormatMessage ( BanListSettings.EntryTemplate, "Y", currentY.ToString(CultureInfo.InvariantCulture), "Position", playerEntry.Position.ToString(CultureInfo.InvariantCulture), "Nickname", SecurityElement.Escape(playerEntry.Nickname ?? "[" + playerEntry.Login + "]"), "Login", SecurityElement.Escape(playerEntry.Login), "RemoveActionID", TMAction.CalculateActionID(ID, (byte)Area.BanListArea, rowIndex, (byte)BanListRowAction.RemovePlayer).ToString(CultureInfo.InvariantCulture) ) )); }
private async Task AddPlayerToList(string displayName, string bucket, string entityId) { Debug.Log($"Added {displayName}:{entityId}"); PlayerListEntry player = Instantiate(prefabPlayerListEntry, playerListLocation.transform); player.transform.SetAsFirstSibling(); player.DisplayName = displayName; player.EntityId = entityId; player.Bucket = bucket == "" ? "?" : bucket; player.onClick += PlayerSelected; player.IsSelected = player.DisplayName == currentPlayer; if (string.IsNullOrEmpty(displayName)) { await GetPlayerNameFromProfile(player); } }
public void Equals_NotSame_False() { string salt1 = Player.MakeSalt(); Hash hash1 = new Hash("password", salt1); Player player1 = new Player("thebigtaco", hash1.Result, salt1); player1.Save(); string salt2 = Player.MakeSalt(); Hash hash2 = new Hash("password1", salt2); Player player2 = new Player("lydianlights", hash2.Result, salt2); player2.Save(); PlayerListEntry leaderboard1 = new PlayerListEntry(player1.Id, player1.Username, 1000); PlayerListEntry leaderboard2 = new PlayerListEntry(player2.Id, player2.Username, 23458); Assert.AreNotEqual(leaderboard1, leaderboard2); }
public LeaderboardModel(string sessionId) : base(sessionId) { Leaderboard = PlayerListEntry.GetLeaderboard(); }
public SearchModel(string searchTerm, string sessionId) : base(sessionId) { Results = PlayerListEntry.GetSearchResults(searchTerm); }