Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utils.Gym: Improve best option selection #315

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}