示例#1
0
        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());
            }
        }
示例#2
0
        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();
            }
        }