context: using System;
  using System.Threading.Tasks;
  using PokemonGo.RocketAPI.Exceptions;
  using System.Reflection;
  using System.Net;
  using System.Text.RegularExpressions;
  using System.Threading;
  using System.Windows.Forms;
  using System.Collections.Generic; 
  using System.IO;
  using PokemonGo.RocketAPI.Logic.Utils;
  using POGOProtos.Enums;
  
  namespace PokemonGo.RocketAPI.Console
  {
      internal class Program
      {
          public static string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs");
          public static string path_translation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Translations");
          public static string account = Path.Combine(path, "Config.txt");
          public static string items = Path.Combine(path, "Items.txt");
          public static string keep = Path.Combine(path, "noTransfer.txt");
          public static string ignore = Path.Combine(path, "noCatch.txt");
          public static string evolve = Path.Combine(path, "Evolve.txt");
          public static string lastcords = Path.Combine(path, "LastCoords.txt");
          public static string huntstats = Path.Combine(path, "HuntStats.txt");
          public static string cmdCoords = string.Empty;
  
          [STAThread]
          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;
                                  case 27:
                                      Globals.TransferFirstLowIV = bool.Parse(line);
                                      break;
                                  //case 28:
                                  //    Globals.userazzberry = 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:
  
gt:                                 Globals.berry = int.Parse(line);