doshidak / showdex

Pokémon Showdown extension that harnesses the power of parabolic calculus to strategically extract your opponents' Elo.
GNU Affero General Public License v3.0
104 stars 18 forks source link

FEAT: Import Moves Reordering Behavior Toggle #148

Closed jmynes closed 1 year ago

jmynes commented 1 year ago

Could there be a setting to import as-is, without sorting moves alphabetically?: image

doshidak commented 1 year ago

hmm, interestingly enough, I don't sort the order of the imported moves at all :o (they're processed in the order as-is in the PokéPaste!)

but a feature exists in the Calcdex that will always show the Pokémon's revealed moves, regardless of the set. the order in which those revealed moves are processed is also handled as-is, which is up to each player. (there's a specific ordering of the revealed moves when you hover over a Pokémon in a battle, which isn't necessarily in the same order as what your opponent sees when they go to choose one.)

revealed moves aren't replaced in a linear order either, i.e., first revealed move replaces the first move slot, second move in the second slot, etc. rather, they replace existing moves based on their properties (e.g., category, STAB, etc.) in a very particular order (see mergeRevealedMoves() for the exact algorithm).

all this to say, not entirely sure what's going on your end o_O ... I tried reproducing this on my end, but without any revealed moves, so the moves appeared in the same order as my PokéPaste import.

did the Slowking have any revealed moves when you took that screenshot? do you happen to have a replay of that game or a similar one by any chance? (no worries if not!)

thanks! c:

jmynes commented 1 year ago

Here's an example: image

  1. I lead Zapdos. my alt lead Milotic
  2. I use Agility, my alt throws out Regirock
  3. I open Regirock in the floating Smogon window
  4. I copy the Swagger + Psych Up set to my clipboard:
    Regirock @ Leftovers
    Ability: Clear Body
    EVs: 252 HP / 252 Atk / 4 SpD
    Adamant Nature
    - Swagger
    - Psych Up
    - Superpower
    - Rock Slide
  5. I switch from the Showdown Usage set to Import
  6. Calcdex shows the moves in alphabetical order, instead:
    - Psych Up
    - Rock Slide
    - Superpower
    - Swagger

Replay: https://replay.pokemonshowdown.com/gen3ou-1928416802

doshidak commented 1 year ago

Thanks for the detailed write-up! I see the problem now on my end, so I'll take a look & keep you posted c:

doshidak commented 1 year ago

dude I figured it out holy fuck LOL.

In importPokePaste(), there's a little line right before the return:

preset.calcdexId = calcPresetCalcdexId(preset);

Seemed innocent enough & in my initial 100 searches, never bothered to look at it. There's nothing possibly in calcPresetCalcdexId() that could sort the array or anything right...?

moves: preset?.moves?.sort().join(','), // sort moves in ABC order

Whoops, don't think I thought it through when I wrote that a year ago LOL.

But anyway, I fixed it & will be bundling it alongside the upcoming v1.1.7 release! (I'll also close this issue when I merge the v1.1.7 PR.)

This has been one wild ride, thanks!