public void LoadCatchSettings() { CatchSettings = new List <CatchSetting>(); foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId))) { if (pokemon == PokemonId.Missingno) { continue; } var cSettings = new CatchSetting { Id = pokemon }; CatchSettings.Add(cSettings); } }
private bool PokemonWithinCatchSettings(MapPokemon pokemon) { CatchSetting catchSettings = UserSettings.CatchSettings.FirstOrDefault(x => x.Id == pokemon.PokemonId); if (catchSettings == null) { LogCaller(new LoggerEventArgs(String.Format("Failed to find catch setting for {0}. Attempting to catch", pokemon.PokemonId), LoggerTypes.Warning)); return(true); } if (!catchSettings.Catch) { LogCaller(new LoggerEventArgs(String.Format("Skipping catching {0}", pokemon.PokemonId), LoggerTypes.Info)); } return(catchSettings.Catch); }
private void UpdateDisplay() { CatchSetting setting = _settings.First(); for (int i = 0; i < comboBoxTransferType.Items.Count; i++) { if (((TransferType)comboBoxTransferType.Items[i]) == setting.TransferType) { comboBoxTransferType.SelectedIndex = i; break; } } numericUpDownKeepMax.Value = setting.KeepMax; numericUpDownMinCP.Value = setting.MinTransferCP; numericUpDownIVPercent.Value = setting.IVPercent; checkBoxTransfer.Checked = setting.Transfer; }
public AccountSettingsForm(Manager manager) { InitializeComponent(); _manager = manager; #region Catching olvColumnCatchId.AspectGetter = delegate(object x) { CatchSetting setting = (CatchSetting)x; return((int)setting.Id); }; #endregion #region Evolving olvColumnEvolveId.AspectGetter = delegate(object x) { EvolveSetting setting = (EvolveSetting)x; return((int)setting.Id); }; #endregion #region Transfer olvColumnTransferId.AspectGetter = delegate(object x) { TransferSetting setting = (TransferSetting)x; return((int)setting.Id); }; #endregion }
public MethodResult <List <PokemonData> > GetPokemonToTransfer() { if (!UserSettings.TransferPokemon) { LogCaller(new LoggerEventArgs("Transferring disabled", LoggerTypes.Debug)); return(new MethodResult <List <PokemonData> > { Data = new List <PokemonData>(), Message = "Transferring disabled", Success = true }); } if (!Pokemon.Any()) { LogCaller(new LoggerEventArgs("You have no pokemon", LoggerTypes.Info)); return(new MethodResult <List <PokemonData> > { Message = "You have no pokemon" }); } var pokemonToTransfer = new List <PokemonData>(); IEnumerable <IGrouping <PokemonId, PokemonData> > groupedPokemon = Pokemon.GroupBy(x => x.PokemonId); foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon) { CatchSetting settings = UserSettings.PokemonSettings.FirstOrDefault(x => x.Id == group.Key); if (settings == null) { LogCaller(new LoggerEventArgs(String.Format("Failed to find transfer settings for pokemon {0}", group.Key), LoggerTypes.Warning)); continue; } if (!settings.Transfer) { continue; } switch (settings.TransferType) { case TransferType.All: pokemonToTransfer.AddRange(group.ToList()); break; case TransferType.BelowCP: pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinTransferCP)); break; case TransferType.BelowIVPercentage: pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.IVPercent)); break; case TransferType.KeepPossibleEvolves: pokemonToTransfer.AddRange(GetPokemonByPossibleEvolve(group, settings.KeepMax)); break; case TransferType.KeepStrongestX: pokemonToTransfer.AddRange(GetPokemonByStrongest(group, settings.KeepMax)); break; case TransferType.KeepXHighestIV: pokemonToTransfer.AddRange(GetPokemonByIV(group, settings.KeepMax)); break; case TransferType.BelowCPAndIVAmount: pokemonToTransfer.AddRange(GetPokemonBelowCPIVAmount(group, settings.MinTransferCP, settings.IVPercent)); break; case TransferType.BelowCPOrIVAmount: pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.IVPercent)); pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinTransferCP)); pokemonToTransfer = pokemonToTransfer.DistinctBy(x => x.Id).ToList(); break; case TransferType.Slashed: pokemonToTransfer.AddRange(group.ToList()); pokemonToTransfer = pokemonToTransfer.DistinctBy(x => x.IsBad).ToList(); break; } } if (UserSettings.TransferSlashPokemons) { var slashPokemons = Pokemon.Where(x => x.IsBad); foreach (var slashPokemon in slashPokemons) { var inlist = pokemonToTransfer.FirstOrDefault(x => x.Id == slashPokemon.Id); if (inlist == null) { pokemonToTransfer.Add(slashPokemon); } } } return(new MethodResult <List <PokemonData> > { Data = pokemonToTransfer, Message = String.Format("Found {0} pokemon to transfer", pokemonToTransfer.Count), Success = true }); }
private MethodResult <List <PokemonData> > GetPokemonToEvolve() { if (!UserSettings.EvolvePokemon) { LogCaller(new LoggerEventArgs("Evolving disabled", LoggerTypes.Info)); return(new MethodResult <List <PokemonData> > { Data = new List <PokemonData>(), Message = "Evolving disabled", Success = true }); } UpdateInventory(); // <- should not be needed var pokemonToEvolve = new List <PokemonData>(); IEnumerable <IGrouping <PokemonId, PokemonData> > groupedPokemon = Pokemon.OrderByDescending(x => x.PokemonId).GroupBy(x => x.PokemonId); foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon) { CatchSetting evolveSetting = UserSettings.PokemonSettings.FirstOrDefault(x => x.Id == group.Key); if (evolveSetting == null) { LogCaller(new LoggerEventArgs(String.Format("Failed to find evolve settings for pokemon {0}", group.Key), LoggerTypes.Info)); continue; } if (!evolveSetting.Evolve) { //Don't evolve continue; } PokemonSettings setting; if (!PokeSettings.TryGetValue(group.Key, out setting)) { LogCaller(new LoggerEventArgs(String.Format("Failed to find settings for pokemon {0}", group.Key), LoggerTypes.Info)); continue; } if (setting.EvolutionIds.Count == 0) { //Pokemon can't evolve continue; } Candy pokemonCandy = PokemonCandy.FirstOrDefault(x => x.FamilyId == setting.FamilyId); List <PokemonData> pokemonGroupToEvolve = group.Where(x => x.Cp >= evolveSetting.MinEvolveCP).OrderByDescending(x => CalculateIVPerfection(x)).ToList(); if (pokemonCandy == null) { LogCaller(new LoggerEventArgs(String.Format("No candy found for pokemon {0}", group.Key), LoggerTypes.Info)); continue; } int candyToEvolve = setting.CandyToEvolve; int totalPokemon = pokemonGroupToEvolve.Count; int totalCandy = pokemonCandy.Candy_; int maxPokemon = totalCandy / candyToEvolve; foreach (PokemonData pData in pokemonGroupToEvolve.Take(maxPokemon)) { pokemonToEvolve.Add(pData); } } return(new MethodResult <List <PokemonData> > { Data = pokemonToEvolve, Message = "Success", Success = true }); }