Reduce array allocations and function calls

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
This commit is contained in:
NightKev 2025-08-02 13:45:13 -07:00 committed by GitHub
parent ae7d963fb5
commit 81a4020698
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -711,7 +711,8 @@ export class FreshStartChallenge extends Challenge {
pokemon.moveset = pokemon.moveset.filter(pm => validMoves.includes(pm.moveId));
if (pokemon.moveset.length < 4) {
// If there's empty slots fill with remaining valid moves
validMoves = validMoves.filter(m => !pokemon.moveset.map(pm => pm.moveId).includes(m));
const existingMoveIds = pokemon.moveset.map(pm => pm.moveId);
validMoves = validMoves.filter(m => !existingMoveIds.includes(m));
pokemon.moveset = pokemon.moveset.concat(validMoves.map(m => new PokemonMove(m))).slice(0, 4);
}
pokemon.luck = 0; // No luck