mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 23:13:42 +02:00
Merge 00f9536d3a
into 8d5ba221d8
This commit is contained in:
commit
0c5e843809
@ -510,11 +510,7 @@ function forceStabMove(
|
|||||||
const chosenPool =
|
const chosenPool =
|
||||||
stabMovePool.length > 0 || !forceAnyDamageIfNoStab
|
stabMovePool.length > 0 || !forceAnyDamageIfNoStab
|
||||||
? stabMovePool
|
? stabMovePool
|
||||||
: filterPool(
|
: filterPool(pool, m => allMoves[m].category !== MoveCategory.STATUS && !STAB_BLACKLIST.has(m), totalWeight);
|
||||||
pool,
|
|
||||||
m => allMoves[m[0]].category !== MoveCategory.STATUS && !STAB_BLACKLIST.has(m[0]),
|
|
||||||
totalWeight,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (chosenPool.length > 0) {
|
if (chosenPool.length > 0) {
|
||||||
let rand = randSeedInt(totalWeight.value);
|
let rand = randSeedInt(totalWeight.value);
|
||||||
@ -589,7 +585,7 @@ function fillInRemainingMovesetSlots(
|
|||||||
const tmCap = getMaxTmCount(pokemon.level);
|
const tmCap = getMaxTmCount(pokemon.level);
|
||||||
const eggCap = getMaxEggMoveCount(pokemon.level);
|
const eggCap = getMaxEggMoveCount(pokemon.level);
|
||||||
const remainingPoolWeight = new NumberHolder(0);
|
const remainingPoolWeight = new NumberHolder(0);
|
||||||
while (remainingPool.length > pokemon.moveset.length && pokemon.moveset.length < 4) {
|
while (pokemon.moveset.length < 4) {
|
||||||
const nonLevelMoveCount = tmCount.value + eggMoveCount.value;
|
const nonLevelMoveCount = tmCount.value + eggMoveCount.value;
|
||||||
remainingPool = filterPool(
|
remainingPool = filterPool(
|
||||||
baseWeights,
|
baseWeights,
|
||||||
@ -605,6 +601,11 @@ function fillInRemainingMovesetSlots(
|
|||||||
if (pokemon.hasTrainer()) {
|
if (pokemon.hasTrainer()) {
|
||||||
filterRemainingTrainerMovePool(remainingPool, pokemon);
|
filterRemainingTrainerMovePool(remainingPool, pokemon);
|
||||||
}
|
}
|
||||||
|
// Ensure loop cannot run infinitely if there are no allowed moves left to
|
||||||
|
// fill the remaining slots
|
||||||
|
if (remainingPool.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const totalWeight = remainingPool.reduce((v, m) => v + m[1], 0);
|
const totalWeight = remainingPool.reduce((v, m) => v + m[1], 0);
|
||||||
let rand = randSeedInt(totalWeight);
|
let rand = randSeedInt(totalWeight);
|
||||||
let index = 0;
|
let index = 0;
|
||||||
@ -719,7 +720,7 @@ export function generateMoveset(pokemon: Pokemon): void {
|
|||||||
tmCount,
|
tmCount,
|
||||||
eggMoveCount,
|
eggMoveCount,
|
||||||
baseWeights,
|
baseWeights,
|
||||||
filterPool(baseWeights, (m: MoveId) => !pokemon.moveset.some(mo => m[0] === mo.moveId)),
|
filterPool(baseWeights, (m: MoveId) => !pokemon.moveset.some(mo => m === mo.moveId)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { __INTERNAL_TEST_EXPORTS } from "#app/ai/ai-moveset-gen";
|
import { __INTERNAL_TEST_EXPORTS, generateMoveset } from "#app/ai/ai-moveset-gen";
|
||||||
import {
|
import {
|
||||||
COMMON_TIER_TM_LEVEL_REQUIREMENT,
|
COMMON_TIER_TM_LEVEL_REQUIREMENT,
|
||||||
GREAT_TIER_TM_LEVEL_REQUIREMENT,
|
GREAT_TIER_TM_LEVEL_REQUIREMENT,
|
||||||
@ -282,4 +282,28 @@ describe("Regression Tests - ai-moveset-gen.ts", () => {
|
|||||||
).not.toThrow();
|
).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("generateMoveset", () => {
|
||||||
|
it("should spawn with 4 moves if possible", async () => {
|
||||||
|
// Need to be in a wave for moveset generation to not actually break
|
||||||
|
await game.classicMode.startBattle([SpeciesId.PIKACHU]);
|
||||||
|
|
||||||
|
// Create a pokemon that can learn at least 4 moves
|
||||||
|
pokemon = createTestablePokemon(SpeciesId.ROCKRUFF, { level: 15 });
|
||||||
|
vi.spyOn(pokemon, "getLevelMoves").mockReturnValue([
|
||||||
|
[1, MoveId.TACKLE],
|
||||||
|
[4, MoveId.LEER],
|
||||||
|
[7, MoveId.SAND_ATTACK],
|
||||||
|
[10, MoveId.ROCK_THROW],
|
||||||
|
[13, MoveId.DOUBLE_TEAM],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Generate the moveset
|
||||||
|
generateMoveset(pokemon);
|
||||||
|
expect(pokemon.moveset).toHaveLength(4);
|
||||||
|
// Unlike other test suites, phase interceptor is not automatically restored after the tests here,
|
||||||
|
// since most tests in this suite do not need the phase
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -127,7 +127,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should start battle against the trainer with correctly loaded assets", async () => {
|
// TODO: This is a flaky test that needs to have its fishy logic revisited
|
||||||
|
it.todo("should start battle against the trainer with correctly loaded assets", async () => {
|
||||||
await game.runToMysteryEncounter(MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER, defaultParty);
|
await game.runToMysteryEncounter(MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER, defaultParty);
|
||||||
|
|
||||||
let successfullyLoaded = false;
|
let successfullyLoaded = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user