mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
Fix minimum move count threshold and utilize baseWeights
This commit is contained in:
parent
207808f37d
commit
864199a8e0
@ -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)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user