Ephenia / Pokeclicker-Scripts

Various scripts & enhancements for the game Pokéclicker.
https://github.com/Ephenia/Pokeclicker-Scripts
GNU General Public License v3.0
184 stars 263 forks source link

Change catchFilterFantasia to just overload pokeball catch method #316

Closed umamaistempo closed 11 months ago

umamaistempo commented 1 year ago

This PR superseeds #315

By just overloading the calculatePokeballToUse instead of overriding the defeatPokemon method we become more future-proof and don't do more than the minimal necessary to apply the catch filter.

This should fix #314, you can check that now on dungeons the number of enemies defeated (top-right corner of dungeon map box) is now displayed correctly as the game original defeatPokemon procedure is being executed.

Thanks to @umbralOptimatum for suggesting this change

Tests

umamaistempo commented 1 year ago

Next improvement I intend to do to improve readability is keeping the collection of overrides as a map/dict instead of several position-based lists.

Eg:

{
  2: [-1, -1],
  30: [2, -1]
}
umbralOptimatum commented 1 year ago

Looks good! One other small improvement would be to replace the paired pokemonList.find() pokemonList.indexOf() calls with pokemonList.findIndex(). From a quick glance it looks like most of the uses only need the index, not the full pokemon object, and when the latter is used might as well access it via the index.

umamaistempo commented 1 year ago

Good catch, will apply that change later today.

Additionally, when I work on the map refactor, this will be replaced by just a simple pokeballFilters.get(id)

On Mon, 5 Jun 2023 at 19:36 umbralOptimatum @.***> wrote:

Looks good! One other small improvement would be to replace the paired pokemonList.find() pokemonList.indexOf() calls with pokemonList.findIndex(). From a quick glance it looks like most of the uses only need the index, not the full pokemon object, and when the latter is used might as well access it via the index.

— Reply to this email directly, view it on GitHub https://github.com/Ephenia/Pokeclicker-Scripts/pull/316#issuecomment-1577573789, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWQ4JNUVDURLE3WTY3CI6DXJZNQTANCNFSM6AAAAAAY3QZ3PU . You are receiving this because you authored the thread.Message ID: @.***>

--

Charlotte Lorelei Oliveira LinkedIn https://www.linkedin.com/in/umamaistempo/

Ephenia commented 11 months ago

Approved!