Re-implement fixed moveset generation with fix
parent
5e8b5c8ac7
commit
a33dd47853
|
@ -767,8 +767,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
for (let e = 0; e < evolutionChain.length; e++) {
|
||||
// TODO: Might need to pass specific form index in simulated evolution chain
|
||||
const speciesLevelMoves = getPokemonSpeciesForm(evolutionChain[e][0] as Species, this.formIndex).getLevelMoves();
|
||||
levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && !lm[0]) || (lm[0] >= evolutionChain[e][1] && (e === evolutionChain.length - 1 || lm[0] <= evolutionChain[e + 1][1]))));
|
||||
levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && !lm[0]) || ((!e || lm[0] > 1) && (e === evolutionChain.length - 1 || lm[0] <= evolutionChain[e + 1][1]))));
|
||||
}
|
||||
levelMoves.sort((lma: [integer, integer], lmb: [integer, integer]) => lma[0] > lmb[0] ? 1 : lma[0] < lmb[0] ? -1 : 0);
|
||||
const uniqueMoves: Moves[] = [];
|
||||
levelMoves = levelMoves.filter(lm => {
|
||||
if (uniqueMoves.find(m => m === lm[1]))
|
||||
|
@ -904,7 +905,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
const movePool = [];
|
||||
const allLevelMoves = this.getLevelMoves(1, true, true);
|
||||
if (!allLevelMoves) {
|
||||
console.log(this.species.speciesId, 'ERROR')
|
||||
console.log(this.species.speciesId, 'ERROR');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -926,13 +927,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
});
|
||||
|
||||
if (attackMovePool.length) {
|
||||
const randomAttackMove = Utils.randSeedWeightedItem(attackMovePool.reverse());
|
||||
const randomAttackMove = Utils.randSeedEasedWeightedItem(attackMovePool);
|
||||
this.moveset.push(new PokemonMove(randomAttackMove, 0, 0));
|
||||
console.log(allMoves[randomAttackMove]);
|
||||
movePool.splice(movePool.findIndex(m => m === randomAttackMove), 1);
|
||||
}
|
||||
|
||||
while (movePool.length && this.moveset.length < 4) {
|
||||
const randomMove = Utils.randSeedWeightedItem(movePool.reverse());
|
||||
const randomMove = Utils.randSeedEasedWeightedItem(movePool);
|
||||
this.moveset.push(new PokemonMove(randomMove, 0, 0));
|
||||
console.log(allMoves[randomMove]);
|
||||
movePool.splice(movePool.indexOf(randomMove), 1);
|
||||
|
|
|
@ -61,7 +61,7 @@ export function updateWindowType(scene: BattleScene, windowTypeIndex: integer):
|
|||
const windowObjects: [Phaser.GameObjects.NineSlice, WindowVariant][] = [];
|
||||
const themedObjects: Phaser.GameObjects.Image[] = [];
|
||||
const traverse = (object: any) => {
|
||||
if (object.hasOwnProperty('children')) {
|
||||
if (object.hasOwnProperty('children') && object.children instanceof Phaser.GameObjects.DisplayList) {
|
||||
const children = object.children as Phaser.GameObjects.DisplayList;
|
||||
for (let child of children.getAll())
|
||||
traverse(child);
|
||||
|
|
10
src/utils.ts
10
src/utils.ts
|
@ -96,6 +96,16 @@ export function randSeedWeightedItem<T>(items: T[]): T {
|
|||
: Phaser.Math.RND.weightedPick(items);
|
||||
}
|
||||
|
||||
export function randSeedEasedWeightedItem<T>(items: T[], easingFunction: string = 'Sine.easeIn'): T {
|
||||
if (!items.length)
|
||||
return null;
|
||||
if (items.length === 1)
|
||||
return items[0];
|
||||
const value = Phaser.Math.RND.realInRange(0, 1);
|
||||
const easedValue = Phaser.Tweens.Builders.GetEaseFunction(easingFunction)(value);
|
||||
return items[Math.floor(easedValue * items.length)];
|
||||
}
|
||||
|
||||
export function getSunday(date: Date): Date {
|
||||
const day = date.getDay();
|
||||
const diff = date.getDate() - day;
|
||||
|
|
Loading…
Reference in New Issue