예제 #1
0
        void infoObservable_HandleNewPokemonLocations(List <DataCollector.PokemonMapData> mapData)
        {
            _pokemonMarks.Clear();
            _pokemonOverlay.Markers.Clear();

            foreach (var pokeData in mapData.Where(x => x.Id != null))
            {
                GMarkerGoogle pokemonMarker;
                Bitmap        pokebitMap = Pokemons.GetPokemonMediumImage(pokeData.PokemonId);
                if (pokebitMap != null)
                {
                    var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokebitMap)
                    {
                        Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                    };
                }
                else
                {
                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.green_small);
                }

                if (pokeData.Type == DataCollector.PokemonMapDataType.Nearby)
                {
                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.black_small);
                }
                pokemonMarker.ToolTipText  = StringUtils.getPokemonNameByLanguage(null, (PokemonId)pokeData.PokemonId) + ", " + pokeData.ExpiresAt.ToString() + ", " + pokeData.Coordinates.Latitude.Value.ToString() + ", " + pokeData.Coordinates.Longitude.Value.ToString();
                pokemonMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                _pokemonMarks.Add(pokeData.Id, pokemonMarker);
                _pokemonOverlay.Markers.Add(pokemonMarker);
            }

            _pokemonOverlay.IsVisibile = cbShowPokemon.Checked;
        }
예제 #2
0
        private static void ReadCommands()
        {
            while (true)
            {
                var input = System.Console.ReadLine();
                if (input == "exit")
                {
                    Environment.Exit(1);
                }

                if (input == "GUI")
                {
                    if (Globals.pokeList)
                    {
                        Task.Run(() =>
                        {
                            PokemonList.ShowDialog();
                        });
                    }
                    else
                    {
                        Task.Run(() =>
                        {
                            PokemonList = new Pokemons();
                            PokemonList.ShowDialog();
                        });
                    }
                }

                if (input == "items")
                {
                    new Logic.Logic(new Settings()).ListItems();
                }
            }
        }
