Skip to content

Commit

Permalink
Utils.Gym: Improve best option selection (issue #307)
Browse files Browse the repository at this point in the history
Since
[v0.10.2](pokeclicker/pokeclicker@f02f836)
a gym leader might have more potential pokémons listed than the ones
that are actually used.

This would lead to many wrong decisions for the automation. The
`getPokemonList()` is now used to access the correct pokémon list.
  • Loading branch information
Farigh committed Aug 25, 2023
2 parents b104a00 + 1d02639 commit fdbdc44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/lib/Utils/Gym.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class AutomationUtilsGym
: playerClickAttack;

let currentGymGemPerTick = 0;
for (const pokemon of gym.pokemons)
const gymPokemons = gym.getPokemonList()
for (const pokemon of gymPokemons)
{
const pokemonData = pokemonMap[pokemon.name];
if (!pokemonData.type.includes(pokemonType))
Expand All @@ -77,7 +78,7 @@ class AutomationUtilsGym
}

// TODO (26/06/2022): Be more precise, all pokemons do not have the same health
currentGymGemPerTick /= gym.pokemons.length;
currentGymGemPerTick /= gymPokemons.length;

// Compare with a 1/1000 precision
if (Math.ceil(currentGymGemPerTick * 1000) >= Math.ceil(bestGymRate * 1000))
Expand Down Expand Up @@ -151,7 +152,7 @@ class AutomationUtilsGym

const weatherType = Weather.regionalWeather[townRegion]();

const ticksToWin = gym.pokemons.reduce(
const ticksToWin = gym.getPokemonList().reduce(
(count, pokemon) =>
{
const partyAttack =
Expand Down Expand Up @@ -198,7 +199,7 @@ class AutomationUtilsGym
{
let gym = GymList[gymName];

for (const pokemon of gym.pokemons)
for (const pokemon of gym.getPokemonList())
{
let pokemonData = pokemonMap[pokemon.name];

Expand All @@ -225,15 +226,9 @@ class AutomationUtilsGym
gymName: gymName,
gymTown: gymTown,
region: TownList[gymTown].region,
subRegion: TownList[gymTown].subRegion,
pokemonMathingType: 1,
totalPokemons: gym.pokemons.length
subRegion: TownList[gymTown].subRegion
});
}
else
{
gemTypeData.at(-1).pokemonMathingType += 1;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions tst/stubs/Gym/Gym.pokeclicker.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ class Gym extends TownContent
this.town = town;
this.pokemons = pokemons;
}

getPokemonList()
{
return this.pokemons
}
}

0 comments on commit fdbdc44

Please sign in to comment.