Fixed code

This commit is contained in:
Bertie690 2025-05-30 11:08:28 -04:00
parent 71ce6575a8
commit 6936d7235e
2 changed files with 22 additions and 19 deletions

View File

@ -65,7 +65,6 @@ import {
rgbToHsv,
deltaRgb,
isBetween,
type nil,
type Constructor,
randSeedIntRange,
} from "#app/utils/common";
@ -4389,11 +4388,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* or `undefined` if no applicable moves have been used since switching in.
*/
getLastNonVirtualMove(ignoreStruggle = false, ignoreFollowUp = true): TurnMove | undefined {
return this.getLastXMoves(-1).find(m =>
m.move !== Moves.NONE
&& (!ignoreStruggle || m.move !== Moves.STRUGGLE)
&& (!isVirtual(m.useType) ||
(!ignoreFollowUp && m.useType === MoveUseType.FOLLOW_UP))
return this.getLastXMoves(-1).find(
m =>
m.move !== Moves.NONE &&
(!ignoreStruggle || m.move !== Moves.STRUGGLE) &&
(!isVirtual(m.useType) || (!ignoreFollowUp && m.useType === MoveUseType.FOLLOW_UP)),
);
}
@ -4413,7 +4412,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.summonData.moveQueue.push(queuedMove);
}
changeForm(formChange: SpeciesFormChange): Promise<void> {
return new Promise(resolve => {
this.formIndex = Math.max(
@ -6247,7 +6245,7 @@ export class EnemyPokemon extends Pokemon {
isVirtual(queuedMove.useType) ||
(moveIndex > -1 && this.getMoveset()[moveIndex].isUsable(this, isIgnorePP(queuedMove.useType)))
) {
moveQueue.splice(0, i) // TODO: This may be redundant and definitely should not be done here
moveQueue.splice(0, i); // TODO: This may be redundant and definitely should not be done here
return queuedMove;
}
}
@ -6258,7 +6256,11 @@ export class EnemyPokemon extends Pokemon {
if (movePool.length) {
// If there's only 1 move in the move pool, use it.
if (movePool.length === 1) {
return { move: movePool[0].moveId, targets: this.getNextTargets(movePool[0].moveId) , useType: MoveUseType.NORMAL};
return {
move: movePool[0].moveId,
targets: this.getNextTargets(movePool[0].moveId),
useType: MoveUseType.NORMAL,
};
}
// If a move is forced because of Encore, use it.
// Said moves are executed normally
@ -6269,7 +6271,7 @@ export class EnemyPokemon extends Pokemon {
return {
move: encoreMove.moveId,
targets: this.getNextTargets(encoreMove.moveId),
useType: MoveUseType.NORMAL
useType: MoveUseType.NORMAL,
};
}
}
@ -6440,15 +6442,17 @@ export class EnemyPokemon extends Pokemon {
r++;
}
}
console.log(movePool.map(m => m.getName()), moveScores, r, sortedMovePool.map(m => m.getName()));
return { move: sortedMovePool[r]!.moveId, targets: moveTargets[sortedMovePool[r]!.moveId], useType: MoveUseType.NORMAL };
console.log(
movePool.map(m => m.getName()),
moveScores,
r,
sortedMovePool.map(m => m.getName()),
);
return { move: sortedMovePool[r]!.moveId, targets: moveTargets[sortedMovePool[r]!.moveId], useType: MoveUseType.NORMAL };
return {
move: sortedMovePool[r]!.moveId,
targets: moveTargets[sortedMovePool[r]!.moveId],
useType: MoveUseType.NORMAL,
};
}
}
}
@ -6741,7 +6745,6 @@ export class EnemyPokemon extends Pokemon {
return ret;
}
/**
* Show or hide the type effectiveness multiplier window
* Passing undefined will hide the window

View File

@ -5,7 +5,7 @@ import { addBBCodeTextObject, addTextObject, getTextColor, TextStyle } from "#ap
import { Command } from "#app/ui/command-ui-handler";
import MessageUiHandler from "#app/ui/message-ui-handler";
import { UiMode } from "#enums/ui-mode";
import { BooleanHolder, toReadableString, randInt, getLocalizedSpriteKey, isNullOrUndefined } from "#app/utils/common";
import { BooleanHolder, toReadableString, randInt, getLocalizedSpriteKey } from "#app/utils/common";
import {
PokemonFormChangeItemModifier,
PokemonHeldItemModifier,
@ -1165,19 +1165,19 @@ export default class PartyUiHandler extends MessageUiHandler {
this.partyUiMode !== PartyUiMode.FAINT_SWITCH &&
globalScene.findModifier(
m =>
m instanceof SwitchEffectTransferModifier &&
m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
m instanceof SwitchEffectTransferModifier && m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
)
);
}
// TODO: add FORCED_SWITCH (and perhaps also BATON_PASS_SWITCH) to the modes
// TODO: refactor once moves in flight become a thing...
private isBatonPassMove(): boolean {
const lastMove: TurnMove | undefined = globalScene.getPlayerField()[this.fieldIndex].getLastXMoves()[0];
return (
this.partyUiMode === PartyUiMode.FAINT_SWITCH &&
allMoves[lastMove.move].getAttrs(ForceSwitchOutAttr)[0]?.isBatonPass() &&
lastMove?.result === MoveResult.SUCCESS
lastMove?.result === MoveResult.SUCCESS &&
allMoves[lastMove.move].getAttrs(ForceSwitchOutAttr)[0]?.isBatonPass()
);
}