예제 #3
0
        void infoObservable_HandleNewPokemonLocations(List <DataCollector.PokemonMapData> mapData)
        {
            try
            {
                if (pokemonLock.WaitOne(5000))
                {
                    if (mapData.Count > 0)
                    {
                        _pokemonMarks.Clear();
                        _pokemonOverlay.Markers.Clear();

                        int prevCount = mapData.Count;
                        mapData.Where(x => x.Id == null && x.PokemonId != null && x.Coordinates.Latitude.HasValue && x.Coordinates.Longitude.HasValue).ToList().ForEach(x => x.Id = x.PokemonId.ToString() + x.Coordinates.Longitude.Value + +x.Coordinates.Latitude.Value);
                        mapData = mapData.Where(x => x.Id != null).ToList();

                        Logger.ColoredConsoleWrite(ConsoleColor.White, string.Format("Got new Pokemon Count: {0}, unfiltered: {1}", mapData.Count, prevCount));
                        foreach (var pokeData in mapData)
                        {
                            GMarkerGoogle pokemonMarker;
                            Bitmap        pokebitMap = Pokemons.GetPokemonMediumImage(pokeData.PokemonId);
                            if (pokebitMap != null)
                            {
                                var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokebitMap)
                                {
                                    Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                                };
                            }
                            else
                            {
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.green_small);
                            }

                            if (pokeData.Type == DataCollector.PokemonMapDataType.Nearby)
                            {
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.black_small);
                            }
                            pokemonMarker.ToolTipText  = string.Format("{0}, {1}, {2}, {3}", StringUtils.getPokemonNameByLanguage(null, pokeData.PokemonId), pokeData.ExpiresAt.ToString(), pokeData.Coordinates.Latitude.Value.ToString(), pokeData.Coordinates.Longitude.Value.ToString());
                            pokemonMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                            pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                            _pokemonMarks.Add(pokeData.Id, pokemonMarker);
                            _pokemonOverlay.Markers.Add(pokemonMarker);
                        }
                    }
                    _pokemonOverlay.IsVisibile = cbShowPokemon.Checked;
                }
            }
            catch (Exception e)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: Error in HandleNewPokemonLocations: {0}", e.ToString()));
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            configureNBug();
            SleepHelper.PreventSleep();
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Found coordinates in command line: {arg}");
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }
                        cmdCoords = arg;
                    }
                }
            }
            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }
            if (!File.Exists(pokelog))
            {
                File.Create(pokelog).Close();
            }
            if (!File.Exists(manualTransferLog))
            {
                File.Create(manualTransferLog).Close();
            }
            if (!File.Exists(EvolveLog))
            {
                File.Create(EvolveLog).Close();
            }
            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                int i = 1;

                //TODO Implement JSON Load

                if (Globals.usePwdEncryption)
                {
                    Globals.password = Encryption.Decrypt(Globals.password);
                }

                if (cmdCoords != string.Empty)
                {
                    string[] crdParts = cmdCoords.Split(',');
                    Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                }
                Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Starting at: {Globals.latitute},{Globals.longitude}");
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());
                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
            }

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                CheckVersion();
                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
            SleepHelper.AllowSleep();
        }
        void infoObservable_HandleNewPokemonLocations(List <DataCollector.PokemonMapData> mapData)
        {
            Invoke(new MethodInvoker(() =>
            {
                try
                {
                    //if (pokemonLock.WaitOne(5000))
                    //{
                    if (mapData.Count > 0)
                    {
                        //_pokemonOverlay = new GMapOverlay("Pokemon");
                        _pokemonMarks.Clear();
                        _pokemonOverlay.Markers.Clear();
                        _pokemonOverlay.IsVisibile = false;

                        int prevCount = mapData.Count;
                        //mapData.Where(x => x.Id == null && x.Coordinates.Latitude.HasValue && x.Coordinates.Longitude.HasValue).ToList().ForEach(x => x.Id = x.PokemonId.ToString() + x.Coordinates.Longitude.Value + +x.Coordinates.Latitude.Value);
                        mapData = mapData.Where(x => x.Id != null).ToList();

                        //Logger.ColoredConsoleWrite(ConsoleColor.White, string.Format("Got new Pokemon Count: {0}, unfiltered: {1}", mapData.Count, prevCount));

                        for (int i = mapData.Count - 1; i >= 0; i--)
                        {
                            var pokeData = mapData[i];
                            GMarkerGoogle pokemonMarker;
                            if (pokeData.Type == DataCollector.PokemonMapDataType.Nearby)
                            {
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.black_small);
                            }
                            else
                            {
                                Bitmap pokebitMap = Pokemons.GetPokemonMediumImage(pokeData.PokemonId);
                                if (pokebitMap != null)
                                {
                                    var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokebitMap)
                                    {
                                        Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                                    };
                                }
                                else
                                {
                                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.green_small);
                                }
                            }
                            pokemonMarker.ToolTipText  = string.Format("{0}\nExpires at:{1}\n{2}\n{3},{4}", StringUtils.getPokemonNameByLanguage(null, pokeData.PokemonId), pokeData.ExpiresAt.ToString(), FindAddress(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value);
                            pokemonMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                            pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                            _pokemonMarks.Add(pokeData.Id, pokemonMarker);
                            _pokemonOverlay.Markers.Add(pokemonMarker);
                        }
                    }
                    if (!map.Overlays.Contains(_pokemonOverlay))
                    {
                        map.Overlays.Add(_pokemonOverlay);
                    }
                    _pokemonOverlay.IsVisibile = true;    //cbShowPokemon.Checked;
                    //}
                }
                catch (Exception e)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, "Ignore this: sending exception information to log file.");
                    Logger.AddLog(string.Format("Error in HandleNewPokemonLocations: {0}", e.ToString()));
                }
            }));
        }
