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, rgbToHsv,
deltaRgb, deltaRgb,
isBetween, isBetween,
type nil,
type Constructor, type Constructor,
randSeedIntRange, randSeedIntRange,
} from "#app/utils/common"; } 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. * or `undefined` if no applicable moves have been used since switching in.
*/ */
getLastNonVirtualMove(ignoreStruggle = false, ignoreFollowUp = true): TurnMove | undefined { getLastNonVirtualMove(ignoreStruggle = false, ignoreFollowUp = true): TurnMove | undefined {
return this.getLastXMoves(-1).find(m => return this.getLastXMoves(-1).find(
m.move !== Moves.NONE m =>
&& (!ignoreStruggle || m.move !== Moves.STRUGGLE) m.move !== Moves.NONE &&
&& (!isVirtual(m.useType) || (!ignoreStruggle || m.move !== Moves.STRUGGLE) &&
(!ignoreFollowUp && m.useType === MoveUseType.FOLLOW_UP)) (!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); this.summonData.moveQueue.push(queuedMove);
} }
changeForm(formChange: SpeciesFormChange): Promise<void> { changeForm(formChange: SpeciesFormChange): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
this.formIndex = Math.max( this.formIndex = Math.max(
@ -6247,7 +6245,7 @@ export class EnemyPokemon extends Pokemon {
isVirtual(queuedMove.useType) || isVirtual(queuedMove.useType) ||
(moveIndex > -1 && this.getMoveset()[moveIndex].isUsable(this, isIgnorePP(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; return queuedMove;
} }
} }
@ -6258,7 +6256,11 @@ export class EnemyPokemon extends Pokemon {
if (movePool.length) { if (movePool.length) {
// If there's only 1 move in the move pool, use it. // If there's only 1 move in the move pool, use it.
if (movePool.length === 1) { 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. // If a move is forced because of Encore, use it.
// Said moves are executed normally // Said moves are executed normally
@ -6269,7 +6271,7 @@ export class EnemyPokemon extends Pokemon {
return { return {
move: encoreMove.moveId, move: encoreMove.moveId,
targets: this.getNextTargets(encoreMove.moveId), targets: this.getNextTargets(encoreMove.moveId),
useType: MoveUseType.NORMAL useType: MoveUseType.NORMAL,
}; };
} }
} }
@ -6440,15 +6442,17 @@ export class EnemyPokemon extends Pokemon {
r++; 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( console.log(
movePool.map(m => m.getName()), movePool.map(m => m.getName()),
moveScores, moveScores,
r, r,
sortedMovePool.map(m => m.getName()), 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; return ret;
} }
/** /**
* Show or hide the type effectiveness multiplier window * Show or hide the type effectiveness multiplier window
* Passing undefined will hide the 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 { Command } from "#app/ui/command-ui-handler";
import MessageUiHandler from "#app/ui/message-ui-handler"; import MessageUiHandler from "#app/ui/message-ui-handler";
import { UiMode } from "#enums/ui-mode"; 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 { import {
PokemonFormChangeItemModifier, PokemonFormChangeItemModifier,
PokemonHeldItemModifier, PokemonHeldItemModifier,
@ -1165,19 +1165,19 @@ export default class PartyUiHandler extends MessageUiHandler {
this.partyUiMode !== PartyUiMode.FAINT_SWITCH && this.partyUiMode !== PartyUiMode.FAINT_SWITCH &&
globalScene.findModifier( globalScene.findModifier(
m => m =>
m instanceof SwitchEffectTransferModifier && m instanceof SwitchEffectTransferModifier && m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
) )
); );
} }
// TODO: add FORCED_SWITCH (and perhaps also BATON_PASS_SWITCH) to the modes // 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 { private isBatonPassMove(): boolean {
const lastMove: TurnMove | undefined = globalScene.getPlayerField()[this.fieldIndex].getLastXMoves()[0]; const lastMove: TurnMove | undefined = globalScene.getPlayerField()[this.fieldIndex].getLastXMoves()[0];
return ( return (
this.partyUiMode === PartyUiMode.FAINT_SWITCH && 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()
); );
} }