// Removes a guild ID from a player's guild list IEnumerator RemoveGuildFromGuildList(string guildId, string accountId, LobbyPeer requester = null) { // Player online? if (LobbyPlayer.accountIdToLobbyPlayer.ContainsKey(accountId)) { var playerKicked = LobbyPlayer.accountIdToLobbyPlayer[accountId]; // Get guild ID list if (playerKicked.guildList == null) { yield return(GuildsDB.GetGuildList(accountId, data => { if (data == null) { playerKicked.guildList = new GuildList(); } else { playerKicked.guildList = data; } })); } // Remove guild ID from the kicked player's guild ID list playerKicked.guildList.Remove(guildId); // Set guild ID list yield return(GuildsDB.SetGuildList(accountId, playerKicked.guildList)); // Send the kicked player the new guild ID list SendGuildList(playerKicked); // Player offline } else { GuildList guildList = null; // Get guild ID list yield return(GuildsDB.GetGuildList(accountId, data => { guildList = data; })); if (guildList == null) { if (requester != null) { Lobby.RPC("GuildKickError", requester, guildId, accountId); } yield break; } // Remove guild ID from the kicked player's guild ID list guildList.Remove(guildId); // Set guild ID list yield return(GuildsDB.SetGuildList(accountId, guildList)); } }
public void UpdateGuildList(List <CharacterSetting> CharacterList) { string OldSelectedGuild = ((SelectedGuild >= 0 && SelectedGuild < GuildList.Count) ? GuildList[SelectedGuild] : null); List <string> ToRemove = new List <string>(); foreach (string GuildName in GuildList) { bool IsFound = false; foreach (CharacterSetting Character in CharacterList) { if (Character.GuildName == GuildName) { IsFound = true; break; } } if (!IsFound) { ToRemove.Add(GuildName); } } foreach (CharacterSetting Character in CharacterList) { if (Character.GuildName.Length > 0 && !GuildList.Contains(Character.GuildName)) { GuildList.Add(Character.GuildName); } } foreach (string GuildName in ToRemove) { GuildList.Remove(GuildName); } if (OldSelectedGuild != null && !GuildList.Contains(OldSelectedGuild)) { SelectedGuild = -1; } else if (GuildList.Count == 1 && SelectedGuild == -1) { SelectedGuild = 0; } }