private void RemoveGuildToBan(object sender, RoutedEventArgs e) { var guildForRemove = BannedGuilds.FirstOrDefault( guild => guild.Name.ToLower() == GuildNameTextBox.Text.ToLower() && guild.Name.ToLower() == SelectedGuildServerName.ToLower()); if (guildForRemove == null) { MessageBox.Show("Гильдия не найдена"); return; } BannedGuilds.Remove(guildForRemove); }
private void OnWindowClosing(object sender, CancelEventArgs e) { if (BannedGuilds.Any()) { WriteObjects(BannedGuildsFileName, BannedGuilds.ToList()); } if (BannedPlayers.Any()) { WriteObjects(BannedPlayersFileName, BannedPlayers.ToList()); } if (GuildsForChecking.Any()) { WriteObjects(GuildsForCheckingFileName, GuildsForChecking.ToList()); } }
private void AddGuildToBan(object sender, RoutedEventArgs e) { var bannedGuildName = GuildNameTextBox.Text; var bGuild = BannedGuilds.FirstOrDefault(g => string.Equals(g.Name, bannedGuildName, StringComparison.OrdinalIgnoreCase) && string.Equals(g.Realm, SelectedGuildServerName, StringComparison.OrdinalIgnoreCase)); if (bGuild != null) { MessageBox.Show("Данная гильдия уже добавлена"); return; } var newGuild = new Guild { Name = bannedGuildName, Realm = SelectedGuildServerName }; BannedGuilds.Add(newGuild); }
private void UpdateBannedGuildsAndPeoples() { foreach (var bannedGuild in BannedGuilds.ToArray()) { var guild = _explorer.GetGuild(Region.EU, bannedGuild.Realm, bannedGuild.Name, GuildOptions.GetMembers); Parallel.ForEach(guild.Members, member => { member.FullCharactor = _explorer.GetCharacter(Region.EU, member.GuildCharacter.Realm, member.GuildCharacter.Name, CharacterOptions.GetPetSlots); }); BannedGuilds.Remove(bannedGuild); BannedGuilds.Add(guild); } foreach (var bannedPlayer in BannedPlayers.ToArray()) { var updated = _explorer.GetCharacter(bannedPlayer.Realm, bannedPlayer.Name, CharacterOptions.GetPetSlots); BannedPlayers.Remove(bannedPlayer); BannedPlayers.Add(updated); } }
private void CheckPlayersList(object sender, RoutedEventArgs e) { if (!BannedGuilds.Any()) { MessageBox.Show("Нет забаненых гильдий"); return; } var reportError = new StringBuilder(); // Будем их чекать var checkPlayers = new ConcurrentBag <Character>(); var splittedNames = TbRaidPlayersForCheck.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Parallel.ForEach(splittedNames, player => { var info = player.Split('-'); if (info.Length != 2) { reportError.AppendLine("Не удалось проверить " + player); return; } var playerName = info[0]; var serverName = info[1]; try { var @char = _explorer.GetCharacter(Region.EU, serverName, playerName, CharacterOptions.GetPetSlots); checkPlayers.Add(@char); } catch (Exception ex) { reportError.AppendLine("Не удалось проверить:" + player + Environment.NewLine + ex.Message); } }); var outBuilder = new StringBuilder(); foreach (var checkPlayer in checkPlayers) { foreach (var bannedGuild in BannedGuilds) { foreach (var bannedMember in bannedGuild.Members) { if (bannedMember.FullCharactor == null || string.IsNullOrEmpty(bannedMember.FullCharactor.Name)) { Debug.WriteLine("Missing char"); continue; } if (bannedMember.FullCharactor.PetSlots.All(slot => slot.IsEmpty)) { outBuilder.AppendLine($"[!] bannedMember {bannedMember} no pets!"); continue; } if (checkPlayer.PetSlots.All(slot => slot.IsEmpty)) { outBuilder.AppendLine($"[!] {checkPlayer} no pets!"); continue; } if (BattleNetUtils.IsEqualCharactors(checkPlayer, bannedMember.FullCharactor)) { outBuilder.AppendLine( $"[!] <{checkPlayer}> is twink of <{bannedMember.FullCharactor}> in guild [{bannedGuild.Name}]"); } } } foreach (var bannedPlayer in BannedPlayers) { if (BattleNetUtils.IsEqualCharactors(checkPlayer, bannedPlayer)) { outBuilder.AppendLine( $"[!] <{checkPlayer}> is banned player twink of <{bannedPlayer}>"); } } } if (outBuilder.Length == 0) { MessageBox.Show("Проверка завершена. Игроки чистые :)"); } else { var resultWindow = new ResultWindow(outBuilder.ToString()); resultWindow.ShowDialog(); } }