예제 #6
0
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Found coordinates in command line: {arg}");
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }

                        cmdCoords = arg;
                    }
                }
            }

            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        try
                        {
                            switch (i)
                            {
                                case 0:
                                    if (line == "Google")
                                        Globals.acc = Enums.AuthType.Google;
                                    else
                                        Globals.acc = Enums.AuthType.Ptc;
                                    break;
                                case 1:
                                    Globals.username = line;
                                    break;
                                case 2:
                                    Globals.password = line;
                                    break;
                                case 3:
                                    if (line.Split('.').Length - 1 > 1)
                                    { // Coords in one line, comma-delimited.
                                        string[] crdParts = line.Split(',');
                                        Globals.latitute = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                        i++;
                                    }
                                    else
                                    {
                                        Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    }
                                    break;
                                case 4:
                                    Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    break;
                                case 5:
                                    Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    break;
                                case 6:
                                    Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    break;
                                case 7:
                                    Globals.radius = int.Parse(line);
                                    break;
                                case 8:
                                    Globals.defLoc = bool.Parse(line);
                                    break;
                                case 9:
                                    Globals.transfer = bool.Parse(line);
                                    break;
                                case 10:
                                    Globals.duplicate = int.Parse(line);
                                    break;
                                case 11:
                                    Globals.evolve = bool.Parse(line);
                                    break;
                                case 12:
                                    Globals.maxCp = int.Parse(line);
                                    break;
                                case 13:
                                    Globals.telAPI = line;
                                    break;
                                case 14:
                                    Globals.telName = line;
                                    break;
                                case 15:
                                    Globals.telDelay = int.Parse(line);
                                    break;
                                case 16:
                                    //Globals.telDelay = int.Parse(line);
                                    // NavigationOption...
                                    break;
                                case 17:
                                    Globals.useluckyegg = bool.Parse(line);
                                    break;
                                case 18:
                                    Globals.gerNames = bool.Parse(line);
                                    break;
                                case 19:
                                    Globals.useincense = bool.Parse(line);
                                    break;
                                case 20:
                                    Globals.ivmaxpercent = int.Parse(line);
                                    break;
                                case 21:
                                    Globals.pokeList = bool.Parse(line);
                                    break;
                                case 22:
                                    Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                    break;
                                case 23:
                                    Globals.pokevision = bool.Parse(line);
                                    break;
                                case 24:
                                    Globals.useluckyegg = bool.Parse(line);
                                    break;
                                case 25:
                                    Globals.autoIncubate = bool.Parse(line);
                                    break;
                                case 26:
                                    Globals.useBasicIncubators = bool.Parse(line);
                                    break;
                            }
                        }
                        catch (Exception)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Problem with value: {line} (line #{i})");
                            throw;
                        }
                        i++;
                    }
                    if (cmdCoords != string.Empty)
                    {
                        string[] crdParts = cmdCoords.Split(',');
                        Globals.latitute = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Starting at: {Globals.latitute},{Globals.longitude}");
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                Globals.pokeball = int.Parse(line);
                                break;
                            case 1:
                                Globals.greatball = int.Parse(line);
                                break;
                            case 2:
                                Globals.ultraball = int.Parse(line);
                                break;
                            case 3:
                                Globals.masterball = int.Parse(line);
                                break;
                            case 4:
                                Globals.revive = int.Parse(line);
                                break;
                            case 5:
                                Globals.toprevive = int.Parse(line);
                                break;
                            case 6:
                                Globals.potion = int.Parse(line);
                                break;
                            case 7:
                                Globals.superpotion = int.Parse(line);
                                break;
                            case 8:
                                Globals.hyperpotion = int.Parse(line);
                                break;
                            case 9:
                                Globals.toppotion = int.Parse(line);
                                break;
                            case 10:
                                Globals.berry = int.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                            if (Globals.gerNames)
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                            if (Globals.gerNames)
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                            if (Globals.gerNames)
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
            }

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {

                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
예제 #7
0
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, String.Format("Found coordinates in command line: {0}", arg));
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }

                        cmdCoords = arg;
                    }
                }
            }


            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        try
                        {
                            switch (i)
                            {
                            case 0:
                                if (line == "Google")
                                {
                                    Globals.acc = Enums.AuthType.Google;
                                }
                                else
                                {
                                    Globals.acc = Enums.AuthType.Ptc;
                                }
                                break;

                            case 1:
                                Globals.username = line;
                                break;

                            case 2:
                                Globals.password = line;
                                break;

                            case 3:
                                if (line.Split('.').Length - 1 > 1)
                                {     // Coords in one line, comma-delimited.
                                    string[] crdParts = line.Split(',');
                                    Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    i++;
                                }
                                else
                                {
                                    Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                }
                                break;

                            case 4:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 5:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 6:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 7:
                                Globals.radius = int.Parse(line);
                                break;

                            case 8:
                                Globals.defLoc = bool.Parse(line);
                                break;

                            case 9:
                                Globals.transfer = bool.Parse(line);
                                break;

                            case 10:
                                Globals.duplicate = int.Parse(line);
                                break;

                            case 11:
                                Globals.evolve = bool.Parse(line);
                                break;

                            case 12:
                                Globals.maxCp = int.Parse(line);
                                break;

                            case 13:
                                Globals.telAPI = line;
                                break;

                            case 14:
                                Globals.telName = line;
                                break;

                            case 15:
                                Globals.telDelay = int.Parse(line);
                                break;

                            case 16:
                                //Globals.telDelay = int.Parse(line);
                                // NavigationOption...
                                break;

                            case 17:
                                Globals.useluckyegg = bool.Parse(line);
                                break;

                            case 18:
                                Globals.gerNames = bool.Parse(line);
                                break;

                            case 19:
                                Globals.useincense = bool.Parse(line);
                                break;

                            case 20:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;

                            case 21:
                                Globals.pokeList = bool.Parse(line);
                                break;

                            case 22:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;

                            case 23:
                                Globals.pokevision = bool.Parse(line);
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, String.Format("Problem with value: {0} (line #{1})", line, i));
                            throw e;
                        }
                        i++;
                    }
                    if (cmdCoords != "")
                    {
                        string[] crdParts = cmdCoords.Split(',');
                        Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, String.Format("Starting at: {0},{1}", Globals.latitute, Globals.longitude));
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 1:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 2:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 3:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 4:
                            Globals.revive = int.Parse(line);
                            break;

                        case 5:
                            Globals.toprevive = int.Parse(line);
                            break;

                        case 6:
                            Globals.potion = int.Parse(line);
                            break;

                        case 7:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 8:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 9:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.berry = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
            }

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
예제 #8
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Current Version: " + version);
            string urlAddress = "http://pastebin.com/raw/5xi0UDAv";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream receiveStream = response.GetResponseStream();
                StreamReader readStream = null;
                if (response.CharacterSet == null)
                    readStream = new StreamReader(receiveStream);
                else
                    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                data = readStream.ReadToEnd();
                response.Close();
                readStream.Close();
                if (version.Equals(data))
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("You are already using the newest version.");
                }
                else
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("There is a newer version avaliable on GitHub. Opening link in 5 Seconds.");
                    Thread.Sleep(5000);
                    Process.Start("http://github.com/shiftcodeYT/PokeBot3/releases/latest");
                    System.Environment.Exit(1);
                }

            }
            else
            {
                System.Console.WriteLine("Couldn't check for Updates. Is Pastebin down?");
            }

            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                if (line == "Google")
                                    Globals.acc = Enums.AuthType.Google;
                                else
                                    Globals.acc = Enums.AuthType.Ptc;
                                break;
                            case 1:
                                Globals.username = line;
                                break;
                            case 2:
                                Globals.password = line;
                                break;
                            case 3:
                                Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 4:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 5:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 6:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 7:
                                Globals.radius = int.Parse(line);
                                break;
                            case 8:
                                Globals.defLoc = bool.Parse(line);
                                break;
                            case 9:
                                Globals.transfer = bool.Parse(line);
                                break;
                            case 10:
                                Globals.duplicate = int.Parse(line);
                                break;
                            case 11:
                                Globals.evolve = bool.Parse(line);
                                break;
                            case 12:
                                Globals.maxCp = int.Parse(line);
                                break;
                            case 13:
                                Globals.telAPI = line;
                                break;
                            case 14:
                                Globals.telName = line;
                                break;
                            case 15:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 16:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 17:
                                Globals.useluckyegg = bool.Parse(line);
                                break;
                            case 18:
                                Globals.gerNames = bool.Parse(line);
                                break;
                            case 19:
                                Globals.useincense = bool.Parse(line);
                                break;
                            case 21:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;
                            case 23:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;
                            case 24:
                                Globals.pokevision = bool.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                Globals.pokeball = int.Parse(line);
                                break;
                            case 1:
                                Globals.greatball = int.Parse(line);
                                break;
                            case 2:
                                Globals.ultraball = int.Parse(line);
                                break;
                            case 3:
                                Globals.revive = int.Parse(line);
                                break;
                            case 4:
                                Globals.potion = int.Parse(line);
                                break;
                            case 5:
                                Globals.superpotion = int.Parse(line);
                                break;
                            case 6:
                                Globals.hyperpotion = int.Parse(line);
                                break;
                            case 7:
                                Globals.berry = int.Parse(line);
                                break;
                            case 8:
                                Globals.masterball = int.Parse(line);
                                break;
                            case 9:
                                Globals.toppotion = int.Parse(line);
                                break;
                            case 10:
                                Globals.toprevive = int.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {

                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
예제 #9
0
        static void Main(string[] args)
        {
            SleepHelper.PreventSleep();
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Found coordinates in command line: {arg}");
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }

                        cmdCoords = arg;
                    }
                }
            }

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            if (!File.Exists(pokelog))
            {
                File.Create(pokelog).Close();
            }

            if (!File.Exists(manualTransferLog))
            {
                File.Create(manualTransferLog).Close();
            }

            if (!File.Exists(EvolveLog))
            {
                File.Create(EvolveLog).Close();
            }

            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                int i = 1;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        try
                        {
                            switch (i)
                            {
                            case 1:
                                if (line == "Google")
                                {
                                    Globals.acc = Enums.AuthType.Google;
                                }
                                else
                                {
                                    Globals.acc = Enums.AuthType.Ptc;
                                }
                                break;

                            case 2:
                                Globals.username = line;
                                break;

                            case 3:
                                Globals.password = line;
                                break;

                            case 4:
                                if (line.Split('.').Length - 1 > 1)
                                {     // Coords in one line, comma-delimited.
                                    string[] crdParts = line.Split(',');
                                    Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    i++;
                                }
                                else
                                {
                                    Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                }
                                break;

                            case 5:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 6:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 7:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 8:
                                Globals.radius = int.Parse(line);
                                break;

                            case 9:
                                Globals.defLoc = bool.Parse(line);
                                break;

                            case 10:
                                Globals.transfer = bool.Parse(line);
                                break;

                            case 11:
                                Globals.duplicate = int.Parse(line);
                                break;

                            case 12:
                                Globals.evolve = bool.Parse(line);
                                break;

                            case 13:
                                Globals.maxCp = int.Parse(line);
                                break;

                            case 14:
                                Globals.telAPI = line;
                                break;

                            case 15:
                                Globals.telName = line;
                                break;

                            case 16:
                                Globals.telDelay = int.Parse(line);
                                break;

                            case 17:
                                //Globals.telDelay = int.Parse(line);
                                // NavigationOption...
                                break;

                            case 18:
                                Globals.useluckyegg = bool.Parse(line);
                                break;

                            case 19:

                                break;

                            case 20:
                                Globals.useincense = bool.Parse(line);
                                break;

                            case 21:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;

                            case 22:
                                Globals.pokeList = bool.Parse(line);
                                break;

                            case 23:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;

                            case 24:
                                //Globals.pokevision = bool.Parse(line);
                                break;

                            case 25:
                                Globals.useluckyegg = bool.Parse(line);
                                break;

                            case 26:
                                Globals.autoIncubate = bool.Parse(line);
                                break;

                            case 27:
                                Globals.useBasicIncubators = bool.Parse(line);
                                break;

                            case 28:
                                Globals.TransferFirstLowIV = bool.Parse(line);
                                break;

                            case 34:
                                Globals.usePwdEncryption = bool.Parse(line);
                                break;
                                //case 35:
                                //    Globals.itemsList = bool.Parse(line);
                                //    break;
                            }
                        }
                        catch (Exception)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Problem with value: {line} (line #{i})");
                            throw;
                        }
                        i++;
                    }
                    if (Globals.usePwdEncryption)
                    {
                        Globals.password = Encryption.Decrypt(Globals.password);
                    }

                    if (cmdCoords != string.Empty)
                    {
                        string[] crdParts = cmdCoords.Split(',');
                        Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Starting at: {Globals.latitute},{Globals.longitude}");
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 1;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 1:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 2:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 3:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 4:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 5:
                            Globals.revive = int.Parse(line);
                            break;

                        case 6:
                            Globals.toprevive = int.Parse(line);
                            break;

                        case 7:
                            Globals.potion = int.Parse(line);
                            break;

                        case 8:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 9:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 11:
                            Globals.berry = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(Program.throws))
                {
                    string[] lines = File.ReadAllLines(@Program.throws);
                    i = 1;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 1:
                            Globals.excellentthrow = int.Parse(line);
                            break;

                        case 2:
                            Globals.greatthrow = int.Parse(line);
                            break;

                        case 3:
                            Globals.nicethrow = int.Parse(line);
                            break;

                        case 4:
                            Globals.ordinarythrow = int.Parse(line);
                            break;

                        default:
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                        {
                            Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                        {
                            Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                        {
                            Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
                //if (Globals.itemsList)
                //{
                //    Task.Run(() =>
                //    {
                //        Items itemsList = new Items();
                //        itemsList.ShowDialog();
                //    });
                //}
            }


            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
            SleepHelper.AllowSleep();
        }
예제 #10
0
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            if (line == "Google")
                            {
                                Globals.acc = Enums.AuthType.Google;
                            }
                            else
                            {
                                Globals.acc = Enums.AuthType.Ptc;
                            }
                            break;

                        case 1:
                            Globals.username = line;
                            break;

                        case 2:
                            Globals.password = line;
                            break;

                        case 3:
                            Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 4:
                            Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 5:
                            Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 6:
                            Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 7:
                            Globals.radius = int.Parse(line);
                            break;

                        case 8:
                            Globals.defLoc = bool.Parse(line);
                            break;

                        case 9:
                            Globals.transfer = bool.Parse(line);
                            break;

                        case 10:
                            Globals.duplicate = int.Parse(line);
                            break;

                        case 11:
                            Globals.evolve = bool.Parse(line);
                            break;

                        case 12:
                            Globals.maxCp = int.Parse(line);
                            break;

                        case 13:
                            Globals.telAPI = line;
                            break;

                        case 14:
                            Globals.telName = line;
                            break;

                        case 15:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 16:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 17:
                            Globals.useluckyegg = bool.Parse(line);
                            break;

                        case 18:
                            Globals.gerNames = bool.Parse(line);
                            break;

                        case 19:
                            Globals.useincense = bool.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 1:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 2:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 3:
                            Globals.revive = int.Parse(line);
                            break;

                        case 4:
                            Globals.potion = int.Parse(line);
                            break;

                        case 5:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 6:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 7:
                            Globals.berry = int.Parse(line);
                            break;

                        case 8:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 9:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.toprevive = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());


                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {
                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
예제 #11
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Current Version: " + version);
            string urlAddress = "http://pastebin.com/raw/5xi0UDAv";

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(urlAddress);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream       receiveStream = response.GetResponseStream();
                StreamReader readStream    = null;
                if (response.CharacterSet == null)
                {
                    readStream = new StreamReader(receiveStream);
                }
                else
                {
                    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                }
                data = readStream.ReadToEnd();
                response.Close();
                readStream.Close();
                if (version.Equals(data))
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("You are already using the newest version.");
                }
                else
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("There is a newer version avaliable on GitHub. Opening link in 5 Seconds.");
                    Thread.Sleep(5000);
                    Process.Start("http://github.com/shiftcodeYT/PokeBot3/releases/latest");
                    System.Environment.Exit(1);
                }
            }
            else
            {
                System.Console.WriteLine("Couldn't check for Updates. Is Pastebin down?");
            }



            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            if (line == "Google")
                            {
                                Globals.acc = Enums.AuthType.Google;
                            }
                            else
                            {
                                Globals.acc = Enums.AuthType.Ptc;
                            }
                            break;

                        case 1:
                            Globals.username = line;
                            break;

                        case 2:
                            Globals.password = line;
                            break;

                        case 3:
                            Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 4:
                            Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 5:
                            Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 6:
                            Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 7:
                            Globals.radius = int.Parse(line);
                            break;

                        case 8:
                            Globals.defLoc = bool.Parse(line);
                            break;

                        case 9:
                            Globals.transfer = bool.Parse(line);
                            break;

                        case 10:
                            Globals.duplicate = int.Parse(line);
                            break;

                        case 11:
                            Globals.evolve = bool.Parse(line);
                            break;

                        case 12:
                            Globals.maxCp = int.Parse(line);
                            break;

                        case 13:
                            Globals.telAPI = line;
                            break;

                        case 14:
                            Globals.telName = line;
                            break;

                        case 15:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 16:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 17:
                            Globals.useluckyegg = bool.Parse(line);
                            break;

                        case 18:
                            Globals.gerNames = bool.Parse(line);
                            break;

                        case 19:
                            Globals.useincense = bool.Parse(line);
                            break;

                        case 21:
                            Globals.ivmaxpercent = int.Parse(line);
                            break;

                        case 23:
                            Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                            break;

                        case 24:
                            Globals.pokevision = bool.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 1:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 2:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 3:
                            Globals.revive = int.Parse(line);
                            break;

                        case 4:
                            Globals.potion = int.Parse(line);
                            break;

                        case 5:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 6:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 7:
                            Globals.berry = int.Parse(line);
                            break;

                        case 8:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 9:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.toprevive = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {
                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
예제 #12
0
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                if (line == "Google")
                                    Globals.acc = Enums.AuthType.Google;
                                else
                                    Globals.acc = Enums.AuthType.Ptc;
                                break;
                            case 1:
                                Globals.username = line;
                                break;
                            case 2:
                                Globals.password = line;
                                break;
                            case 3:
                                Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 4:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 5:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 6:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 7:
                                Globals.radius = int.Parse(line);
                                break;
                            case 8:
                                Globals.defLoc = bool.Parse(line);
                                break;
                            case 9:
                                Globals.transfer = bool.Parse(line);
                                break;
                            case 10:
                                Globals.duplicate = int.Parse(line);
                                break;
                            case 11:
                                Globals.evolve = bool.Parse(line);
                                break;
                            case 12:
                                Globals.maxCp = int.Parse(line);
                                break;
                            case 13:
                                Globals.telAPI = line;
                                break;
                            case 14:
                                Globals.telName = line;
                                break;
                            case 15:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 16:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 17:
                                Globals.useluckyegg = bool.Parse(line);
                                break;
                            case 18:
                                Globals.gerNames = bool.Parse(line);
                                break;
                            case 19:
                                Globals.useincense = bool.Parse(line);
                                break;
                            case 21:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;
                            case 23:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                Globals.pokeball = int.Parse(line);
                                break;
                            case 1:
                                Globals.greatball = int.Parse(line);
                                break;
                            case 2:
                                Globals.ultraball = int.Parse(line);
                                break;
                            case 3:
                                Globals.revive = int.Parse(line);
                                break;
                            case 4:
                                Globals.potion = int.Parse(line);
                                break;
                            case 5:
                                Globals.superpotion = int.Parse(line);
                                break;
                            case 6:
                                Globals.hyperpotion = int.Parse(line);
                                break;
                            case 7:
                                Globals.berry = int.Parse(line);
                                break;
                            case 8:
                                Globals.masterball = int.Parse(line);
                                break;
                            case 9:
                                Globals.toppotion = int.Parse(line);
                                break;
                            case 10:
                                Globals.toprevive = int.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {

                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }