From fc089e034ff29eab4610ef2add10dffd534e8d3a Mon Sep 17 00:00:00 2001 From: simplyphp Date: Thu, 4 Aug 2016 17:50:14 -0500 Subject: [PATCH 1/2] Code cleanup --- PoGo.NecroBot.CLI/App.config | 25 +- PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj | 3 +- PoGo.NecroBot.Logic/Logging/Logger.cs | 19 +- PoGo.NecroBot.Logic/Navigation.cs | 7 - .../PoGo.NecroBot.Logic.csproj | 3 +- PoGo.NecroBot.Logic/Settings.cs | 1359 +++++++++-------- PoGo.NecroBot.Logic/State/FarmState.cs | 3 - .../Tasks/FavoritePokemonTask.cs | 1 - .../Tasks/InventoryListTask.cs | 3 - .../Tasks/LevelUpPokemonTask.cs | 3 - .../Tasks/TransferDuplicatePokemonTask.cs | 2 - .../Tasks/TransferPokemonTask.cs | 5 - PoGo.NecroBot.Logic/Utils/Statistics.cs | 1 - PoGo.NecroBot.Logic/app.config | 13 +- 14 files changed, 718 insertions(+), 729 deletions(-) diff --git a/PoGo.NecroBot.CLI/App.config b/PoGo.NecroBot.CLI/App.config index 3679eb6cd..758b35441 100644 --- a/PoGo.NecroBot.CLI/App.config +++ b/PoGo.NecroBot.CLI/App.config @@ -1,32 +1,31 @@ - - + -
-
+
+
- + - - + + - - + + - - + + - + - \ No newline at end of file + diff --git a/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj b/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj index f1744dfa3..7399d3d9e 100644 --- a/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj +++ b/PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj @@ -9,10 +9,11 @@ Properties PoGo.NecroBot.CLI NecroBot - v4.5 + v4.5.2 512 + AnyCPU diff --git a/PoGo.NecroBot.Logic/Logging/Logger.cs b/PoGo.NecroBot.Logic/Logging/Logger.cs index 47e7779f5..7b405dd00 100644 --- a/PoGo.NecroBot.Logic/Logging/Logger.cs +++ b/PoGo.NecroBot.Logic/Logging/Logger.cs @@ -16,6 +16,7 @@ public static class Logger private static DateTime _lastLogTime; private static readonly IList LogbufferList = new List(); private static string _lastLogMessage; + private static bool _isGui; private static void Log(string message, bool force = false) { @@ -49,12 +50,16 @@ private static void Log(string message, bool force = false) /// unset. /// /// - public static void SetLogger(ILogger logger, string subPath = "") + public static void SetLogger(ILogger logger, string subPath = "", bool isGui = false) { _logger = logger; - _path = Path.Combine(Directory.GetCurrentDirectory(), subPath, "Logs"); - Directory.CreateDirectory(_path); - Log($"Initializing NecroBot logger at time {DateTime.Now}..."); + _isGui = isGui; + if (!_isGui) + { + _path = Path.Combine(Directory.GetCurrentDirectory(), subPath, "Logs"); + Directory.CreateDirectory(_path); + Log($"Initializing NecroBot logger at time {DateTime.Now}..."); + } } /// @@ -74,11 +79,13 @@ public static void SetLoggerContext(ISession session) /// Optional. Default is automatic color. public static void Write(string message, LogLevel level = LogLevel.Info, ConsoleColor color = ConsoleColor.Black, bool force = false) { - if (_logger == null || _lastLogMessage == message ) + if (_logger == null || _lastLogMessage == message) return; _lastLogMessage = message; _logger.Write(message, level, color); - Log(string.Concat($"[{DateTime.Now.ToString("HH:mm:ss")}] ", message), force); + + if (!_isGui) + Log(string.Concat($"[{DateTime.Now.ToString("HH:mm:ss")}] ", message), force); } } diff --git a/PoGo.NecroBot.Logic/Navigation.cs b/PoGo.NecroBot.Logic/Navigation.cs index cb360710a..dff259daf 100644 --- a/PoGo.NecroBot.Logic/Navigation.cs +++ b/PoGo.NecroBot.Logic/Navigation.cs @@ -1,7 +1,5 @@ #region using directives -#region using directives - using System; using System.Globalization; using System.Threading; @@ -10,11 +8,6 @@ using PoGo.NecroBot.Logic.Utils; using PokemonGo.RocketAPI; using POGOProtos.Networking.Responses; -using System.Linq; - -#endregion - -// ReSharper disable RedundantAssignment #endregion diff --git a/PoGo.NecroBot.Logic/PoGo.NecroBot.Logic.csproj b/PoGo.NecroBot.Logic/PoGo.NecroBot.Logic.csproj index a9e584bf6..745973fed 100644 --- a/PoGo.NecroBot.Logic/PoGo.NecroBot.Logic.csproj +++ b/PoGo.NecroBot.Logic/PoGo.NecroBot.Logic.csproj @@ -9,8 +9,9 @@ Properties PoGo.NecroBot.Logic PoGo.NecroBot.Logic - v4.5 + v4.5.2 512 + true diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index 2138f3b14..e5812ae98 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -18,306 +18,307 @@ namespace PoGo.NecroBot.Logic { - internal class AuthSettings - { - [JsonIgnore] - private string _filePath; - - public AuthType AuthType; - public string GoogleUsername; - public string GooglePassword; - public string PtcUsername; - public string PtcPassword; - - public void Load(string path) + internal class AuthSettings { - try - { - _filePath = path; + [JsonIgnore] + private string _filePath; - if (File.Exists(_filePath)) - { - //if the file exists, load the settings - var input = File.ReadAllText(_filePath); - - var settings = new JsonSerializerSettings(); - settings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); + public AuthType AuthType; + public string GoogleUsername; + public string GooglePassword; + public string PtcUsername; + public string PtcPassword; - JsonConvert.PopulateObject(input, this, settings); - } - else + public void Load(string path) { - Save(_filePath); + try + { + _filePath = path; + + if (File.Exists(_filePath)) + { + //if the file exists, load the settings + var input = File.ReadAllText(_filePath); + + var settings = new JsonSerializerSettings(); + settings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); + + JsonConvert.PopulateObject(input, this, settings); + } + else + { + Save(_filePath); + } + } + catch (JsonReaderException exception) + { + if (exception.Message.Contains("Unexpected character") && exception.Message.Contains("PtcUsername")) + Logger.Write("JSON Exception: You need to properly configure your PtcUsername using quotations.", + LogLevel.Error); + else if (exception.Message.Contains("Unexpected character") && exception.Message.Contains("PtcPassword")) + Logger.Write( + "JSON Exception: You need to properly configure your PtcPassword using quotations.", + LogLevel.Error); + else if (exception.Message.Contains("Unexpected character") && + exception.Message.Contains("GoogleUsername")) + Logger.Write( + "JSON Exception: You need to properly configure your GoogleUsername using quotations.", + LogLevel.Error); + else if (exception.Message.Contains("Unexpected character") && + exception.Message.Contains("GooglePassword")) + Logger.Write( + "JSON Exception: You need to properly configure your GooglePassword using quotations.", + LogLevel.Error); + else + Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); + } } - } - catch (JsonReaderException exception) - { - if (exception.Message.Contains("Unexpected character") && exception.Message.Contains("PtcUsername")) - Logger.Write("JSON Exception: You need to properly configure your PtcUsername using quotations.", - LogLevel.Error); - else if (exception.Message.Contains("Unexpected character") && exception.Message.Contains("PtcPassword")) - Logger.Write( - "JSON Exception: You need to properly configure your PtcPassword using quotations.", - LogLevel.Error); - else if (exception.Message.Contains("Unexpected character") && - exception.Message.Contains("GoogleUsername")) - Logger.Write( - "JSON Exception: You need to properly configure your GoogleUsername using quotations.", - LogLevel.Error); - else if (exception.Message.Contains("Unexpected character") && - exception.Message.Contains("GooglePassword")) - Logger.Write( - "JSON Exception: You need to properly configure your GooglePassword using quotations.", - LogLevel.Error); - else - Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error); - } - } - public void Save(string path) - { - var output = JsonConvert.SerializeObject(this, Formatting.Indented, - new StringEnumConverter { CamelCaseText = true }); + public void Save(string path) + { + var output = JsonConvert.SerializeObject(this, Formatting.Indented, + new StringEnumConverter { CamelCaseText = true }); + + var folder = Path.GetDirectoryName(path); + if (folder != null && !Directory.Exists(folder)) + { + Directory.CreateDirectory(folder); + } - var folder = Path.GetDirectoryName(path); - if (folder != null && !Directory.Exists(folder)) - { - Directory.CreateDirectory(folder); - } + File.WriteAllText(path, output); + } - File.WriteAllText(path, output); + public void Save() + { + if (!string.IsNullOrEmpty(_filePath)) + { + Save(_filePath); + } + } } - public void Save() + public class GlobalSettings { - if (!string.IsNullOrEmpty(_filePath)) - { - Save(_filePath); - } - } - } - - public class GlobalSettings - { - - [JsonIgnore] - internal AuthSettings Auth = new AuthSettings(); - [JsonIgnore] - public string GeneralConfigPath; - [JsonIgnore] - public string ProfileConfigPath; - [JsonIgnore] - public string ProfilePath; - - [DefaultValue("en")] - public string TranslationLanguageCode; - //autoupdate - [DefaultValue(true)] - public bool AutoUpdate; - [DefaultValue(true)] - public bool TransferConfigAndAuthOnUpdate; - //pressakeyshit - [DefaultValue(false)] - public bool StartupWelcomeDelay; - //console options - [DefaultValue(10)] - public int AmountOfPokemonToDisplayOnStart; - [DefaultValue(true)] - public bool ShowPokeballCountsBeforeRecycle; - //powerup - [DefaultValue(false)] - public bool AutomaticallyLevelUpPokemon; - [DefaultValue(5)] - public int AmountOfTimesToUpgradeLoop; - [DefaultValue(5000)] - public int GetMinStarDustForLevelUp; - [DefaultValue("iv")] - public string LevelUpByCPorIv; - [DefaultValue(1000)] - public float UpgradePokemonCpMinimum; - [DefaultValue(95)] - public float UpgradePokemonIvMinimum; - [DefaultValue("and")] - public string UpgradePokemonMinimumStatsOperator; - //position - [DefaultValue(false)] - public bool DisableHumanWalking; - [DefaultValue(10)] - public double DefaultAltitude; - [DefaultValue(40.778915)] - public double DefaultLatitude; - [DefaultValue(-73.962277)] - public double DefaultLongitude; - [DefaultValue(31.0)] - public double WalkingSpeedInKilometerPerHour; - [DefaultValue(10)] - public int MaxSpawnLocationOffset; - //delays - [DefaultValue(5000)] - public int DelayBetweenPlayerActions; - [DefaultValue(2000)] - public int DelayBetweenPokemonCatch; - //dump stats - [DefaultValue(false)] - public bool DumpPokemonStats; - //evolve - [DefaultValue(95)] - public float EvolveAboveIvValue; - [DefaultValue(false)] - public bool EvolveAllPokemonAboveIv; - [DefaultValue(true)] - public bool EvolveAllPokemonWithEnoughCandy; - [DefaultValue(90.0)] - public double EvolveKeptPokemonsAtStorageUsagePercentage; - [DefaultValue(false)] - public bool KeepPokemonsThatCanEvolve; - //keeping - [DefaultValue(1250)] - public int KeepMinCp; - [DefaultValue(90)] - public float KeepMinIvPercentage; - [DefaultValue(6)] - public int KeepMinLvl; - [DefaultValue("or")] - public string KeepMinOperator; - [DefaultValue(false)] - public bool UseKeepMinLvl; - [DefaultValue(false)] - public bool PrioritizeIvOverCp; - [DefaultValue(1)] - public int KeepMinDuplicatePokemon; - //gpx - [DefaultValue(false)] - public bool UseGpxPathing; - [DefaultValue("GPXPath.GPX")] - public string GpxFile; - //recycle - [DefaultValue(true)] - public bool VerboseRecycling; - [DefaultValue(90.0)] - public double RecycleInventoryAtUsagePercentage; - //lucky, incense and berries - [DefaultValue(true)] - public bool UseEggIncubators; - [DefaultValue(false)] - public bool UseLuckyEggConstantly; - [DefaultValue(30)] - public int UseLuckyEggsMinPokemonAmount; - [DefaultValue(false)] - public bool UseLuckyEggsWhileEvolving; - [DefaultValue(false)] - public bool UseIncenseConstantly; - [DefaultValue(1000)] - public int UseBerriesMinCp; - [DefaultValue(90)] - public float UseBerriesMinIv; - [DefaultValue(0.20)] - public double UseBerriesBelowCatchProbability; - [DefaultValue("and")] - public string UseBerriesOperator; - //snipe - [DefaultValue(true)] - public bool UseSnipeOnlineLocationServer; - [DefaultValue(false)] - public bool UseSnipeLocationServer; - [DefaultValue("localhost")] - public string SnipeLocationServer; - [DefaultValue(16969)] - public int SnipeLocationServerPort; - [DefaultValue(true)] - public bool GetSniperInfoFromPokezz; - [DefaultValue(true)] - public bool GetOnlyVerifiedSniperInfoFromPokezz; - [DefaultValue(20)] - public int MinPokeballsToSnipe; - [DefaultValue(0)] - public int MinPokeballsWhileSnipe; - [DefaultValue(60000)] - public int MinDelayBetweenSnipes; - [DefaultValue(0.003)] - public double SnipingScanOffset; - [DefaultValue(false)] - public bool SnipeAtPokestops; - [DefaultValue(false)] - public bool SnipeIgnoreUnknownIv; - [DefaultValue(false)] - public bool UseTransferIvForSnipe; - //rename - [DefaultValue(false)] - public bool RenamePokemon; - [DefaultValue(true)] - public bool RenameOnlyAboveIv; - [DefaultValue("{1}_{0}")] - public string RenameTemplate; - //amounts - [DefaultValue(6)] - public int MaxPokeballsPerPokemon; - [DefaultValue(1000)] - public int MaxTravelDistanceInMeters; - [DefaultValue(120)] - public int TotalAmountOfPokeballsToKeep; - [DefaultValue(80)] - public int TotalAmountOfPotionsToKeep; - [DefaultValue(60)] - public int TotalAmountOfRevivesToKeep; - [DefaultValue(50)] - public int TotalAmountOfBerriesToKeep; - //balls - [DefaultValue(1000)] - public int UseGreatBallAboveCp; - [DefaultValue(1250)] - public int UseUltraBallAboveCp; - [DefaultValue(1500)] - public int UseMasterBallAboveCp; - [DefaultValue(85.0)] - public double UseGreatBallAboveIv; - [DefaultValue(95.0)] - public double UseUltraBallAboveIv; - [DefaultValue(0.2)] - public double UseGreatBallBelowCatchProbability; - [DefaultValue(0.1)] - public double UseUltraBallBelowCatchProbability; - [DefaultValue(0.05)] - public double UseMasterBallBelowCatchProbability; - //customizable catch - [DefaultValue(false)] - public bool EnableHumanizedThrows; - [DefaultValue(40)] - public int NiceThrowChance; - [DefaultValue(30)] - public int GreatThrowChance; - [DefaultValue(10)] - public int ExcellentThrowChance; - [DefaultValue(90)] - public int CurveThrowChance; - [DefaultValue(90.00)] - public double ForceGreatThrowOverIv; - [DefaultValue(95.00)] - public double ForceExcellentThrowOverIv; - [DefaultValue(1000)] - public int ForceGreatThrowOverCp; - [DefaultValue(1500)] - public int ForceExcellentThrowOverCp; - //transfer - [DefaultValue(false)] - public bool TransferWeakPokemon; - [DefaultValue(true)] - public bool TransferDuplicatePokemon; - [DefaultValue(true)] - public bool TransferDuplicatePokemonOnCapture; - //favorite - [DefaultValue(95)] - public float FavoriteMinIvPercentage; - [DefaultValue(false)] - public bool AutoFavoritePokemon; - //notcatch - [DefaultValue(false)] - public bool UsePokemonToNotCatchFilter; - [DefaultValue(false)] - public bool UsePokemonSniperFilterOnly; - [DefaultValue(14251)] - public int WebSocketPort; - public List> ItemRecycleFilter = new List> + [JsonIgnore] + internal AuthSettings Auth = new AuthSettings(); + [JsonIgnore] + public string GeneralConfigPath; + [JsonIgnore] + public string ProfileConfigPath; + [JsonIgnore] + public string ProfilePath; + [JsonIgnore] + public bool isGui; + + [DefaultValue("en")] + public string TranslationLanguageCode; + //autoupdate + [DefaultValue(true)] + public bool AutoUpdate; + [DefaultValue(true)] + public bool TransferConfigAndAuthOnUpdate; + //pressakeyshit + [DefaultValue(false)] + public bool StartupWelcomeDelay; + //console options + [DefaultValue(10)] + public int AmountOfPokemonToDisplayOnStart; + [DefaultValue(true)] + public bool ShowPokeballCountsBeforeRecycle; + //powerup + [DefaultValue(false)] + public bool AutomaticallyLevelUpPokemon; + [DefaultValue(5)] + public int AmountOfTimesToUpgradeLoop; + [DefaultValue(5000)] + public int GetMinStarDustForLevelUp; + [DefaultValue("iv")] + public string LevelUpByCPorIv; + [DefaultValue(1000)] + public float UpgradePokemonCpMinimum; + [DefaultValue(95)] + public float UpgradePokemonIvMinimum; + [DefaultValue("and")] + public string UpgradePokemonMinimumStatsOperator; + //position + [DefaultValue(false)] + public bool DisableHumanWalking; + [DefaultValue(10)] + public double DefaultAltitude; + [DefaultValue(40.778915)] + public double DefaultLatitude; + [DefaultValue(-73.962277)] + public double DefaultLongitude; + [DefaultValue(31.0)] + public double WalkingSpeedInKilometerPerHour; + [DefaultValue(10)] + public int MaxSpawnLocationOffset; + //delays + [DefaultValue(5000)] + public int DelayBetweenPlayerActions; + [DefaultValue(2000)] + public int DelayBetweenPokemonCatch; + //dump stats + [DefaultValue(false)] + public bool DumpPokemonStats; + //evolve + [DefaultValue(95)] + public float EvolveAboveIvValue; + [DefaultValue(false)] + public bool EvolveAllPokemonAboveIv; + [DefaultValue(true)] + public bool EvolveAllPokemonWithEnoughCandy; + [DefaultValue(90.0)] + public double EvolveKeptPokemonsAtStorageUsagePercentage; + [DefaultValue(false)] + public bool KeepPokemonsThatCanEvolve; + //keeping + [DefaultValue(1250)] + public int KeepMinCp; + [DefaultValue(90)] + public float KeepMinIvPercentage; + [DefaultValue(6)] + public int KeepMinLvl; + [DefaultValue("or")] + public string KeepMinOperator; + [DefaultValue(false)] + public bool UseKeepMinLvl; + [DefaultValue(false)] + public bool PrioritizeIvOverCp; + [DefaultValue(1)] + public int KeepMinDuplicatePokemon; + //gpx + [DefaultValue(false)] + public bool UseGpxPathing; + [DefaultValue("GPXPath.GPX")] + public string GpxFile; + //recycle + [DefaultValue(true)] + public bool VerboseRecycling; + [DefaultValue(90.0)] + public double RecycleInventoryAtUsagePercentage; + //lucky, incense and berries + [DefaultValue(true)] + public bool UseEggIncubators; + [DefaultValue(false)] + public bool UseLuckyEggConstantly; + [DefaultValue(30)] + public int UseLuckyEggsMinPokemonAmount; + [DefaultValue(false)] + public bool UseLuckyEggsWhileEvolving; + [DefaultValue(false)] + public bool UseIncenseConstantly; + [DefaultValue(1000)] + public int UseBerriesMinCp; + [DefaultValue(90)] + public float UseBerriesMinIv; + [DefaultValue(0.20)] + public double UseBerriesBelowCatchProbability; + [DefaultValue("and")] + public string UseBerriesOperator; + //snipe + [DefaultValue(true)] + public bool UseSnipeOnlineLocationServer; + [DefaultValue(false)] + public bool UseSnipeLocationServer; + [DefaultValue("localhost")] + public string SnipeLocationServer; + [DefaultValue(16969)] + public int SnipeLocationServerPort; + [DefaultValue(true)] + public bool GetSniperInfoFromPokezz; + [DefaultValue(true)] + public bool GetOnlyVerifiedSniperInfoFromPokezz; + [DefaultValue(20)] + public int MinPokeballsToSnipe; + [DefaultValue(0)] + public int MinPokeballsWhileSnipe; + [DefaultValue(60000)] + public int MinDelayBetweenSnipes; + [DefaultValue(0.003)] + public double SnipingScanOffset; + [DefaultValue(false)] + public bool SnipeAtPokestops; + [DefaultValue(false)] + public bool SnipeIgnoreUnknownIv; + [DefaultValue(false)] + public bool UseTransferIvForSnipe; + //rename + [DefaultValue(false)] + public bool RenamePokemon; + [DefaultValue(true)] + public bool RenameOnlyAboveIv; + [DefaultValue("{1}_{0}")] + public string RenameTemplate; + //amounts + [DefaultValue(6)] + public int MaxPokeballsPerPokemon; + [DefaultValue(1000)] + public int MaxTravelDistanceInMeters; + [DefaultValue(120)] + public int TotalAmountOfPokeballsToKeep; + [DefaultValue(80)] + public int TotalAmountOfPotionsToKeep; + [DefaultValue(60)] + public int TotalAmountOfRevivesToKeep; + [DefaultValue(50)] + public int TotalAmountOfBerriesToKeep; + //balls + [DefaultValue(1000)] + public int UseGreatBallAboveCp; + [DefaultValue(1250)] + public int UseUltraBallAboveCp; + [DefaultValue(1500)] + public int UseMasterBallAboveCp; + [DefaultValue(85.0)] + public double UseGreatBallAboveIv; + [DefaultValue(95.0)] + public double UseUltraBallAboveIv; + [DefaultValue(0.2)] + public double UseGreatBallBelowCatchProbability; + [DefaultValue(0.1)] + public double UseUltraBallBelowCatchProbability; + [DefaultValue(0.05)] + public double UseMasterBallBelowCatchProbability; + //customizable catch + [DefaultValue(false)] + public bool EnableHumanizedThrows; + [DefaultValue(40)] + public int NiceThrowChance; + [DefaultValue(30)] + public int GreatThrowChance; + [DefaultValue(10)] + public int ExcellentThrowChance; + [DefaultValue(90)] + public int CurveThrowChance; + [DefaultValue(90.00)] + public double ForceGreatThrowOverIv; + [DefaultValue(95.00)] + public double ForceExcellentThrowOverIv; + [DefaultValue(1000)] + public int ForceGreatThrowOverCp; + [DefaultValue(1500)] + public int ForceExcellentThrowOverCp; + //transfer + [DefaultValue(false)] + public bool TransferWeakPokemon; + [DefaultValue(true)] + public bool TransferDuplicatePokemon; + [DefaultValue(true)] + public bool TransferDuplicatePokemonOnCapture; + //favorite + [DefaultValue(95)] + public float FavoriteMinIvPercentage; + [DefaultValue(false)] + public bool AutoFavoritePokemon; + //notcatch + [DefaultValue(false)] + public bool UsePokemonToNotCatchFilter; + [DefaultValue(false)] + public bool UsePokemonSniperFilterOnly; + [DefaultValue(14251)] + public int WebSocketPort; + public List> ItemRecycleFilter = new List> { new KeyValuePair(ItemId.ItemUnknown, 0), new KeyValuePair(ItemId.ItemLuckyEgg, 200), @@ -336,7 +337,7 @@ public class GlobalSettings new KeyValuePair(ItemId.ItemItemStorageUpgrade, 100) }; - public List PokemonsNotToTransfer = new List + public List PokemonsNotToTransfer = new List { //criteria: from SS Tier to A Tier + Regional Exclusive PokemonId.Venusaur, @@ -377,7 +378,7 @@ public class GlobalSettings PokemonId.Mew }; - public List PokemonsToEvolve = new List + public List PokemonsToEvolve = new List { /*NOTE: keep all the end-of-line commas exept for the last one or an exception will be thrown! criteria: 12 candies*/ @@ -416,7 +417,7 @@ public class GlobalSettings //PokemonId.Staryu }; - public List PokemonsToIgnore = new List + public List PokemonsToIgnore = new List { //criteria: most common PokemonId.Caterpie, @@ -428,7 +429,7 @@ public class GlobalSettings PokemonId.Doduo }; - public Dictionary PokemonsTransferFilter = new Dictionary + public Dictionary PokemonsTransferFilter = new Dictionary { //criteria: based on NY Central Park and Tokyo variety + sniping optimization {PokemonId.Golduck, new TransferFilter(1800, 6, false, 95, "or", 1)}, @@ -456,16 +457,16 @@ public class GlobalSettings {PokemonId.Dragonite, new TransferFilter(2600, 6, false, 90, "or", 1)} }; - public SnipeSettings PokemonToSnipe = new SnipeSettings - { - Locations = new List + public SnipeSettings PokemonToSnipe = new SnipeSettings + { + Locations = new List { new Location(38.55680748646112, -121.2383794784546), //Dratini Spot new Location(-33.85901900, 151.21309800), //Magikarp Spot new Location(47.5014969, -122.0959568), //Eevee Spot new Location(51.5025343, -0.2055027) //Charmender Spot }, - Pokemon = new List + Pokemon = new List { PokemonId.Venusaur, PokemonId.Charizard, @@ -522,9 +523,9 @@ public class GlobalSettings PokemonId.Mewtwo, PokemonId.Mew } - }; + }; - public List PokemonToUseMasterball = new List + public List PokemonToUseMasterball = new List { PokemonId.Articuno, PokemonId.Zapdos, @@ -533,434 +534,440 @@ public class GlobalSettings PokemonId.Mewtwo }; - public GlobalSettings() - { - InitializePropertyDefaultValues(this); - } - - public void InitializePropertyDefaultValues(object obj) - { - FieldInfo[] fields = obj.GetType().GetFields(); - - foreach (FieldInfo field in fields) - { - var d = field.GetCustomAttribute(); - - if (d != null) - field.SetValue(obj, d.Value); - } - } - - public static GlobalSettings Default => new GlobalSettings(); - - 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 + public GlobalSettings() { - //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(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(); - } + InitializePropertyDefaultValues(this); } - catch (JsonReaderException exception) + + public void InitializePropertyDefaultValues(object obj) { - 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); + FieldInfo[] fields = obj.GetType().GetFields(); - bool boolBreak = false; - settings = new GlobalSettings(); + foreach (FieldInfo field in fields) + { + var d = field.GetCustomAttribute(); - 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; - } + if (d != null) + field.SetValue(obj, d.Value); + } } - } + public static GlobalSettings Default => new GlobalSettings(); - 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")); + 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(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(); + } + } + 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; + } - return shouldExit ? null : settings; - } + settings.ProfilePath = profilePath; + settings.ProfileConfigPath = profileConfigPath; + settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config"); + settings.isGui = isGui; + settings.migratePercentages(); - private static void SetupSettings(GlobalSettings settings) - { - SetupAccountType(settings); - SetupUserAccount(settings); - SetupConfig(settings); + settings.Save(configFile); + settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json")); - Logger.Write("### COMPLETED SETUP ###", LogLevel.None); - } + return shouldExit ? null : settings; + } - 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"); + private static void SetupSettings(GlobalSettings settings) + { + SetupAccountType(settings); + SetupUserAccount(settings); + SetupConfig(settings); - while (true) - { - strInput = Console.ReadLine().ToLower(); + Logger.Write("### COMPLETED SETUP ###", LogLevel.None); + } - switch (strInput) + private static void SetupAccountType(GlobalSettings settings) { - 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; - } - } - } + string strInput; + Logger.Write("### Setting up new USER ACCOUNT ###", LogLevel.None); + Logger.Write("Please choose an account type: google/ptc"); - 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: " + strInput); - - Console.WriteLine(""); - 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: " + strInput); - - Logger.Write("### User Account Completed ###\n", LogLevel.None); - } + 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; + } + } + } - 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 + private static void SetupUserAccount(GlobalSettings settings) { - double dblInput = double.Parse(Console.ReadLine()); - settings.DefaultLatitude = dblInput; - Logger.Write("Lattitude accepted: " + dblInput); - break; + 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: " + strInput); + + Console.WriteLine(""); + 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: " + strInput); + + Logger.Write("### User Account Completed ###\n", LogLevel.None); } - catch (FormatException) + + private static void SetupConfig(GlobalSettings settings) { - Logger.Write("[ERROR] Please input only a VALUE for example: " + settings.DefaultLatitude, LogLevel.Error); - continue; + 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; + } + } } - } - Logger.Write("Please enter a Longitude (Right click to paste)"); - while (true) - { - try + + /// + /// Method for issue #1966 + /// + private void migratePercentages() { - double dblInput = double.Parse(Console.ReadLine()); - settings.DefaultLongitude = dblInput; - Logger.Write("Longitude accepted: " + dblInput); - break; + if (EvolveKeptPokemonsAtStorageUsagePercentage <= 1.0) + { + EvolveKeptPokemonsAtStorageUsagePercentage *= 100.0f; + } + if (RecycleInventoryAtUsagePercentage <= 1.0) + { + RecycleInventoryAtUsagePercentage *= 100.0f; + } } - catch (FormatException) + + public void Save(string fullPath) { - Logger.Write("[ERROR] Please input only a VALUE for example: " + settings.DefaultLongitude, LogLevel.Error); - continue; - } - } - } + var jsonSerializeSettings = new JsonSerializerSettings + { + DefaultValueHandling = DefaultValueHandling.Include, + Formatting = Formatting.Indented, + Converters = new JsonConverter[] { new StringEnumConverter { CamelCaseText = true } } + }; + var output = JsonConvert.SerializeObject(this, jsonSerializeSettings); - /// - /// Method for issue #1966 - /// - private void migratePercentages() - { - if (EvolveKeptPokemonsAtStorageUsagePercentage <= 1.0) - { - EvolveKeptPokemonsAtStorageUsagePercentage *= 100.0f; - } - if (RecycleInventoryAtUsagePercentage <= 1.0) - { - RecycleInventoryAtUsagePercentage *= 100.0f; - } + var folder = Path.GetDirectoryName(fullPath); + if (folder != null && !Directory.Exists(folder)) + { + Directory.CreateDirectory(folder); + } + + File.WriteAllText(fullPath, output); + } } - public void Save(string fullPath) + public class ClientSettings : ISettings { - var jsonSerializeSettings = new JsonSerializerSettings - { - DefaultValueHandling = DefaultValueHandling.Include, - Formatting = Formatting.Indented, - Converters = new JsonConverter[] { new StringEnumConverter { CamelCaseText = true } } - }; - - var output = JsonConvert.SerializeObject(this, jsonSerializeSettings); - - var folder = Path.GetDirectoryName(fullPath); - if (folder != null && !Directory.Exists(folder)) - { - Directory.CreateDirectory(folder); - } - - File.WriteAllText(fullPath, output); - } - } + // Never spawn at the same position. + private readonly Random _rand = new Random(); + private readonly GlobalSettings _settings; - public class ClientSettings : ISettings - { - // Never spawn at the same position. - private readonly Random _rand = new Random(); - private readonly GlobalSettings _settings; + public ClientSettings(GlobalSettings settings) + { + _settings = settings; + } - public ClientSettings(GlobalSettings settings) - { - _settings = settings; - } + public string GoogleUsername => _settings.Auth.GoogleUsername; + public string GooglePassword => _settings.Auth.GooglePassword; - public string GoogleUsername => _settings.Auth.GoogleUsername; - public string GooglePassword => _settings.Auth.GooglePassword; + public string GoogleRefreshToken + { + get { return null; } + set { GoogleRefreshToken = null; } + } + AuthType ISettings.AuthType + { + get { return _settings.Auth.AuthType; } - public string GoogleRefreshToken - { - get { return null; } - set { GoogleRefreshToken = null; } - } - AuthType ISettings.AuthType - { - get { return _settings.Auth.AuthType; } + set { _settings.Auth.AuthType = value; } + } - set { _settings.Auth.AuthType = value; } - } + double ISettings.DefaultLatitude + { + get + { + return _settings.DefaultLatitude + _rand.NextDouble() * ((double)_settings.MaxSpawnLocationOffset / 111111); + } - double ISettings.DefaultLatitude - { - get - { - return _settings.DefaultLatitude + _rand.NextDouble() * ((double)_settings.MaxSpawnLocationOffset / 111111); - } + set { _settings.DefaultLatitude = value; } + } - set { _settings.DefaultLatitude = value; } - } + double ISettings.DefaultLongitude + { + get + { + return _settings.DefaultLongitude + + _rand.NextDouble() * + ((double)_settings.MaxSpawnLocationOffset / 111111 / Math.Cos(_settings.DefaultLatitude)); + } - double ISettings.DefaultLongitude - { - get - { - return _settings.DefaultLongitude + - _rand.NextDouble() * - ((double)_settings.MaxSpawnLocationOffset / 111111 / Math.Cos(_settings.DefaultLatitude)); - } - - set { _settings.DefaultLongitude = value; } - } + set { _settings.DefaultLongitude = value; } + } - double ISettings.DefaultAltitude - { - get { return _settings.DefaultAltitude; } + double ISettings.DefaultAltitude + { + get { return _settings.DefaultAltitude; } - set { _settings.DefaultAltitude = value; } - } + set { _settings.DefaultAltitude = value; } + } - string ISettings.GoogleUsername - { - get { return _settings.Auth.GoogleUsername; } + string ISettings.GoogleUsername + { + get { return _settings.Auth.GoogleUsername; } - set { _settings.Auth.GoogleUsername = value; } - } + set { _settings.Auth.GoogleUsername = value; } + } - string ISettings.GooglePassword - { - get { return _settings.Auth.GooglePassword; } + string ISettings.GooglePassword + { + get { return _settings.Auth.GooglePassword; } - set { _settings.Auth.GooglePassword = value; } - } + set { _settings.Auth.GooglePassword = value; } + } - string ISettings.PtcUsername - { - get { return _settings.Auth.PtcUsername; } + string ISettings.PtcUsername + { + get { return _settings.Auth.PtcUsername; } - set { _settings.Auth.PtcUsername = value; } - } + set { _settings.Auth.PtcUsername = value; } + } - string ISettings.PtcPassword - { - get { return _settings.Auth.PtcPassword; } + string ISettings.PtcPassword + { + get { return _settings.Auth.PtcPassword; } - set { _settings.Auth.PtcPassword = value; } + set { _settings.Auth.PtcPassword = value; } + } } - } - public class LogicSettings : ILogicSettings - { - private readonly GlobalSettings _settings; - - public LogicSettings(GlobalSettings settings) + public class LogicSettings : ILogicSettings { - _settings = settings; - } + private readonly GlobalSettings _settings; - public string ProfilePath => _settings.ProfilePath; - public string ProfileConfigPath => _settings.ProfileConfigPath; - public string GeneralConfigPath => _settings.GeneralConfigPath; - public bool AutoUpdate => _settings.AutoUpdate; - public bool TransferConfigAndAuthOnUpdate => _settings.TransferConfigAndAuthOnUpdate; - public bool TransferWeakPokemon => _settings.TransferWeakPokemon; - public bool DisableHumanWalking => _settings.DisableHumanWalking; - public float KeepMinIvPercentage => _settings.KeepMinIvPercentage; - public string KeepMinOperator => _settings.KeepMinOperator; - public int KeepMinCp => _settings.KeepMinCp; - public int KeepMinLvl => _settings.KeepMinLvl; - public bool UseKeepMinLvl => _settings.UseKeepMinLvl; - public bool AutomaticallyLevelUpPokemon => _settings.AutomaticallyLevelUpPokemon; - public int AmountOfTimesToUpgradeLoop => _settings.AmountOfTimesToUpgradeLoop; - public string LevelUpByCPorIv => _settings.LevelUpByCPorIv; - public int GetMinStarDustForLevelUp => _settings.GetMinStarDustForLevelUp; - public bool UseLuckyEggConstantly => _settings.UseLuckyEggConstantly; - public bool UseIncenseConstantly => _settings.UseIncenseConstantly; - public int UseBerriesMinCp => _settings.UseBerriesMinCp; - public float UseBerriesMinIv => _settings.UseBerriesMinIv; - public double UseBerriesBelowCatchProbability => _settings.UseBerriesBelowCatchProbability; - public string UseBerriesOperator => _settings.UseBerriesOperator; - public float UpgradePokemonIvMinimum => _settings.UpgradePokemonIvMinimum; - public float UpgradePokemonCpMinimum => _settings.UpgradePokemonCpMinimum; - public string UpgradePokemonMinimumStatsOperator => _settings.UpgradePokemonMinimumStatsOperator; - public double WalkingSpeedInKilometerPerHour => _settings.WalkingSpeedInKilometerPerHour; - public bool EvolveAllPokemonWithEnoughCandy => _settings.EvolveAllPokemonWithEnoughCandy; - public bool KeepPokemonsThatCanEvolve => _settings.KeepPokemonsThatCanEvolve; - public bool TransferDuplicatePokemon => _settings.TransferDuplicatePokemon; - public bool TransferDuplicatePokemonOnCapture => _settings.TransferDuplicatePokemonOnCapture; - public bool UseEggIncubators => _settings.UseEggIncubators; - public int UseGreatBallAboveCp => _settings.UseGreatBallAboveCp; - public int UseUltraBallAboveCp => _settings.UseUltraBallAboveCp; - public int UseMasterBallAboveCp => _settings.UseMasterBallAboveCp; - public double UseGreatBallAboveIv => _settings.UseGreatBallAboveIv; - public double UseUltraBallAboveIv => _settings.UseUltraBallAboveIv; - public double UseMasterBallBelowCatchProbability => _settings.UseMasterBallBelowCatchProbability; - public double UseUltraBallBelowCatchProbability => _settings.UseUltraBallBelowCatchProbability; - public double UseGreatBallBelowCatchProbability => _settings.UseGreatBallBelowCatchProbability; - public bool EnableHumanizedThrows => _settings.EnableHumanizedThrows; - public int NiceThrowChance => _settings.NiceThrowChance; - public int GreatThrowChance => _settings.GreatThrowChance; - public int ExcellentThrowChance => _settings.ExcellentThrowChance; - public int CurveThrowChance => _settings.CurveThrowChance; - public double ForceGreatThrowOverIv => _settings.ForceGreatThrowOverIv; - public double ForceExcellentThrowOverIv => _settings.ForceExcellentThrowOverIv; - public int ForceGreatThrowOverCp => _settings.ForceGreatThrowOverCp; - public int ForceExcellentThrowOverCp => _settings.ForceExcellentThrowOverCp; - public int DelayBetweenPokemonCatch => _settings.DelayBetweenPokemonCatch; - public int DelayBetweenPlayerActions => _settings.DelayBetweenPlayerActions; - public bool UsePokemonToNotCatchFilter => _settings.UsePokemonToNotCatchFilter; - public bool UsePokemonSniperFilterOnly => _settings.UsePokemonSniperFilterOnly; - public int KeepMinDuplicatePokemon => _settings.KeepMinDuplicatePokemon; - public bool PrioritizeIvOverCp => _settings.PrioritizeIvOverCp; - public int MaxTravelDistanceInMeters => _settings.MaxTravelDistanceInMeters; - public string GpxFile => _settings.GpxFile; - public bool UseGpxPathing => _settings.UseGpxPathing; - public bool UseLuckyEggsWhileEvolving => _settings.UseLuckyEggsWhileEvolving; - public int UseLuckyEggsMinPokemonAmount => _settings.UseLuckyEggsMinPokemonAmount; - public bool EvolveAllPokemonAboveIv => _settings.EvolveAllPokemonAboveIv; - public float EvolveAboveIvValue => _settings.EvolveAboveIvValue; - public bool RenamePokemon => _settings.RenamePokemon; - public bool RenameOnlyAboveIv => _settings.RenameOnlyAboveIv; - public float FavoriteMinIvPercentage => _settings.FavoriteMinIvPercentage; - public bool AutoFavoritePokemon => _settings.AutoFavoritePokemon; - public string RenameTemplate => _settings.RenameTemplate; - public int AmountOfPokemonToDisplayOnStart => _settings.AmountOfPokemonToDisplayOnStart; - public bool DumpPokemonStats => _settings.DumpPokemonStats; - public string TranslationLanguageCode => _settings.TranslationLanguageCode; - public bool ShowPokeballCountsBeforeRecycle => _settings.ShowPokeballCountsBeforeRecycle; - public bool VerboseRecycling => _settings.VerboseRecycling; - public double RecycleInventoryAtUsagePercentage => _settings.RecycleInventoryAtUsagePercentage; - public double EvolveKeptPokemonsAtStorageUsagePercentage => _settings.EvolveKeptPokemonsAtStorageUsagePercentage; - public ICollection> ItemRecycleFilter => _settings.ItemRecycleFilter; - public ICollection PokemonsToEvolve => _settings.PokemonsToEvolve; - public ICollection PokemonsNotToTransfer => _settings.PokemonsNotToTransfer; - public ICollection PokemonsNotToCatch => _settings.PokemonsToIgnore; - public ICollection PokemonToUseMasterball => _settings.PokemonToUseMasterball; - public Dictionary PokemonsTransferFilter => _settings.PokemonsTransferFilter; - public bool StartupWelcomeDelay => _settings.StartupWelcomeDelay; - public bool SnipeAtPokestops => _settings.SnipeAtPokestops; - public int MinPokeballsToSnipe => _settings.MinPokeballsToSnipe; - public int MinPokeballsWhileSnipe => _settings.MinPokeballsWhileSnipe; - public int MaxPokeballsPerPokemon => _settings.MaxPokeballsPerPokemon; - - public SnipeSettings PokemonToSnipe => _settings.PokemonToSnipe; - public string SnipeLocationServer => _settings.SnipeLocationServer; - public int SnipeLocationServerPort => _settings.SnipeLocationServerPort; - public bool GetSniperInfoFromPokezz => _settings.GetSniperInfoFromPokezz; - public bool GetOnlyVerifiedSniperInfoFromPokezz => _settings.GetOnlyVerifiedSniperInfoFromPokezz; - public bool UseSnipeLocationServer => _settings.UseSnipeLocationServer; - public bool UseSnipeOnlineLocationServer => _settings.UseSnipeOnlineLocationServer; - public bool UseTransferIvForSnipe => _settings.UseTransferIvForSnipe; - public bool SnipeIgnoreUnknownIv => _settings.SnipeIgnoreUnknownIv; - public int MinDelayBetweenSnipes => _settings.MinDelayBetweenSnipes; - public double SnipingScanOffset => _settings.SnipingScanOffset; - public int TotalAmountOfPokeballsToKeep => _settings.TotalAmountOfPokeballsToKeep; - public int TotalAmountOfPotionsToKeep => _settings.TotalAmountOfPotionsToKeep; - public int TotalAmountOfRevivesToKeep => _settings.TotalAmountOfRevivesToKeep; - public int TotalAmountOfBerriesToKeep => _settings.TotalAmountOfBerriesToKeep; - } + public LogicSettings(GlobalSettings settings) + { + _settings = settings; + } + + public string ProfilePath => _settings.ProfilePath; + public string ProfileConfigPath => _settings.ProfileConfigPath; + public string GeneralConfigPath => _settings.GeneralConfigPath; + public bool AutoUpdate => _settings.AutoUpdate; + public bool TransferConfigAndAuthOnUpdate => _settings.TransferConfigAndAuthOnUpdate; + public bool TransferWeakPokemon => _settings.TransferWeakPokemon; + public bool DisableHumanWalking => _settings.DisableHumanWalking; + public float KeepMinIvPercentage => _settings.KeepMinIvPercentage; + public string KeepMinOperator => _settings.KeepMinOperator; + public int KeepMinCp => _settings.KeepMinCp; + public int KeepMinLvl => _settings.KeepMinLvl; + public bool UseKeepMinLvl => _settings.UseKeepMinLvl; + public bool AutomaticallyLevelUpPokemon => _settings.AutomaticallyLevelUpPokemon; + public int AmountOfTimesToUpgradeLoop => _settings.AmountOfTimesToUpgradeLoop; + public string LevelUpByCPorIv => _settings.LevelUpByCPorIv; + public int GetMinStarDustForLevelUp => _settings.GetMinStarDustForLevelUp; + public bool UseLuckyEggConstantly => _settings.UseLuckyEggConstantly; + public bool UseIncenseConstantly => _settings.UseIncenseConstantly; + public int UseBerriesMinCp => _settings.UseBerriesMinCp; + public float UseBerriesMinIv => _settings.UseBerriesMinIv; + public double UseBerriesBelowCatchProbability => _settings.UseBerriesBelowCatchProbability; + public string UseBerriesOperator => _settings.UseBerriesOperator; + public float UpgradePokemonIvMinimum => _settings.UpgradePokemonIvMinimum; + public float UpgradePokemonCpMinimum => _settings.UpgradePokemonCpMinimum; + public string UpgradePokemonMinimumStatsOperator => _settings.UpgradePokemonMinimumStatsOperator; + public double WalkingSpeedInKilometerPerHour => _settings.WalkingSpeedInKilometerPerHour; + public bool EvolveAllPokemonWithEnoughCandy => _settings.EvolveAllPokemonWithEnoughCandy; + public bool KeepPokemonsThatCanEvolve => _settings.KeepPokemonsThatCanEvolve; + public bool TransferDuplicatePokemon => _settings.TransferDuplicatePokemon; + public bool TransferDuplicatePokemonOnCapture => _settings.TransferDuplicatePokemonOnCapture; + public bool UseEggIncubators => _settings.UseEggIncubators; + public int UseGreatBallAboveCp => _settings.UseGreatBallAboveCp; + public int UseUltraBallAboveCp => _settings.UseUltraBallAboveCp; + public int UseMasterBallAboveCp => _settings.UseMasterBallAboveCp; + public double UseGreatBallAboveIv => _settings.UseGreatBallAboveIv; + public double UseUltraBallAboveIv => _settings.UseUltraBallAboveIv; + public double UseMasterBallBelowCatchProbability => _settings.UseMasterBallBelowCatchProbability; + public double UseUltraBallBelowCatchProbability => _settings.UseUltraBallBelowCatchProbability; + public double UseGreatBallBelowCatchProbability => _settings.UseGreatBallBelowCatchProbability; + public bool EnableHumanizedThrows => _settings.EnableHumanizedThrows; + public int NiceThrowChance => _settings.NiceThrowChance; + public int GreatThrowChance => _settings.GreatThrowChance; + public int ExcellentThrowChance => _settings.ExcellentThrowChance; + public int CurveThrowChance => _settings.CurveThrowChance; + public double ForceGreatThrowOverIv => _settings.ForceGreatThrowOverIv; + public double ForceExcellentThrowOverIv => _settings.ForceExcellentThrowOverIv; + public int ForceGreatThrowOverCp => _settings.ForceGreatThrowOverCp; + public int ForceExcellentThrowOverCp => _settings.ForceExcellentThrowOverCp; + public int DelayBetweenPokemonCatch => _settings.DelayBetweenPokemonCatch; + public int DelayBetweenPlayerActions => _settings.DelayBetweenPlayerActions; + public bool UsePokemonToNotCatchFilter => _settings.UsePokemonToNotCatchFilter; + public bool UsePokemonSniperFilterOnly => _settings.UsePokemonSniperFilterOnly; + public int KeepMinDuplicatePokemon => _settings.KeepMinDuplicatePokemon; + public bool PrioritizeIvOverCp => _settings.PrioritizeIvOverCp; + public int MaxTravelDistanceInMeters => _settings.MaxTravelDistanceInMeters; + public string GpxFile => _settings.GpxFile; + public bool UseGpxPathing => _settings.UseGpxPathing; + public bool UseLuckyEggsWhileEvolving => _settings.UseLuckyEggsWhileEvolving; + public int UseLuckyEggsMinPokemonAmount => _settings.UseLuckyEggsMinPokemonAmount; + public bool EvolveAllPokemonAboveIv => _settings.EvolveAllPokemonAboveIv; + public float EvolveAboveIvValue => _settings.EvolveAboveIvValue; + public bool RenamePokemon => _settings.RenamePokemon; + public bool RenameOnlyAboveIv => _settings.RenameOnlyAboveIv; + public float FavoriteMinIvPercentage => _settings.FavoriteMinIvPercentage; + public bool AutoFavoritePokemon => _settings.AutoFavoritePokemon; + public string RenameTemplate => _settings.RenameTemplate; + public int AmountOfPokemonToDisplayOnStart => _settings.AmountOfPokemonToDisplayOnStart; + public bool DumpPokemonStats => _settings.DumpPokemonStats; + public string TranslationLanguageCode => _settings.TranslationLanguageCode; + public bool ShowPokeballCountsBeforeRecycle => _settings.ShowPokeballCountsBeforeRecycle; + public bool VerboseRecycling => _settings.VerboseRecycling; + public double RecycleInventoryAtUsagePercentage => _settings.RecycleInventoryAtUsagePercentage; + public double EvolveKeptPokemonsAtStorageUsagePercentage => _settings.EvolveKeptPokemonsAtStorageUsagePercentage; + public ICollection> ItemRecycleFilter => _settings.ItemRecycleFilter; + public ICollection PokemonsToEvolve => _settings.PokemonsToEvolve; + public ICollection PokemonsNotToTransfer => _settings.PokemonsNotToTransfer; + public ICollection PokemonsNotToCatch => _settings.PokemonsToIgnore; + public ICollection PokemonToUseMasterball => _settings.PokemonToUseMasterball; + public Dictionary PokemonsTransferFilter => _settings.PokemonsTransferFilter; + public bool StartupWelcomeDelay => _settings.StartupWelcomeDelay; + public bool SnipeAtPokestops => _settings.SnipeAtPokestops; + public int MinPokeballsToSnipe => _settings.MinPokeballsToSnipe; + public int MinPokeballsWhileSnipe => _settings.MinPokeballsWhileSnipe; + public int MaxPokeballsPerPokemon => _settings.MaxPokeballsPerPokemon; + + public SnipeSettings PokemonToSnipe => _settings.PokemonToSnipe; + public string SnipeLocationServer => _settings.SnipeLocationServer; + public int SnipeLocationServerPort => _settings.SnipeLocationServerPort; + public bool GetSniperInfoFromPokezz => _settings.GetSniperInfoFromPokezz; + public bool GetOnlyVerifiedSniperInfoFromPokezz => _settings.GetOnlyVerifiedSniperInfoFromPokezz; + public bool UseSnipeLocationServer => _settings.UseSnipeLocationServer; + public bool UseSnipeOnlineLocationServer => _settings.UseSnipeOnlineLocationServer; + public bool UseTransferIvForSnipe => _settings.UseTransferIvForSnipe; + public bool SnipeIgnoreUnknownIv => _settings.SnipeIgnoreUnknownIv; + public int MinDelayBetweenSnipes => _settings.MinDelayBetweenSnipes; + public double SnipingScanOffset => _settings.SnipingScanOffset; + public int TotalAmountOfPokeballsToKeep => _settings.TotalAmountOfPokeballsToKeep; + public int TotalAmountOfPotionsToKeep => _settings.TotalAmountOfPotionsToKeep; + public int TotalAmountOfRevivesToKeep => _settings.TotalAmountOfRevivesToKeep; + public int TotalAmountOfBerriesToKeep => _settings.TotalAmountOfBerriesToKeep; + } } diff --git a/PoGo.NecroBot.Logic/State/FarmState.cs b/PoGo.NecroBot.Logic/State/FarmState.cs index f1489208f..9955c4aa1 100644 --- a/PoGo.NecroBot.Logic/State/FarmState.cs +++ b/PoGo.NecroBot.Logic/State/FarmState.cs @@ -3,9 +3,6 @@ using System.Threading; using System.Threading.Tasks; using PoGo.NecroBot.Logic.Tasks; -using PoGo.NecroBot.Logic.Common; -using PoGo.NecroBot.Logic.Logging; -using System; #endregion diff --git a/PoGo.NecroBot.Logic/Tasks/FavoritePokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/FavoritePokemonTask.cs index c3ba7b457..f14a019e1 100644 --- a/PoGo.NecroBot.Logic/Tasks/FavoritePokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/FavoritePokemonTask.cs @@ -1,7 +1,6 @@ #region using directives using System; -using System.Globalization; using System.Threading; using System.Threading.Tasks; using PoGo.NecroBot.Logic.Common; diff --git a/PoGo.NecroBot.Logic/Tasks/InventoryListTask.cs b/PoGo.NecroBot.Logic/Tasks/InventoryListTask.cs index 54c1680e2..cf33698c2 100644 --- a/PoGo.NecroBot.Logic/Tasks/InventoryListTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/InventoryListTask.cs @@ -1,10 +1,7 @@ using PoGo.NecroBot.Logic.Event; using PoGo.NecroBot.Logic.State; using PoGo.NecroBot.Logic.Utils; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace PoGo.NecroBot.Logic.Tasks diff --git a/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs index e133ec195..9054b9f75 100644 --- a/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs @@ -1,13 +1,10 @@ #region using directives -using System; using System.Threading; using System.Threading.Tasks; using PoGo.NecroBot.Logic.Logging; using PoGo.NecroBot.Logic.State; -using System.Collections.Generic; using PoGo.NecroBot.Logic.PoGoUtils; -using POGOProtos.Enums; using System.Linq; #endregion diff --git a/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs index 46139c513..19878d93c 100644 --- a/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs @@ -7,8 +7,6 @@ using PoGo.NecroBot.Logic.PoGoUtils; using PoGo.NecroBot.Logic.State; using PoGo.NecroBot.Logic.Utils; -using PoGo.NecroBot.Logic.Logging; -using PoGo.NecroBot.Logic.Common; #endregion diff --git a/PoGo.NecroBot.Logic/Tasks/TransferPokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/TransferPokemonTask.cs index e332e951d..2a0619837 100644 --- a/PoGo.NecroBot.Logic/Tasks/TransferPokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/TransferPokemonTask.cs @@ -1,14 +1,9 @@ #region using directives using System.Linq; -using System.Threading; using System.Threading.Tasks; -using PoGo.NecroBot.Logic.Event; -using PoGo.NecroBot.Logic.PoGoUtils; using PoGo.NecroBot.Logic.State; using PoGo.NecroBot.Logic.Utils; -using PoGo.NecroBot.Logic.Logging; -using PoGo.NecroBot.Logic.Common; #endregion diff --git a/PoGo.NecroBot.Logic/Utils/Statistics.cs b/PoGo.NecroBot.Logic/Utils/Statistics.cs index 9bff79a2f..ad51577f9 100644 --- a/PoGo.NecroBot.Logic/Utils/Statistics.cs +++ b/PoGo.NecroBot.Logic/Utils/Statistics.cs @@ -3,7 +3,6 @@ #region using directives using System; -using System.Globalization; using System.Linq; using POGOProtos.Networking.Responses; using System.Threading.Tasks; diff --git a/PoGo.NecroBot.Logic/app.config b/PoGo.NecroBot.Logic/app.config index 9701faebc..545d0858a 100644 --- a/PoGo.NecroBot.Logic/app.config +++ b/PoGo.NecroBot.Logic/app.config @@ -1,16 +1,15 @@ - - + - - + + - - + + - \ No newline at end of file + From 14dda154f5a4e52ec85e96469f3211314e41ea74 Mon Sep 17 00:00:00 2001 From: simplyphp Date: Thu, 4 Aug 2016 18:00:12 -0500 Subject: [PATCH 2/2] Fixing incorrect setup.md suggestion on settings --- PoGo.NecroBot.CLI/SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PoGo.NecroBot.CLI/SETUP.md b/PoGo.NecroBot.CLI/SETUP.md index 4e756e02d..97b32b9ed 100644 --- a/PoGo.NecroBot.CLI/SETUP.md +++ b/PoGo.NecroBot.CLI/SETUP.md @@ -4,7 +4,7 @@ Setup for Necrobot: 2. Go to the config directory and open config.json in Notepad, Sublime, Brackets, etc. 3. Change the "DefaultLatitude" and "DefaultLongitude" to your starting location. Change other parameters in the json file as you wish. - **Note: changing "MaxTravelDistanceInMeters" to a large number (<5000) may cause problems** + **Note: changing "MaxTravelDistanceInMeters" to a large number (>=5000) may cause problems** 4. Run the NecroBot app again and start botting PoGo! See the Discord chat below for questions. Be nice.