private static Session SetupTranslationCode(Session session, ITranslation translator, GlobalSettings settings) { Logger.Write(translator.GetTranslation(TranslationString.FirstStartLanguagePrompt, "Y", "N"), LogLevel.None); string strInput; bool boolBreak = false; while (!boolBreak) { strInput = Console.ReadLine().ToLower(); switch (strInput) { case "y": boolBreak = true; break; case "n": return session; default: Logger.Write(translator.GetTranslation(TranslationString.PromptError, "y", "n"), LogLevel.Error); continue; } } Logger.Write(translator.GetTranslation(TranslationString.FirstStartLanguageCodePrompt)); strInput = Console.ReadLine(); settings.TranslationLanguageCode = strInput; session = new Session(new ClientSettings(settings), new LogicSettings(settings)); translator = session.Translation; Logger.Write(translator.GetTranslation(TranslationString.FirstStartLanguageConfirm, strInput)); return session; }
public LogicSettings(GlobalSettings settings) { _settings = settings; }
public static Session SetupSettings(Session session, GlobalSettings settings, String configPath) { Session newSession = SetupTranslationCode(session, session.Translation, settings); SetupAccountType(newSession.Translation, settings); SetupUserAccount(newSession.Translation, settings); SetupConfig(newSession.Translation, settings); SaveFiles(settings, configPath); Logger.Write(session.Translation.GetTranslation(TranslationString.FirstStartSetupCompleted), LogLevel.None); return newSession; }
private static void SetupAccountType(ITranslation translator, GlobalSettings settings) { string strInput; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupAccount), LogLevel.None); Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupTypePrompt, "google", "ptc")); while (true) { strInput = Console.ReadLine().ToLower(); switch (strInput) { case "google": settings.Auth.AuthType = AuthType.Google; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupTypeConfirm, "GOOGLE")); return; case "ptc": settings.Auth.AuthType = AuthType.Ptc; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupTypeConfirm, "PTC")); return; default: Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupTypePromptError, "google", "ptc"), LogLevel.Error); break; } } }
private static void SetupConfig(GlobalSettings settings) { Logger.Write("### Setting Default Position ###", LogLevel.None); Logger.Write("Please enter a Latitude (Right click to paste)"); while (true) { try { double dblInput = double.Parse(Console.ReadLine()); settings.DefaultLatitude = dblInput; Logger.Write("Lattitude accepted: " + dblInput); break; } catch (FormatException) { Logger.Write("[ERROR] Please input only a VALUE for example: " + settings.DefaultLatitude, LogLevel.Error); continue; } } Logger.Write("Please enter a Longitude (Right click to paste)"); while (true) { try { double dblInput = double.Parse(Console.ReadLine()); settings.DefaultLongitude = dblInput; Logger.Write("Longitude accepted: " + dblInput); break; } catch (FormatException) { Logger.Write("[ERROR] Please input only a VALUE for example: " + settings.DefaultLongitude, LogLevel.Error); continue; } } }
private static void SetupUserAccount(GlobalSettings settings) { Console.WriteLine(""); Logger.Write("Please enter a Username", LogLevel.None); string strInput = Console.ReadLine(); if (settings.Auth.AuthType == AuthType.Google) settings.Auth.GoogleUsername = strInput; else settings.Auth.PtcUsername = strInput; Logger.Write("Accepted username: "******""); Logger.Write("Please enter a Password", LogLevel.None); strInput = Console.ReadLine(); if (settings.Auth.AuthType == AuthType.Google) settings.Auth.GooglePassword = strInput; else settings.Auth.PtcPassword = strInput; Logger.Write("Accepted password: "******"### User Account Completed ###\n", LogLevel.None); }
public LogicSettings(GlobalSettings settings) { _settings = settings; }
public static GlobalSettings Load(string path) { GlobalSettings settings = null; bool isGui = (AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.Contains("PoGo.NecroBot.GUI")).SingleOrDefault() != null); var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); var shouldExit = false; if (File.Exists(configFile)) { try { //if the file exists, load the settings var input = File.ReadAllText(configFile); var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject<GlobalSettings>(input, jsonSettings); //This makes sure that existing config files dont get null values which lead to an exception foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.KeepMinOperator == null)) { filter.Value.KeepMinOperator = "or"; } foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.Moves == null)) { filter.Value.Moves = new List<PokemonMove>(); } foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.MovesOperator == null)) { filter.Value.MovesOperator = "or"; } } catch (JsonReaderException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return null; } } else if (!isGui) { Logger.Write("This is your first start, would you like to begin setup? Y/N", LogLevel.Warning); bool boolBreak = false; settings = new GlobalSettings(); while (!boolBreak) { string strInput = Console.ReadLine().ToLower(); switch (strInput) { case "y": boolBreak = true; SetupSettings(settings); break; case "n": Logger.Write("Config/Auth file automatically generated and must be completed before continuing"); boolBreak = true; shouldExit = true; break; default: Logger.Write("[INPUT ERROR] Error with input, please enter 'y' or 'n'", LogLevel.Error); continue; } } } else { settings = new GlobalSettings(); shouldExit = true; } settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); settings.isGui = isGui; settings.migratePercentages(); settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); return shouldExit ? null : settings; }
public static GlobalSettings Load(string path) { GlobalSettings settings; var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); var shouldExit = false; if (File.Exists(configFile)) { try { //if the file exists, load the settings var input = File.ReadAllText(configFile); var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject <GlobalSettings>(input, jsonSettings); //This makes sure that existing config files dont get null values which lead to an exception foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.KeepMinOperator == null)) { filter.Value.KeepMinOperator = "or"; } foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.Moves == null)) { filter.Value.Moves = new List <PokemonMove>(); } } catch (JsonReaderException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return(null); } } else { Logger.Write("This is your first start, would you like to begin setup? Y/N", LogLevel.Warning); bool boolBreak = false; settings = new GlobalSettings(); while (!boolBreak) { string strInput = Console.ReadLine().ToLower(); switch (strInput) { case "y": boolBreak = true; SetupSettings(settings); break; case "n": Logger.Write("Config/Auth file automatically generated and must be completed before continuing"); boolBreak = true; shouldExit = true; break; default: Logger.Write("[INPUT ERROR] Error with input, please enter 'y' or 'n'", LogLevel.Error); continue; } } } settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); settings.migratePercentages(); settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); return(shouldExit ? null : settings); }
public ClientSettings(GlobalSettings settings) { _settings = settings; }
public MultiAccountManager(GlobalSettings globalSettings, List <AuthConfig> accounts) { _globalSettings = globalSettings; MigrateDatabase(); SyncDatabase(accounts); }
private void DefaultsButton_Click(object sender, RoutedEventArgs e) { _set = new GlobalSettings(); Settings = ObservableSettings.CreateFromGlobalSettings(_set); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { var profilePath = Path.Combine(Directory.GetCurrentDirectory(), ""); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); var authFile = Path.Combine(profileConfigPath, "auth.json"); _set = Settings.GetGlobalSettingsObject(); _set.Save(configFile); _set.Auth.Save(authFile); }
private void ReloadButton_Click(object sender, RoutedEventArgs e) { _set = GlobalSettings.Load(""); if (null == _set) _set = GlobalSettings.Load(""); if (null == _set) throw new Exception("There was an error attempting to build default config files - may be a file permissions issue! Cannot proceed."); Settings = ObservableSettings.CreateFromGlobalSettings(_set); }
public static ObservableSettings CreateFromGlobalSettings(GlobalSettings set) { ObservableSettings res = new ObservableSettings(); // BASIC res.TranslationLanguageCode = set.TranslationLanguageCode; res.AutoUpdate = set.AutoUpdate; res.TransferConfigAndAuthOnUpdate = set.TransferConfigAndAuthOnUpdate; res.DisableHumanWalking = set.DisableHumanWalking; res.Latitude = set.DefaultLatitude; res.Longitude = set.DefaultLongitude; res.MaxTravelDistanceInMeters = set.MaxTravelDistanceInMeters; res.WalkingSpeedInKilometerPerHour = set.WalkingSpeedInKilometerPerHour; res.MaxSpawnLocationOffset = set.MaxSpawnLocationOffset; res.DelayBetweenPlayerActions = set.DelayBetweenPlayerActions; res.DelayBetweenPokemonCatch = set.DelayBetweenPokemonCatch; // AUTH res.AuthType = set.Auth.AuthType; res.GoogleUsername = set.Auth.GoogleUsername; res.GooglePassword = set.Auth.GooglePassword; res.PtcUsername = set.Auth.PtcUsername; res.PtcPassword = set.Auth.PtcPassword; res.UseProxy = set.Auth.UseProxy; res.UseProxyHost = set.Auth.UseProxyHost; res.UseProxyPort = set.Auth.UseProxyPort; res.UseProxyAuthentication = set.Auth.UseProxyAuthentication; res.UseProxyUsername = set.Auth.UseProxyUsername; res.UseProxyPassword = set.Auth.UseProxyPassword; // DEVICE res.DevicePackageName = set.Auth.DevicePackageName; res.DeviceId = set.Auth.DeviceId; res.AndroidBoardName = set.Auth.AndroidBoardName; res.AndroidBootloader = set.Auth.AndroidBootloader; res.DeviceBrand = set.Auth.DeviceBrand; res.DeviceModel = set.Auth.DeviceModel; res.DeviceModelIdentifier = set.Auth.DeviceModelIdentifier; res.DeviceModelBoot = set.Auth.DeviceModelBoot; res.HardwareManufacturer = set.Auth.HardwareManufacturer; res.HardwareModel = set.Auth.HardwareModel; res.FirmwareBrand = set.Auth.FirmwareBrand; res.FirmwareTags = set.Auth.FirmwareTags; res.FirmwareType = set.Auth.FirmwareType; res.FirmwareFingerprint = set.Auth.FirmwareFingerprint; // INVENTORY res.VerboseRecycling = set.VerboseRecycling; res.RecycleInventoryAtUsagePercentage = set.RecycleInventoryAtUsagePercentage; res.TotalAmountOfPokeballsToKeep = set.TotalAmountOfPokeballsToKeep; res.TotalAmountOfPotionsToKeep = set.TotalAmountOfPotionsToKeep; res.TotalAmountOfRevivesToKeep = set.TotalAmountOfRevivesToKeep; res.TotalAmountOfBerriesToKeep = set.TotalAmountOfBerriesToKeep; res.UseEggIncubators = set.UseEggIncubators; res.UseLuckyEggConstantly = set.UseLuckyEggConstantly; res.UseLuckyEggsMinPokemonAmount = set.UseLuckyEggsMinPokemonAmount; res.UseLuckyEggsWhileEvolving = set.UseLuckyEggsWhileEvolving; res.UseIncenseConstantly = set.UseIncenseConstantly; // POKEMON res.RenamePokemon = set.RenamePokemon; res.RenameOnlyAboveIv = set.RenameOnlyAboveIv; res.RenameTemplate = set.RenameTemplate; res.AutomaticallyLevelUpPokemon = set.AutomaticallyLevelUpPokemon; res.AmountOfTimesToUpgradeLoop = set.AmountOfTimesToUpgradeLoop; res.GetMinStarDustForLevelUp = set.GetMinStarDustForLevelUp; res.LevelUpByCPorIv = set.LevelUpByCPorIv; res.UpgradePokemonCpMinimum = set.UpgradePokemonCpMinimum; res.UpgradePokemonIvMinimum = set.UpgradePokemonIvMinimum; res.UpgradePokemonMinimumStatsOperator = set.UpgradePokemonMinimumStatsOperator; res.EvolveAboveIvValue = set.EvolveAboveIvValue; res.EvolveAllPokemonAboveIv = set.EvolveAllPokemonAboveIv; res.EvolveAllPokemonWithEnoughCandy = set.EvolveAllPokemonWithEnoughCandy; res.EvolveKeptPokemonsAtStorageUsagePercentage = set.EvolveKeptPokemonsAtStorageUsagePercentage; res.KeepPokemonsThatCanEvolve = set.KeepPokemonsThatCanEvolve; res.AutoFavoritePokemon = set.AutoFavoritePokemon; res.FavoriteMinIvPercentage = set.FavoriteMinIvPercentage; // CAPTURE res.CatchPokemon = set.CatchPokemon; res.UsePokemonToNotCatchFilter = set.UsePokemonToNotCatchFilter; res.MaxPokeballsPerPokemon = set.MaxPokeballsPerPokemon; res.MaxBerriesToUsePerPokemon = set.MaxBerriesToUsePerPokemon; res.UseGreatBallAboveCp = set.UseGreatBallAboveCp; res.UseUltraBallAboveCp = set.UseUltraBallAboveCp; res.UseMasterBallAboveCp = set.UseMasterBallAboveCp; res.UseGreatBallAboveIv = set.UseGreatBallAboveIv; res.UseUltraBallAboveIv = set.UseUltraBallAboveIv; res.UseGreatBallBelowCatchProbability = set.UseGreatBallBelowCatchProbability; res.UseUltraBallBelowCatchProbability = set.UseUltraBallBelowCatchProbability; res.UseMasterBallBelowCatchProbability = set.UseMasterBallBelowCatchProbability; res.UseBerriesMinCp = set.UseBerriesMinCp; res.UseBerriesMinIv = set.UseBerriesMinIv; res.UseBerriesBelowCatchProbability = set.UseBerriesBelowCatchProbability; res.UseBerriesOperator = set.UseBerriesOperator; res.EnableHumanizedThrows = set.EnableHumanizedThrows; res.NiceThrowChance = set.NiceThrowChance; res.GreatThrowChance = set.GreatThrowChance; res.ExcellentThrowChance = set.ExcellentThrowChance; res.CurveThrowChance = set.CurveThrowChance; res.ForceGreatThrowOverIv = set.ForceGreatThrowOverIv; res.ForceExcellentThrowOverIv = set.ForceExcellentThrowOverIv; res.ForceGreatThrowOverCp = set.ForceGreatThrowOverCp; res.ForceExcellentThrowOverCp = set.ForceExcellentThrowOverCp; // TRANSFER // SNIPING // MISC return res; }
public static GlobalSettings Load(string path) { GlobalSettings settings; var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); if (File.Exists(configFile)) { try { //if the file exists, load the settings var input = File.ReadAllText(configFile); var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new StringEnumConverter {CamelCaseText = true}); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject<GlobalSettings>(input, jsonSettings); } catch (JsonReaderException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return null; } } else { settings = new GlobalSettings(); } if (settings.WebSocketPort == 0) { settings.WebSocketPort = 14251; } if (settings.PokemonToSnipe == null) { settings.PokemonToSnipe = Default.PokemonToSnipe; } if (settings.RenameTemplate == null) { settings.RenameTemplate = Default.RenameTemplate; } if (settings.SnipeLocationServer == null) { settings.SnipeLocationServer = Default.SnipeLocationServer; } settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); var firstRun = !File.Exists(configFile); settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); if (firstRun) { return null; } return settings; }
/* MISC //gpx public bool UseGpxPathing; public string GpxFile; //websockets public bool UseWebsocket; public int WebSocketPort; //Telegram public bool UseTelegramAPI; public string TelegramAPIKey; //console options public bool StartupWelcomeDelay; public int AmountOfPokemonToDisplayOnStart; public bool DetailedCountsBeforeRecycling; public bool DumpPokemonStats; SNIPING //snipe public bool UseSnipeLocationServer; public string SnipeLocationServer; public int SnipeLocationServerPort; public bool GetSniperInfoFromPokezz; public bool GetOnlyVerifiedSniperInfoFromPokezz; public int MinPokeballsToSnipe; public int MinPokeballsWhileSnipe; public int MinDelayBetweenSnipes; public double SnipingScanOffset; public bool SnipeAtPokestops; public bool SnipeIgnoreUnknownIv; public bool UseTransferIvForSnipe; public bool SnipePokemonNotInPokedex; public bool UsePokemonSniperFilterOnly; CAPTURE TRANSFER //transfer public bool TransferWeakPokemon; public bool TransferDuplicatePokemon; public bool TransferDuplicatePokemonOnCapture; //keeping public int KeepMinCp; public float KeepMinIvPercentage; public int KeepMinLvl; public string KeepMinOperator; public bool UseKeepMinLvl; public bool PrioritizeIvOverCp; public int KeepMinDuplicatePokemon; */ internal GlobalSettings GetGlobalSettingsObject() { GlobalSettings gs = new GlobalSettings(); // BASIC gs.TranslationLanguageCode = TranslationLanguageCode; gs.AutoUpdate = AutoUpdate; gs.TransferConfigAndAuthOnUpdate = TransferConfigAndAuthOnUpdate; gs.DisableHumanWalking = DisableHumanWalking; gs.DefaultLatitude = DefaultLatitude; gs.DefaultLongitude = DefaultLongitude; gs.MaxTravelDistanceInMeters = MaxTravelDistanceInMeters; gs.WalkingSpeedInKilometerPerHour = WalkingSpeedInKilometerPerHour; gs.MaxSpawnLocationOffset = MaxSpawnLocationOffset; gs.DelayBetweenPlayerActions = DelayBetweenPlayerActions; gs.DelayBetweenPokemonCatch = DelayBetweenPokemonCatch; // AUTH gs.Auth.AuthType = AuthType; gs.Auth.GoogleUsername = GoogleUsername; gs.Auth.GooglePassword = GooglePassword; gs.Auth.PtcUsername = PtcUsername; gs.Auth.PtcPassword = PtcPassword; gs.Auth.UseProxy = UseProxy; gs.Auth.UseProxyHost = UseProxyHost; gs.Auth.UseProxyPort = UseProxyPort; gs.Auth.UseProxyAuthentication = UseProxyAuthentication; gs.Auth.UseProxyUsername = UseProxyUsername; gs.Auth.UseProxyPassword = UseProxyPassword; // DEVICE gs.Auth.DevicePackageName = DevicePackageName; gs.Auth.DeviceId = DeviceId; gs.Auth.AndroidBoardName = AndroidBoardName; gs.Auth.AndroidBootloader = AndroidBootloader; gs.Auth.DeviceBrand = DeviceBrand; gs.Auth.DeviceModel = DeviceModel; gs.Auth.DeviceModelIdentifier = DeviceModelIdentifier; gs.Auth.DeviceModelBoot = DeviceModelBoot; gs.Auth.HardwareManufacturer = HardwareManufacturer; gs.Auth.HardwareModel = HardwareModel; gs.Auth.FirmwareBrand = FirmwareBrand; gs.Auth.FirmwareTags = FirmwareTags; gs.Auth.FirmwareType = FirmwareType; gs.Auth.FirmwareFingerprint = FirmwareFingerprint; // INVENTORY gs.VerboseRecycling = VerboseRecycling; gs.RecycleInventoryAtUsagePercentage = RecycleInventoryAtUsagePercentage; gs.TotalAmountOfPokeballsToKeep = TotalAmountOfPokeballsToKeep; gs.TotalAmountOfPotionsToKeep = TotalAmountOfPotionsToKeep; gs.TotalAmountOfRevivesToKeep = TotalAmountOfRevivesToKeep; gs.TotalAmountOfBerriesToKeep = TotalAmountOfBerriesToKeep; gs.UseEggIncubators = UseEggIncubators; gs.UseLuckyEggConstantly = UseLuckyEggConstantly; gs.UseLuckyEggsMinPokemonAmount = UseLuckyEggsMinPokemonAmount; gs.UseLuckyEggsWhileEvolving = UseLuckyEggsWhileEvolving; gs.UseIncenseConstantly = UseIncenseConstantly; // POKEMON gs.RenamePokemon = RenamePokemon; gs.RenameOnlyAboveIv = RenameOnlyAboveIv; gs.RenameTemplate = RenameTemplate; gs.AutomaticallyLevelUpPokemon = AutomaticallyLevelUpPokemon; gs.AmountOfTimesToUpgradeLoop = AmountOfTimesToUpgradeLoop; gs.GetMinStarDustForLevelUp = GetMinStarDustForLevelUp; gs.LevelUpByCPorIv = LevelUpByCPorIv; gs.UpgradePokemonCpMinimum = UpgradePokemonCpMinimum; gs.UpgradePokemonIvMinimum = UpgradePokemonIvMinimum; gs.UpgradePokemonMinimumStatsOperator = UpgradePokemonMinimumStatsOperator; gs.EvolveAboveIvValue = EvolveAboveIvValue; gs.EvolveAllPokemonAboveIv = EvolveAllPokemonAboveIv; gs.EvolveAllPokemonWithEnoughCandy = EvolveAllPokemonWithEnoughCandy; gs.EvolveKeptPokemonsAtStorageUsagePercentage = EvolveKeptPokemonsAtStorageUsagePercentage; gs.KeepPokemonsThatCanEvolve = KeepPokemonsThatCanEvolve; gs.AutoFavoritePokemon = AutoFavoritePokemon; gs.FavoriteMinIvPercentage = FavoriteMinIvPercentage; // CAPTURE gs.CatchPokemon = CatchPokemon; gs.UsePokemonToNotCatchFilter = UsePokemonToNotCatchFilter; gs.MaxPokeballsPerPokemon = MaxPokeballsPerPokemon; gs.MaxBerriesToUsePerPokemon = MaxBerriesToUsePerPokemon; gs.UseGreatBallAboveCp = UseGreatBallAboveCp; gs.UseUltraBallAboveCp = UseUltraBallAboveCp; gs.UseMasterBallAboveCp = UseMasterBallAboveCp; gs.UseGreatBallAboveIv = UseGreatBallAboveIv; gs.UseUltraBallAboveIv = UseUltraBallAboveIv; gs.UseGreatBallBelowCatchProbability = UseGreatBallBelowCatchProbability; gs.UseUltraBallBelowCatchProbability = UseUltraBallBelowCatchProbability; gs.UseMasterBallBelowCatchProbability = UseMasterBallBelowCatchProbability; gs.UseBerriesMinCp = UseBerriesMinCp; gs.UseBerriesMinIv = UseBerriesMinIv; gs.UseBerriesBelowCatchProbability = UseBerriesBelowCatchProbability; gs.UseBerriesOperator = UseBerriesOperator; gs.EnableHumanizedThrows = EnableHumanizedThrows; gs.NiceThrowChance = NiceThrowChance; gs.GreatThrowChance = GreatThrowChance; gs.ExcellentThrowChance = ExcellentThrowChance; gs.CurveThrowChance = CurveThrowChance; gs.ForceGreatThrowOverIv = ForceGreatThrowOverIv; gs.ForceExcellentThrowOverIv = ForceExcellentThrowOverIv; gs.ForceGreatThrowOverCp = ForceGreatThrowOverCp; gs.ForceExcellentThrowOverCp = ForceExcellentThrowOverCp; // TRANSFER // SNIPING // MISC return gs; }
private static void SetupAccountType(GlobalSettings settings) { string strInput; Logger.Write("### Setting up new USER ACCOUNT ###", LogLevel.None); Logger.Write("Please choose an account type: google/ptc"); while (true) { strInput = Console.ReadLine().ToLower(); switch (strInput) { case "google": settings.Auth.AuthType = AuthType.Google; Logger.Write("Chosen Account Type: GOOGLE"); return; case "ptc": settings.Auth.AuthType = AuthType.Ptc; Logger.Write("Chosen Account Type: PTC"); return; default: Logger.Write("[ERROR] submitted an incorrect account type, please choose 'google' or 'ptc'", LogLevel.Error); break; } } }
public static GlobalSettings Load(string path) { GlobalSettings settings; var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); //personal stuff bool blOverWriteSettings = false; if (File.Exists(srSettingsDirectory + "overwrite.txt")) { blOverWriteSettings = true; } if (File.Exists(srSettingsDirectory + "upgrade.txt")) { blUpgrade_Usefull_Pokemon = true; } //personal stuff if (File.Exists(srSettingsDirectory + "predefined_pokestop_locs.txt")) { lstPokeStopLocations = File.ReadAllLines(srSettingsDirectory + "predefined_pokestop_locs.txt").ToList(); } //personal stuff if (File.Exists(srSettingsDirectory + "auths.txt")) { foreach (var vrLine in File.ReadLines(srSettingsDirectory + "auths.txt")) { List<string> lstParams = vrLine.Split(';').ToList(); string srAuth = "{{" + Environment.NewLine + " \"AuthType\": \"google\"," + Environment.NewLine + " \"GoogleRefreshToken\": null," + Environment.NewLine + " \"PtcUsername\": null," + Environment.NewLine + " \"PtcPassword\": null," + Environment.NewLine + " \"GoogleUsername\": \"{0}\"," + Environment.NewLine + " \"GooglePassword\": \"{1}\"" + Environment.NewLine + " }}"; string srTempAuth = string.Format(srAuth, lstParams[1], lstParams[2]); string srPath = @"D:\74 pokemon go\hesap botlar\{0}\Config\auth.json"; File.WriteAllText(string.Format(srPath, lstParams[0]), srTempAuth); } } if (File.Exists(configFile) && blOverWriteSettings == false) { try { //if the file exists, load the settings var input = File.ReadAllText(configFile); var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject<GlobalSettings>(input, jsonSettings); // One day we might be able to better do this so its automatic /* FieldInfo[] fi = typeof(GlobalSettings).GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo info in fi) { if (info.GetValue(Default) is int || info.GetValue(Default) is bool || info.GetValue(Default) is float) { } if (info.GetValue(Default) is double) { Logger.Write($"{info.Name}={info.GetValue(Default)}", LogLevel.Error); Type type = settings.GetType(); PropertyInfo propertyInfo = type.GetProperty(info.Name, BindingFlags.Instance | BindingFlags.Public); propertyInfo.SetValue(settings, info.GetValue(Default)); } } */ } catch (JsonReaderException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return null; } } else { settings = new GlobalSettings(); } if (settings.DefaultAltitude == 0) { settings.DefaultAltitude = Default.DefaultAltitude; } if (settings.DefaultLatitude == 0) { settings.DefaultLatitude = Default.DefaultLatitude; } if (settings.DefaultLongitude == 0) { settings.DefaultLongitude = Default.DefaultLongitude; } if (settings.WebSocketPort == 0) { settings.WebSocketPort = 14251; } if (settings.PokemonToSnipe == null) { settings.PokemonToSnipe = Default.PokemonToSnipe; } if (settings.RenameTemplate == null) { settings.RenameTemplate = Default.RenameTemplate; } if (settings.SnipeLocationServer == null) { settings.SnipeLocationServer = Default.SnipeLocationServer; } if (settings.SnipingScanOffset <= 0) { settings.SnipingScanOffset = Default.SnipingScanOffset; } if (settings.RecycleInventoryAtUsagePercentage <= 0) { settings.RecycleInventoryAtUsagePercentage = Default.RecycleInventoryAtUsagePercentage; } if (settings.WalkingSpeedInKilometerPerHour <= 0) { settings.WalkingSpeedInKilometerPerHour = Default.WalkingSpeedInKilometerPerHour; } if (settings.EvolveKeptPokemonsAtStorageUsagePercentage <= 0) { settings.EvolveKeptPokemonsAtStorageUsagePercentage = Default.EvolveKeptPokemonsAtStorageUsagePercentage; } if (settings.UseGreatBallBelowCatchProbability < 0) { settings.UseGreatBallBelowCatchProbability = Default.UseGreatBallBelowCatchProbability; } if (settings.UseUltraBallBelowCatchProbability < 0) { settings.UseUltraBallBelowCatchProbability = Default.UseUltraBallBelowCatchProbability; } if (settings.UseMasterBallBelowCatchProbability < 0) { settings.UseMasterBallBelowCatchProbability = Default.UseMasterBallBelowCatchProbability; } if (settings.UseBerriesMinCp < 0) { settings.UseBerriesMinCp = Default.UseBerriesMinCp; } if (settings.UseBerriesMinIv < 0) { settings.UseBerriesMinIv = Default.UseBerriesMinIv; } if (settings.UseBerriesOperator == null || (!settings.UseBerriesOperator.ToLower().Equals("and") && !settings.UseBerriesOperator.ToLower().Equals("or"))) { settings.UseBerriesOperator = Default.UseBerriesOperator; } settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); var firstRun = !File.Exists(configFile); settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); if (firstRun && blOverWriteSettings == false) { return null; } return firstRun ? null : settings; }
private static void SetupSettings(GlobalSettings settings) { SetupAccountType(settings); SetupUserAccount(settings); SetupConfig(settings); Logger.Write("### COMPLETED SETUP ###", LogLevel.None); }
public static ObservableSettings CreateFromGlobalSettings(GlobalSettings set) { ObservableSettings res = new ObservableSettings(); // BASIC res.TranslationLanguageCode = set.TranslationLanguageCode; res.AutoUpdate = set.AutoUpdate; res.TransferConfigAndAuthOnUpdate = set.TransferConfigAndAuthOnUpdate; res.StartupWelcomeDelay = set.StartupWelcomeDelay; res.DisableHumanWalking = set.DisableHumanWalking; res.DefaultLatitude = set.DefaultLatitude; res.DefaultLongitude = set.DefaultLongitude; res.MaxTravelDistanceInMeters = set.MaxTravelDistanceInMeters; res.WalkingSpeedInKilometerPerHour = set.WalkingSpeedInKilometerPerHour; res.MaxSpawnLocationOffset = set.MaxSpawnLocationOffset; res.DelayBetweenPlayerActions = set.DelayBetweenPlayerActions; res.DelayBetweenPokemonCatch = set.DelayBetweenPokemonCatch; // AUTH res.AuthType = set.Auth.AuthType; res.GoogleUsername = set.Auth.GoogleUsername; res.GooglePassword = set.Auth.GooglePassword; res.PtcUsername = set.Auth.PtcUsername; res.PtcPassword = set.Auth.PtcPassword; res.UseProxy = set.Auth.UseProxy; res.UseProxyHost = set.Auth.UseProxyHost; res.UseProxyPort = set.Auth.UseProxyPort; res.UseProxyAuthentication = set.Auth.UseProxyAuthentication; res.UseProxyUsername = set.Auth.UseProxyUsername; res.UseProxyPassword = set.Auth.UseProxyPassword; // DEVICE res.DevicePackageName = set.Auth.DevicePackageName; res.DeviceId = set.Auth.DeviceId; res.AndroidBoardName = set.Auth.AndroidBoardName; res.AndroidBootloader = set.Auth.AndroidBootloader; res.DeviceBrand = set.Auth.DeviceBrand; res.DeviceModel = set.Auth.DeviceModel; res.DeviceModelIdentifier = set.Auth.DeviceModelIdentifier; res.DeviceModelBoot = set.Auth.DeviceModelBoot; res.HardwareManufacturer = set.Auth.HardwareManufacturer; res.HardwareModel = set.Auth.HardwareModel; res.FirmwareBrand = set.Auth.FirmwareBrand; res.FirmwareTags = set.Auth.FirmwareTags; res.FirmwareType = set.Auth.FirmwareType; res.FirmwareFingerprint = set.Auth.FirmwareFingerprint; // INVENTORY res.VerboseRecycling = set.VerboseRecycling; res.RecycleInventoryAtUsagePercentage = set.RecycleInventoryAtUsagePercentage; res.TotalAmountOfPokeballsToKeep = set.TotalAmountOfPokeballsToKeep; res.TotalAmountOfPotionsToKeep = set.TotalAmountOfPotionsToKeep; res.TotalAmountOfRevivesToKeep = set.TotalAmountOfRevivesToKeep; res.TotalAmountOfBerriesToKeep = set.TotalAmountOfBerriesToKeep; res.UseEggIncubators = set.UseEggIncubators; res.UseLuckyEggConstantly = set.UseLuckyEggConstantly; res.UseLuckyEggsMinPokemonAmount = set.UseLuckyEggsMinPokemonAmount; res.UseLuckyEggsWhileEvolving = set.UseLuckyEggsWhileEvolving; res.UseIncenseConstantly = set.UseIncenseConstantly; // POKEMON res.RenamePokemon = set.RenamePokemon; res.RenameOnlyAboveIv = set.RenameOnlyAboveIv; res.RenameTemplate = set.RenameTemplate; res.AutomaticallyLevelUpPokemon = set.AutomaticallyLevelUpPokemon; res.OnlyUpgradeFavorites = set.OnlyUpgradeFavorites; res.AmountOfTimesToUpgradeLoop = set.AmountOfTimesToUpgradeLoop; res.GetMinStarDustForLevelUp = set.GetMinStarDustForLevelUp; res.LevelUpByCPorIv = set.LevelUpByCPorIv; res.UpgradePokemonCpMinimum = set.UpgradePokemonCpMinimum; res.UpgradePokemonIvMinimum = set.UpgradePokemonIvMinimum; res.UpgradePokemonMinimumStatsOperator = set.UpgradePokemonMinimumStatsOperator; res.EvolveAboveIvValue = set.EvolveAboveIvValue; res.EvolveAllPokemonAboveIv = set.EvolveAllPokemonAboveIv; res.EvolveAllPokemonWithEnoughCandy = set.EvolveAllPokemonWithEnoughCandy; res.EvolveKeptPokemonsAtStorageUsagePercentage = set.EvolveKeptPokemonsAtStorageUsagePercentage; res.KeepPokemonsThatCanEvolve = set.KeepPokemonsThatCanEvolve; res.AutoFavoritePokemon = set.AutoFavoritePokemon; res.FavoriteMinIvPercentage = set.FavoriteMinIvPercentage; // CAPTURE res.CatchPokemon = set.CatchPokemon; res.UsePokemonToNotCatchFilter = set.UsePokemonToNotCatchFilter; res.MaxPokeballsPerPokemon = set.MaxPokeballsPerPokemon; res.MaxBerriesToUsePerPokemon = set.MaxBerriesToUsePerPokemon; res.UseGreatBallAboveCp = set.UseGreatBallAboveCp; res.UseUltraBallAboveCp = set.UseUltraBallAboveCp; res.UseMasterBallAboveCp = set.UseMasterBallAboveCp; res.UseGreatBallAboveIv = set.UseGreatBallAboveIv; res.UseUltraBallAboveIv = set.UseUltraBallAboveIv; res.UseGreatBallBelowCatchProbability = set.UseGreatBallBelowCatchProbability; res.UseUltraBallBelowCatchProbability = set.UseUltraBallBelowCatchProbability; res.UseMasterBallBelowCatchProbability = set.UseMasterBallBelowCatchProbability; res.UseBerriesMinCp = set.UseBerriesMinCp; res.UseBerriesMinIv = set.UseBerriesMinIv; res.UseBerriesBelowCatchProbability = set.UseBerriesBelowCatchProbability; res.UseBerriesOperator = set.UseBerriesOperator; res.EnableHumanizedThrows = set.EnableHumanizedThrows; res.NiceThrowChance = set.NiceThrowChance; res.GreatThrowChance = set.GreatThrowChance; res.ExcellentThrowChance = set.ExcellentThrowChance; res.CurveThrowChance = set.CurveThrowChance; res.ForceGreatThrowOverIv = set.ForceGreatThrowOverIv; res.ForceExcellentThrowOverIv = set.ForceExcellentThrowOverIv; res.ForceGreatThrowOverCp = set.ForceGreatThrowOverCp; res.ForceExcellentThrowOverCp = set.ForceExcellentThrowOverCp; // TRANSFER res.TransferWeakPokemon = set.TransferWeakPokemon; res.TransferDuplicatePokemon = set.TransferDuplicatePokemon; res.TransferDuplicatePokemonOnCapture = set.TransferDuplicatePokemonOnCapture; res.KeepMinCp = set.KeepMinCp; res.KeepMinIvPercentage = set.KeepMinIvPercentage; res.KeepMinLvl = set.KeepMinLvl; res.KeepMinOperator = set.KeepMinOperator; res.UseKeepMinLevel = set.UseKeepMinLvl; res.PrioritizeIvOverCp = set.PrioritizeIvOverCp; res.KeepMinDuplicatePokemon = set.KeepMinDuplicatePokemon; // SNIPING res.UseSnipeLocationServer = set.UseSnipeLocationServer; res.SnipeLocationServer = set.SnipeLocationServer; res.SnipeLocationServerPort = set.SnipeLocationServerPort; res.GetSniperInfoFromPokezz = set.GetSniperInfoFromPokezz; res.GetOnlyVerifiedSniperInfoFromPokezz = set.GetOnlyVerifiedSniperInfoFromPokezz; res.GetSniperInfoFromPokeSnipers = set.GetSniperInfoFromPokeSnipers; res.GetSniperInfoFromPokeWatchers = set.GetSniperInfoFromPokeWatchers; res.GetSniperInfoFromSkiplagged = set.GetSniperInfoFromSkiplagged; res.MinPokeballsToSnipe = set.MinPokeballsToSnipe; res.MinPokeballsWhileSnipe = set.MinPokeballsWhileSnipe; res.MinDelayBetweenSnipes = set.MinDelayBetweenSnipes; res.SnipingScanOffset = set.SnipingScanOffset; res.SnipeAtPokestops = set.SnipeAtPokestops; res.SnipeIgnoreUnknownIv = set.SnipeIgnoreUnknownIv; res.UseTransferIvForSnipe = set.UseTransferIvForSnipe; res.SnipePokemonNotInPokedex = set.SnipePokemonNotInPokedex; // MISC res.FastSoftBanBypass = set.FastSoftBanBypass; res.UseGpxPathing = set.UseGpxPathing; res.GpxFile = set.GpxFile; res.UseWebsocket = set.UseWebsocket; res.WebSocketPort = set.WebSocketPort; res.UseTelegramAPI = set.UseTelegramAPI; res.TelegramAPIKey = set.TelegramAPIKey; res.TelegramPassword = set.TelegramPassword; res.AmountOfPokemonToDisplayOnStart = set.AmountOfPokemonToDisplayOnStart; res.DetailedCountsBeforeRecycling = set.DetailedCountsBeforeRecycling; res.DumpPokemonStats = set.DumpPokemonStats; // OBJECTS & ITERATORS res.PokemonToSnipe = set.PokemonToSnipe; foreach (PokemonId pid in Enum.GetValues(typeof(PokemonId))) { res.NoTransferCollection.Add(new PokemonToggle(pid, (null != set.PokemonsNotToTransfer && set.PokemonsNotToTransfer.Contains(pid)) )); res.EvolveCollection.Add( new PokemonToggle(pid, (null != set.PokemonsToEvolve && set.PokemonsToEvolve.Contains(pid)) )); res.UpgradeCollection.Add( new PokemonToggle(pid, (null != set.PokemonsToLevelUp && set.PokemonsToLevelUp.Contains(pid)) )); res.IgnoreCollection.Add( new PokemonToggle(pid, (null != set.PokemonsToIgnore && set.PokemonsToIgnore.Contains(pid)) )); res.MasterballCollection.Add(new PokemonToggle(pid, (null != set.PokemonToUseMasterball && set.PokemonToUseMasterball.Contains(pid)) )); } foreach (PokemonId key in set.PokemonsTransferFilter.Keys) res.PokemonsTransferFilter.Add(key, set.PokemonsTransferFilter[key]); foreach (KeyValuePair<ItemId, int> kvp in set.ItemRecycleFilter) res.ItemRecycleFilter.Add(kvp); res.LoadCurrentCoords(); return res; }
public static GlobalSettings Load(string path, bool boolSkipSave = false) { GlobalSettings settings = null; bool isGui = (AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.FullName.Contains("PoGo.NecroBot.GUI")) != null); var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); var shouldExit = false; if (File.Exists(configFile)) { try { //if the file exists, load the settings string input = ""; int count = 0; while (true) { try { input = File.ReadAllText(configFile); if (!input.Contains("DeprecatedMoves")) input = input.Replace("\"Moves\"", $"\"DeprecatedMoves\""); break; } catch (Exception exception) { if (count > 10) { //sometimes we have to wait close to config.json for access Logger.Write("configFile: " + exception.Message, LogLevel.Error); } count++; Thread.Sleep(1000); } }; var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; try { settings = JsonConvert.DeserializeObject<GlobalSettings>(input, jsonSettings); } catch (Newtonsoft.Json.JsonSerializationException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return null; } //This makes sure that existing config files dont get null values which lead to an exception foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.KeepMinOperator == null)) { filter.Value.KeepMinOperator = "or"; } foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.Moves == null)) { filter.Value.Moves = (filter.Value.DeprecatedMoves != null) ? new List<List<PokemonMove>> { filter.Value.DeprecatedMoves } : filter.Value.Moves ?? new List<List<PokemonMove>>(); } foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.MovesOperator == null)) { filter.Value.MovesOperator = "or"; } } catch (JsonReaderException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return null; } } else { settings = new GlobalSettings(); shouldExit = true; } settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); settings.isGui = isGui; if ( !boolSkipSave || !settings.CheckForUpdates || !settings.AutoUpdate ) { settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); } return shouldExit ? null : settings; }
internal GlobalSettings GetGlobalSettingsObject() { GlobalSettings gs = new GlobalSettings(); // BASIC gs.TranslationLanguageCode = TranslationLanguageCode; gs.AutoUpdate = AutoUpdate; gs.TransferConfigAndAuthOnUpdate = TransferConfigAndAuthOnUpdate; gs.StartupWelcomeDelay = StartupWelcomeDelay; gs.DisableHumanWalking = DisableHumanWalking; gs.DefaultLatitude = DefaultLatitude; gs.DefaultLongitude = DefaultLongitude; gs.MaxTravelDistanceInMeters = MaxTravelDistanceInMeters; gs.WalkingSpeedInKilometerPerHour = WalkingSpeedInKilometerPerHour; gs.MaxSpawnLocationOffset = MaxSpawnLocationOffset; gs.DelayBetweenPlayerActions = DelayBetweenPlayerActions; gs.DelayBetweenPokemonCatch = DelayBetweenPokemonCatch; // AUTH gs.Auth.AuthType = AuthType; gs.Auth.GoogleUsername = GoogleUsername; gs.Auth.GooglePassword = GooglePassword; gs.Auth.PtcUsername = PtcUsername; gs.Auth.PtcPassword = PtcPassword; gs.Auth.UseProxy = UseProxy; gs.Auth.UseProxyHost = UseProxyHost; gs.Auth.UseProxyPort = UseProxyPort; gs.Auth.UseProxyAuthentication = UseProxyAuthentication; gs.Auth.UseProxyUsername = UseProxyUsername; gs.Auth.UseProxyPassword = UseProxyPassword; // DEVICE gs.Auth.DevicePackageName = DevicePackageName; gs.Auth.DeviceId = DeviceId; gs.Auth.AndroidBoardName = AndroidBoardName; gs.Auth.AndroidBootloader = AndroidBootloader; gs.Auth.DeviceBrand = DeviceBrand; gs.Auth.DeviceModel = DeviceModel; gs.Auth.DeviceModelIdentifier = DeviceModelIdentifier; gs.Auth.DeviceModelBoot = DeviceModelBoot; gs.Auth.HardwareManufacturer = HardwareManufacturer; gs.Auth.HardwareModel = HardwareModel; gs.Auth.FirmwareBrand = FirmwareBrand; gs.Auth.FirmwareTags = FirmwareTags; gs.Auth.FirmwareType = FirmwareType; gs.Auth.FirmwareFingerprint = FirmwareFingerprint; // INVENTORY gs.VerboseRecycling = VerboseRecycling; gs.RecycleInventoryAtUsagePercentage = RecycleInventoryAtUsagePercentage; gs.TotalAmountOfPokeballsToKeep = TotalAmountOfPokeballsToKeep; gs.TotalAmountOfPotionsToKeep = TotalAmountOfPotionsToKeep; gs.TotalAmountOfRevivesToKeep = TotalAmountOfRevivesToKeep; gs.TotalAmountOfBerriesToKeep = TotalAmountOfBerriesToKeep; gs.UseEggIncubators = UseEggIncubators; gs.UseLuckyEggConstantly = UseLuckyEggConstantly; gs.UseLuckyEggsMinPokemonAmount = UseLuckyEggsMinPokemonAmount; gs.UseLuckyEggsWhileEvolving = UseLuckyEggsWhileEvolving; gs.UseIncenseConstantly = UseIncenseConstantly; // POKEMON gs.RenamePokemon = RenamePokemon; gs.RenameOnlyAboveIv = RenameOnlyAboveIv; gs.RenameTemplate = RenameTemplate; gs.AutomaticallyLevelUpPokemon = AutomaticallyLevelUpPokemon; gs.OnlyUpgradeFavorites = OnlyUpgradeFavorites; gs.AmountOfTimesToUpgradeLoop = AmountOfTimesToUpgradeLoop; gs.GetMinStarDustForLevelUp = GetMinStarDustForLevelUp; gs.LevelUpByCPorIv = LevelUpByCPorIv; gs.UpgradePokemonCpMinimum = UpgradePokemonCpMinimum; gs.UpgradePokemonIvMinimum = UpgradePokemonIvMinimum; gs.UpgradePokemonMinimumStatsOperator = UpgradePokemonMinimumStatsOperator; gs.EvolveAboveIvValue = EvolveAboveIvValue; gs.EvolveAllPokemonAboveIv = EvolveAllPokemonAboveIv; gs.EvolveAllPokemonWithEnoughCandy = EvolveAllPokemonWithEnoughCandy; gs.EvolveKeptPokemonsAtStorageUsagePercentage = EvolveKeptPokemonsAtStorageUsagePercentage; gs.KeepPokemonsThatCanEvolve = KeepPokemonsThatCanEvolve; gs.AutoFavoritePokemon = AutoFavoritePokemon; gs.FavoriteMinIvPercentage = FavoriteMinIvPercentage; // CAPTURE gs.CatchPokemon = CatchPokemon; gs.UsePokemonToNotCatchFilter = UsePokemonToNotCatchFilter; gs.MaxPokeballsPerPokemon = MaxPokeballsPerPokemon; gs.MaxBerriesToUsePerPokemon = MaxBerriesToUsePerPokemon; gs.UseGreatBallAboveCp = UseGreatBallAboveCp; gs.UseUltraBallAboveCp = UseUltraBallAboveCp; gs.UseMasterBallAboveCp = UseMasterBallAboveCp; gs.UseGreatBallAboveIv = UseGreatBallAboveIv; gs.UseUltraBallAboveIv = UseUltraBallAboveIv; gs.UseGreatBallBelowCatchProbability = UseGreatBallBelowCatchProbability; gs.UseUltraBallBelowCatchProbability = UseUltraBallBelowCatchProbability; gs.UseMasterBallBelowCatchProbability = UseMasterBallBelowCatchProbability; gs.UseBerriesMinCp = UseBerriesMinCp; gs.UseBerriesMinIv = UseBerriesMinIv; gs.UseBerriesBelowCatchProbability = UseBerriesBelowCatchProbability; gs.UseBerriesOperator = UseBerriesOperator; gs.EnableHumanizedThrows = EnableHumanizedThrows; gs.NiceThrowChance = NiceThrowChance; gs.GreatThrowChance = GreatThrowChance; gs.ExcellentThrowChance = ExcellentThrowChance; gs.CurveThrowChance = CurveThrowChance; gs.ForceGreatThrowOverIv = ForceGreatThrowOverIv; gs.ForceExcellentThrowOverIv = ForceExcellentThrowOverIv; gs.ForceGreatThrowOverCp = ForceGreatThrowOverCp; gs.ForceExcellentThrowOverCp = ForceExcellentThrowOverCp; // TRANSFER gs.TransferWeakPokemon = TransferWeakPokemon; gs.TransferDuplicatePokemon = TransferDuplicatePokemon; gs.TransferDuplicatePokemonOnCapture = TransferDuplicatePokemonOnCapture; gs.KeepMinCp = KeepMinCp; gs.KeepMinIvPercentage = KeepMinIvPercentage; gs.KeepMinLvl = KeepMinLvl; gs.KeepMinOperator = KeepMinOperator; gs.UseKeepMinLvl = UseKeepMinLevel; gs.PrioritizeIvOverCp = PrioritizeIvOverCp; gs.KeepMinDuplicatePokemon = KeepMinDuplicatePokemon; // SNIPING gs.UseSnipeLocationServer = UseSnipeLocationServer; gs.SnipeLocationServer = SnipeLocationServer; gs.SnipeLocationServerPort = SnipeLocationServerPort; gs.GetSniperInfoFromPokezz = GetSniperInfoFromPokezz; gs.GetOnlyVerifiedSniperInfoFromPokezz = GetOnlyVerifiedSniperInfoFromPokezz; gs.GetSniperInfoFromPokeSnipers = GetSniperInfoFromPokeSnipers; gs.GetSniperInfoFromPokeWatchers = GetSniperInfoFromPokeWatchers; gs.GetSniperInfoFromSkiplagged = GetSniperInfoFromSkiplagged; gs.MinPokeballsToSnipe = MinPokeballsToSnipe; gs.MinPokeballsWhileSnipe = MinPokeballsWhileSnipe; gs.MinDelayBetweenSnipes = MinDelayBetweenSnipes; gs.SnipingScanOffset = SnipingScanOffset; gs.SnipeAtPokestops = SnipeAtPokestops; gs.SnipeIgnoreUnknownIv = SnipeIgnoreUnknownIv; gs.UseTransferIvForSnipe = UseTransferIvForSnipe; gs.SnipePokemonNotInPokedex = SnipePokemonNotInPokedex; // MISC gs.FastSoftBanBypass = FastSoftBanBypass; gs.UseGpxPathing = UseGpxPathing; gs.GpxFile = GpxFile; gs.UseWebsocket = UseWebsocket; gs.WebSocketPort = WebSocketPort; gs.UseTelegramAPI = UseTelegramAPI; gs.TelegramAPIKey = TelegramAPIKey; gs.TelegramPassword = TelegramPassword; gs.AmountOfPokemonToDisplayOnStart = AmountOfPokemonToDisplayOnStart; gs.DetailedCountsBeforeRecycling = DetailedCountsBeforeRecycling; gs.DumpPokemonStats = DumpPokemonStats; // OBJECTS & ITERATORS gs.PokemonToSnipe = PokemonToSnipe; gs.PokemonsNotToTransfer.Clear(); foreach (PokemonToggle pt in NoTransferCollection) if (pt.IsChecked) gs.PokemonsNotToTransfer.Add(pt.Id); gs.PokemonsToEvolve.Clear(); foreach (PokemonToggle pt in EvolveCollection) if (pt.IsChecked) gs.PokemonsToEvolve.Add(pt.Id); gs.PokemonsToLevelUp.Clear(); foreach (PokemonToggle pt in UpgradeCollection) if (pt.IsChecked) gs.PokemonsToLevelUp.Add(pt.Id); gs.PokemonsToIgnore.Clear(); foreach (PokemonToggle pt in IgnoreCollection) if (pt.IsChecked) gs.PokemonsToIgnore.Add(pt.Id); gs.PokemonToUseMasterball.Clear(); foreach (PokemonToggle pt in MasterballCollection) if (pt.IsChecked) gs.PokemonToUseMasterball.Add(pt.Id); gs.PokemonsTransferFilter.Clear(); foreach (PokemonId key in PokemonsTransferFilter.Keys) gs.PokemonsTransferFilter.Add(key, PokemonsTransferFilter[key]); foreach (KeyValuePair<ItemId, int> kvp in ItemRecycleFilter) gs.ItemRecycleFilter.Add(kvp); SaveCurrentCoords(); return gs; }
private static void SaveFiles(GlobalSettings settings, String configFile) { settings.Save(configFile); settings.Auth.Load(Path.Combine(settings.ProfileConfigPath, "auth.json")); }
public static GlobalSettings Load(string path) { GlobalSettings settings; var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); if( File.Exists( configFile ) ) { try { //if the file exists, load the settings var input = File.ReadAllText( configFile ); var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add( new StringEnumConverter { CamelCaseText = true } ); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject<GlobalSettings>( input, jsonSettings ); //This makes sure that existing config files dont get null values which lead to an exception foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.KeepMinOperator == null)) { filter.Value.KeepMinOperator = "or"; } foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.Moves == null)) { filter.Value.Moves = new List<PokemonMove>(); } } catch( JsonReaderException exception ) { Logger.Write( "JSON Exception: " + exception.Message, LogLevel.Error ); return null; } } else settings = new GlobalSettings(); settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); var firstRun = !File.Exists(configFile); settings.migratePercentages(); settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); return firstRun ? null : settings; }
private static void SetupConfig(ITranslation translator, GlobalSettings settings) { Logger.Write(translator.GetTranslation(TranslationString.FirstStartDefaultLocationPrompt, "Y", "N"), LogLevel.None); bool boolBreak = false; while (!boolBreak) { string strInput = Console.ReadLine().ToLower(); switch (strInput) { case "y": boolBreak = true; break; case "n": Logger.Write(translator.GetTranslation(TranslationString.FirstStartDefaultLocationSet)); return; default: // PROMPT ERROR \\ Logger.Write(translator.GetTranslation(TranslationString.PromptError, "y", "n"), LogLevel.Error); continue; } } Logger.Write(translator.GetTranslation(TranslationString.FirstStartDefaultLocation), LogLevel.None); Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLatLongPrompt)); while (true) { try { string strInput = Console.ReadLine(); string[] strSplit = strInput.Split( ',' ); if( strSplit.Length > 1 ) { double dblLat = double.Parse( strSplit[ 0 ].Trim( ' ' ) ); double dblLong = double.Parse( strSplit[ 1 ].Trim( ' ' ) ); settings.DefaultLatitude = dblLat; settings.DefaultLongitude = dblLong; Logger.Write( translator.GetTranslation( TranslationString.FirstStartSetupDefaultLatLongConfirm, $"{dblLat}, {dblLong}" ) ); } else { Logger.Write( translator.GetTranslation( TranslationString.FirstStartSetupDefaultLocationError, $"{settings.DefaultLatitude}, {settings.DefaultLongitude}", LogLevel.Error ) ); continue; } break; } catch (FormatException) { Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLocationError, $"{settings.DefaultLatitude}, {settings.DefaultLongitude}", LogLevel.Error)); continue; } } }
private static void SetupConfig(ITranslation translator, GlobalSettings settings) { Logger.Write(translator.GetTranslation(TranslationString.FirstStartDefaultLocationPrompt, "Y", "N"), LogLevel.None); bool boolBreak = false; while (!boolBreak) { string strInput = Console.ReadLine().ToLower(); switch (strInput) { case "y": boolBreak = true; break; case "n": Logger.Write(translator.GetTranslation(TranslationString.FirstStartDefaultLocationSet)); return; default: // PROMPT ERROR \\ Logger.Write(translator.GetTranslation(TranslationString.PromptError, "y", "n"), LogLevel.Error); continue; } } Logger.Write(translator.GetTranslation(TranslationString.FirstStartDefaultLocation), LogLevel.None); Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLatPrompt)); while (true) { try { double dblInput = double.Parse(Console.ReadLine()); settings.DefaultLatitude = dblInput; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLatConfirm, dblInput)); break; } catch (FormatException) { Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLocationError, settings.DefaultLatitude, LogLevel.Error)); continue; } } Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLongPrompt)); while (true) { try { double dblInput = double.Parse(Console.ReadLine()); settings.DefaultLongitude = dblInput; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLongConfirm, dblInput)); break; } catch (FormatException) { Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupDefaultLocationError, settings.DefaultLongitude, LogLevel.Error)); continue; } } }
private static void SetupUserAccount(ITranslation translator, GlobalSettings settings) { Console.WriteLine(""); Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupUsernamePrompt), LogLevel.None); string strInput = Console.ReadLine(); if (settings.Auth.AuthType == AuthType.Google) settings.Auth.GoogleUsername = strInput; else settings.Auth.PtcUsername = strInput; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupUsernameConfirm, strInput)); Console.WriteLine(""); Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupPasswordPrompt), LogLevel.None); strInput = Console.ReadLine(); if (settings.Auth.AuthType == AuthType.Google) settings.Auth.GooglePassword = strInput; else settings.Auth.PtcPassword = strInput; Logger.Write(translator.GetTranslation(TranslationString.FirstStartSetupPasswordConfirm, strInput)); Logger.Write(translator.GetTranslation(TranslationString.FirstStartAccountCompleted), LogLevel.None); }
public static GlobalSettings Load(string path) { GlobalSettings settings; var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); if (File.Exists(configFile)) { try { //if the file exists, load the settings var input = File.ReadAllText(configFile); var jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new StringEnumConverter {CamelCaseText = true}); jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace; jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject<GlobalSettings>(input, jsonSettings); // One day we might be able to better do this so its automatic /* FieldInfo[] fi = typeof(GlobalSettings).GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo info in fi) { if (info.GetValue(Default) is int || info.GetValue(Default) is bool || info.GetValue(Default) is float) { } if (info.GetValue(Default) is double) { Logger.Write($"{info.Name}={info.GetValue(Default)}", LogLevel.Error); Type type = settings.GetType(); PropertyInfo propertyInfo = type.GetProperty(info.Name, BindingFlags.Instance | BindingFlags.Public); propertyInfo.SetValue(settings, info.GetValue(Default)); } } */ } catch (JsonReaderException exception) { Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); return null; } } else { settings = new GlobalSettings(); } if (settings.DefaultAltitude == 0) { settings.DefaultAltitude = Default.DefaultAltitude; } if (settings.DefaultLatitude == 0) { settings.DefaultLatitude = Default.DefaultLatitude; } if (settings.DefaultLongitude == 0) { settings.DefaultLongitude = Default.DefaultLongitude; } if (settings.WebSocketPort == 0) { settings.WebSocketPort = 14251; } if (settings.PokemonToSnipe == null) { settings.PokemonToSnipe = Default.PokemonToSnipe; } if (settings.RenameTemplate == null) { settings.RenameTemplate = Default.RenameTemplate; } if (settings.SnipeLocationServer == null) { settings.SnipeLocationServer = Default.SnipeLocationServer; } if (settings.SnipingScanOffset <= 0) { settings.SnipingScanOffset = Default.SnipingScanOffset; } if (settings.RecycleInventoryAtUsagePercentage <= 0) { settings.RecycleInventoryAtUsagePercentage = Default.RecycleInventoryAtUsagePercentage; } if (settings.WalkingSpeedInKilometerPerHour <= 0) { settings.WalkingSpeedInKilometerPerHour = Default.WalkingSpeedInKilometerPerHour; } if (settings.EvolveKeptPokemonsAtStorageUsagePercentage <= 0) { settings.EvolveKeptPokemonsAtStorageUsagePercentage = Default.EvolveKeptPokemonsAtStorageUsagePercentage; } settings.ProfilePath = profilePath; settings.ProfileConfigPath = profileConfigPath; settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); var firstRun = !File.Exists(configFile); settings.Save(configFile); settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); return firstRun ? null : settings; }
public ClientSettings(GlobalSettings settings) { _settings = settings; }
public void StartBot() { string strCulture = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; var culture = CultureInfo.CreateSpecificCulture("en"); CultureInfo.DefaultThreadCurrentCulture = culture; Thread.CurrentThread.CurrentCulture = culture; AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEventHandler; var profilePath = Path.Combine(Directory.GetCurrentDirectory(), subPath); var profileConfigPath = Path.Combine(profilePath, "config"); var configFile = Path.Combine(profileConfigPath, "config.json"); PoGo.NecroBot.Logic.GlobalSettings Einstellungen = new PoGo.NecroBot.Logic.GlobalSettings(); List <KeyValuePair <int, string> > PokemonTranslationStrings = Uebersetzer._PokemonNameToId; pokemonNameToId["missingno"] = "001"; foreach (var pokemon in PokemonTranslationStrings) { string pomoName = pokemon.Key.ToString(); string idC = ""; if (pomoName.Length == 1) { idC = "00" + pomoName; } if (pomoName.Length == 2) { idC = "0" + pomoName; } if (pomoName.Length == 3) { idC = pomoName; } pokemonNameToId[pokemon.Value.ToString()] = idC; } if (File.Exists(configFile)) { Einstellungen = GlobalSettings.Load(subPath); } else { return; } session = new Session(new ClientSettings(Einstellungen), new LogicSettings(Einstellungen)); session.Client.ApiFailure = new ApiFailureStrategy(session); var stats = new Statistics(); stats.DirtyEvent += () => { isLoaded = true; this.GraphicalInterface.updateData(stats.getNickname().ToString(), stats.getLevel().ToString(), stats.getNeedXp(), stats.getTotalXp(), stats.getStardust().ToString(), Math.Round((stats.GetRuntime() * 60), 3).ToString()); }; var aggregator = new StatisticsAggregator(stats); var machine = new StateMachine(); session.EventDispatcher.EventReceived += evt => Informations.Listen(evt, session); session.EventDispatcher.EventReceived += evt => aggregator.Listen(evt, session); machine.SetFailureState(new LoginState()); session.Navigation.UpdatePositionEvent += (lat, lng) => session.EventDispatcher.Send(new UpdatePositionEvent { Latitude = lat, Longitude = lng }); session.Navigation.UpdatePositionEvent += Navigation_UpdatePositionEvent; machine.AsyncStart(new VersionCheckState(), session, subPath); pokemonDisplay = new getPokemonDisplayed(session); Einstellungen.checkProxy(session.Translation); }