Skip to content

Commit

Permalink
Fixed a logic error in GetDuplicatePokemonToTransfer & reduced size o…
Browse files Browse the repository at this point in the history
…f GetXpDiff

With KeepPokemonsThatCanEvolve=true it previously also kept all pokemons
that couldn't evolve. Added KeepPokemonsThatCanEvolve to Settings
  • Loading branch information
5andr0 committed Jul 25, 2016
1 parent ebd86d3 commit 3bf1661
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 89 deletions.
3 changes: 3 additions & 0 deletions PoGo.NecroBot.CLI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<setting name="EvolveAllPokemonWithEnoughCandy" serializeAs="String">
<value>False</value>
</setting>
<setting name="KeepPokemonsThatCanEvolve" serializeAs="String">
<value>False</value>
</setting>
<setting name="TransferDuplicatePokemon" serializeAs="String">
<value>True</value>
</setting>
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class LogicSettings : ILogicSettings
public int KeepMinCp => UserSettings.Default.KeepMinCP;
public double WalkingSpeedInKilometerPerHour => UserSettings.Default.WalkingSpeedInKilometerPerHour;
public bool EvolveAllPokemonWithEnoughCandy => UserSettings.Default.EvolveAllPokemonWithEnoughCandy;
public bool KeepPokemonsThatCanEvolve => UserSettings.Default.KeepPokemonsThatCanEvolve;
public bool TransferDuplicatePokemon => UserSettings.Default.TransferDuplicatePokemon;
public int DelayBetweenPokemonCatch => UserSettings.Default.DelayBetweenPokemonCatch;
public bool UsePokemonToNotCatchFilter => UserSettings.Default.UsePokemonToNotCatchFilter;
Expand Down
17 changes: 16 additions & 1 deletion PoGo.NecroBot.CLI/UserSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface ILogicSettings
int KeepMinCp { get; }
double WalkingSpeedInKilometerPerHour { get; }
bool EvolveAllPokemonWithEnoughCandy { get; }
bool KeepPokemonsThatCanEvolve { get; }
bool TransferDuplicatePokemon { get; }
int DelayBetweenPokemonCatch { get; }
bool UsePokemonToNotCatchFilter { get; }
Expand Down
10 changes: 4 additions & 6 deletions PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ public async Task<IEnumerable<PokemonData>> GetDuplicatePokemonToTransfer(
{
var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.Key);
var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
if (settings.CandyToEvolve == 0)
continue;
var amountToSkip = _client.Settings.KeepMinDuplicatePokemon;

if (settings.CandyToEvolve > 0 && familyCandy.Candy / settings.CandyToEvolve > amountToSkip)
amountToSkip = familyCandy.Candy / settings.CandyToEvolve;

var amountToSkip = familyCandy.Candy/settings.CandyToEvolve;
amountToSkip = amountToSkip > _logicClient.Settings.KeepMinDuplicatePokemon
? amountToSkip
: _logicClient.Settings.KeepMinDuplicatePokemon;
if (prioritizeIVoverCp)
{
results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key)
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TransferDuplicatePokemonTask
public static void Execute(Context ctx, StateMachine machine)
{
var duplicatePokemons =
ctx.Inventory.GetDuplicatePokemonToTransfer(false, ctx.LogicSettings.PrioritizeIvOverCp,
ctx.Inventory.GetDuplicatePokemonToTransfer(ctx.LogicSettings.KeepPokemonsThatCanEvolve, ctx.LogicSettings.PrioritizeIvOverCp,
ctx.LogicSettings.PokemonsNotToTransfer).Result;

foreach (var duplicatePokemon in duplicatePokemons)
Expand Down
87 changes: 6 additions & 81 deletions PoGo.NecroBot.Logic/Utils/Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,88 +73,13 @@ public double GetRuntime()

public static int GetXpDiff(int level)
{
switch (level)
if (level > 0 && level <= 40)
{
case 1:
return 0;
case 2:
return 1000;
case 3:
return 2000;
case 4:
return 3000;
case 5:
return 4000;
case 6:
return 5000;
case 7:
return 6000;
case 8:
return 7000;
case 9:
return 8000;
case 10:
return 9000;
case 11:
return 10000;
case 12:
return 10000;
case 13:
return 10000;
case 14:
return 10000;
case 15:
return 15000;
case 16:
return 20000;
case 17:
return 20000;
case 18:
return 20000;
case 19:
return 25000;
case 20:
return 25000;
case 21:
return 50000;
case 22:
return 75000;
case 23:
return 100000;
case 24:
return 125000;
case 25:
return 150000;
case 26:
return 190000;
case 27:
return 200000;
case 28:
return 250000;
case 29:
return 300000;
case 30:
return 350000;
case 31:
return 500000;
case 32:
return 500000;
case 33:
return 750000;
case 34:
return 1000000;
case 35:
return 1250000;
case 36:
return 1500000;
case 37:
return 2000000;
case 38:
return 2500000;
case 39:
return 1000000;
case 40:
return 1000000;
int[] xpTable = { 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000,
10000, 10000, 10000, 10000, 15000, 20000, 20000, 20000, 25000, 25000,
50000, 75000, 100000, 125000, 150000, 190000, 200000, 250000, 300000, 350000,
500000, 500000, 750000, 1000000, 1250000, 1500000, 2000000, 2500000, 1000000, 1000000};
return xpTable[level - 1];
}
return 0;
}
Expand Down

1 comment on commit 3bf1661

@al1sse
Copy link

@al1sse al1sse commented on 3bf1661 Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeepPokemonsThatCanEvolve=true keep crashing

Please sign in to comment.