mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-19 23:02:19 +02:00
Apply biome
This commit is contained in:
parent
45d3035dc1
commit
24614c0a61
@ -1179,7 +1179,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
const lastMove = pokemon.getLastXMoves(1)[0];
|
||||
globalScene.tryReplacePhase(
|
||||
m => m instanceof MovePhase && m.pokemon === pokemon,
|
||||
new MovePhase(pokemon, lastMove.targets ?? [], movesetMove)
|
||||
new MovePhase(pokemon, lastMove.targets ?? [], movesetMove),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,9 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
const ppRestoreMove = pokemon.getMoveset().find(m => !m.getPpRatio()) ? pokemon.getMoveset().find(m => !m.getPpRatio()) : pokemon.getMoveset().find(m => m.getPpRatio() < 1);
|
||||
const ppRestoreMove = pokemon.getMoveset().find(m => !m.getPpRatio())
|
||||
? pokemon.getMoveset().find(m => !m.getPpRatio())
|
||||
: pokemon.getMoveset().find(m => m.getPpRatio() < 1);
|
||||
if (ppRestoreMove !== undefined) {
|
||||
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
|
||||
globalScene.queueMessage(
|
||||
|
@ -818,7 +818,11 @@ async function addEggMoveToNewPokemonMoveset(
|
||||
* @param newPokemonGeneratedMoveset
|
||||
* @param newEggMoveIndex
|
||||
*/
|
||||
function addFavoredMoveToNewPokemonMoveset(newPokemon: PlayerPokemon, newPokemonGeneratedMoveset: (PokemonMove)[], newEggMoveIndex: number | null) {
|
||||
function addFavoredMoveToNewPokemonMoveset(
|
||||
newPokemon: PlayerPokemon,
|
||||
newPokemonGeneratedMoveset: PokemonMove[],
|
||||
newEggMoveIndex: number | null,
|
||||
) {
|
||||
let favoredMove: PokemonMove | null = null;
|
||||
for (const move of newPokemonGeneratedMoveset) {
|
||||
// Needs to match first type, second type will be replaced
|
||||
|
@ -573,19 +573,22 @@ export class MoveRequirement extends EncounterPokemonRequirement {
|
||||
override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] {
|
||||
if (!this.invertQuery) {
|
||||
// get the Pokemon with at least one move in the required moves list
|
||||
return partyPokemon.filter((pokemon) =>
|
||||
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle())
|
||||
&& pokemon.moveset.some((move) => move.moveId && this.requiredMoves.includes(move.moveId)));
|
||||
} else {
|
||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed moves
|
||||
return partyPokemon.filter((pokemon) =>
|
||||
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle())
|
||||
&& !pokemon.moveset.some((move) => move.moveId && this.requiredMoves.includes(move.moveId)));
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) &&
|
||||
pokemon.moveset.some(move => move.moveId && this.requiredMoves.includes(move.moveId)),
|
||||
);
|
||||
}
|
||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed moves
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) &&
|
||||
!pokemon.moveset.some(move => move.moveId && this.requiredMoves.includes(move.moveId)),
|
||||
);
|
||||
}
|
||||
|
||||
override getDialogueToken(pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedMoves = pokemon?.moveset.filter((move) => move.moveId && this.requiredMoves.includes(move.moveId));
|
||||
const includedMoves = pokemon?.moveset.filter(move => move.moveId && this.requiredMoves.includes(move.moveId));
|
||||
if (includedMoves && includedMoves.length > 0 && includedMoves[0]) {
|
||||
return ["move", includedMoves[0].getName()];
|
||||
}
|
||||
@ -620,15 +623,26 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement {
|
||||
|
||||
override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] {
|
||||
if (!this.invertQuery) {
|
||||
return partyPokemon.filter((pokemon) => this.requiredMoves.filter((learnableMove) => pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(learnableMove)).length > 0);
|
||||
} else {
|
||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed learnableMoves
|
||||
return partyPokemon.filter((pokemon) => this.requiredMoves.filter((learnableMove) => pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(learnableMove)).length === 0);
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
this.requiredMoves.filter(learnableMove =>
|
||||
pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(learnableMove),
|
||||
).length > 0,
|
||||
);
|
||||
}
|
||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed learnableMoves
|
||||
return partyPokemon.filter(
|
||||
pokemon =>
|
||||
this.requiredMoves.filter(learnableMove =>
|
||||
pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(learnableMove),
|
||||
).length === 0,
|
||||
);
|
||||
}
|
||||
|
||||
override getDialogueToken(pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedCompatMoves = this.requiredMoves.filter((reqMove) => pokemon?.compatibleTms.filter((tm) => !pokemon.moveset.find(m => m.moveId === tm)).includes(reqMove));
|
||||
const includedCompatMoves = this.requiredMoves.filter(reqMove =>
|
||||
pokemon?.compatibleTms.filter(tm => !pokemon.moveset.find(m => m.moveId === tm)).includes(reqMove),
|
||||
);
|
||||
if (includedCompatMoves.length > 0) {
|
||||
return ["compatibleMove", Moves[includedCompatMoves[0]]];
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ export class SpeciesFormChangeMoveLearnedTrigger extends SpeciesFormChangeTrigge
|
||||
}
|
||||
|
||||
canChange(pokemon: Pokemon): boolean {
|
||||
return (!!pokemon.moveset.filter(m => m.moveId === this.move).length) === this.known;
|
||||
return !!pokemon.moveset.filter(m => m.moveId === this.move).length === this.known;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,10 @@ export class TmModifierType extends PokemonModifierType {
|
||||
`tm_${PokemonType[allMoves[moveId].type].toLowerCase()}`,
|
||||
(_type, args) => new TmModifier(this, (args[0] as PlayerPokemon).id),
|
||||
(pokemon: PlayerPokemon) => {
|
||||
if (pokemon.compatibleTms.indexOf(moveId) === -1 || pokemon.getMoveset().filter(m => m.moveId === moveId).length) {
|
||||
if (
|
||||
pokemon.compatibleTms.indexOf(moveId) === -1 ||
|
||||
pokemon.getMoveset().filter(m => m.moveId === moveId).length
|
||||
) {
|
||||
return PartyUiHandler.NoEffectMessage;
|
||||
}
|
||||
return null;
|
||||
@ -1327,7 +1330,13 @@ class AttackTypeBoosterModifierTypeGenerator extends ModifierTypeGenerator {
|
||||
return new AttackTypeBoosterModifierType(pregenArgs[0] as PokemonType, 20);
|
||||
}
|
||||
|
||||
const attackMoveTypes = party.map(p => p.getMoveset().map(m => m.getMove()).filter(m => m instanceof AttackMove).map(m => m.type)).flat();
|
||||
const attackMoveTypes = party.flatMap(p =>
|
||||
p
|
||||
.getMoveset()
|
||||
.map(m => m.getMove())
|
||||
.filter(m => m instanceof AttackMove)
|
||||
.map(m => m.type),
|
||||
);
|
||||
if (!attackMoveTypes.length) {
|
||||
return null;
|
||||
}
|
||||
@ -1519,7 +1528,9 @@ class TmModifierTypeGenerator extends ModifierTypeGenerator {
|
||||
}
|
||||
const partyMemberCompatibleTms = party.map(p => {
|
||||
const previousLevelMoves = p.getLearnableLevelMoves();
|
||||
return (p as PlayerPokemon).compatibleTms.filter(tm => !p.moveset.find(m => m.moveId === tm) && !previousLevelMoves.find(lm=>lm === tm));
|
||||
return (p as PlayerPokemon).compatibleTms.filter(
|
||||
tm => !p.moveset.find(m => m.moveId === tm) && !previousLevelMoves.find(lm => lm === tm),
|
||||
);
|
||||
});
|
||||
const tierUniqueCompatibleTms = partyMemberCompatibleTms
|
||||
.flat()
|
||||
@ -2390,24 +2401,66 @@ const modifierPool: ModifierPool = {
|
||||
[ModifierTier.COMMON]: [
|
||||
new WeightedModifierType(modifierTypes.POKEBALL, () => (hasMaximumBalls(PokeballType.POKEBALL) ? 0 : 6), 6),
|
||||
new WeightedModifierType(modifierTypes.RARE_CANDY, 2),
|
||||
new WeightedModifierType(modifierTypes.POTION, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875) && !p.isFainted()).length, 3);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
}, 9),
|
||||
new WeightedModifierType(modifierTypes.SUPER_POTION, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75) && !p.isFainted()).length, 3);
|
||||
return thresholdPartyMemberCount;
|
||||
}, 3),
|
||||
new WeightedModifierType(modifierTypes.ETHER, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
|
||||
&& p.getMoveset().filter(m => m.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
}, 9),
|
||||
new WeightedModifierType(modifierTypes.MAX_ETHER, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
|
||||
&& p.getMoveset().filter(m => m.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
|
||||
return thresholdPartyMemberCount;
|
||||
}, 3),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.POTION,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(p => p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875 && !p.isFainted()).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
},
|
||||
9,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.SUPER_POTION,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(p => p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75 && !p.isFainted()).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount;
|
||||
},
|
||||
3,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.ETHER,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(
|
||||
p =>
|
||||
p.hp &&
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
},
|
||||
9,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.MAX_ETHER,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(
|
||||
p =>
|
||||
p.hp &&
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount;
|
||||
},
|
||||
3,
|
||||
),
|
||||
new WeightedModifierType(modifierTypes.LURE, lureWeightFunc(10, 2)),
|
||||
new WeightedModifierType(modifierTypes.TEMP_STAT_STAGE_BOOSTER, 4),
|
||||
new WeightedModifierType(modifierTypes.BERRY, 2),
|
||||
@ -2419,54 +2472,136 @@ const modifierPool: ModifierPool = {
|
||||
[ModifierTier.GREAT]: [
|
||||
new WeightedModifierType(modifierTypes.GREAT_BALL, () => (hasMaximumBalls(PokeballType.GREAT_BALL) ? 0 : 6), 6),
|
||||
new WeightedModifierType(modifierTypes.PP_UP, 2),
|
||||
new WeightedModifierType(modifierTypes.FULL_HEAL, (party: Pokemon[]) => {
|
||||
const statusEffectPartyMemberCount = Math.min(party.filter(p => p.hp && !!p.status && !p.getHeldItems().some(i => {
|
||||
if (i instanceof TurnStatusEffectModifier) {
|
||||
return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect;
|
||||
}
|
||||
return false;
|
||||
})).length, 3);
|
||||
return statusEffectPartyMemberCount * 6;
|
||||
}, 18),
|
||||
new WeightedModifierType(modifierTypes.REVIVE, (party: Pokemon[]) => {
|
||||
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
||||
return faintedPartyMemberCount * 9;
|
||||
}, 27),
|
||||
new WeightedModifierType(modifierTypes.MAX_REVIVE, (party: Pokemon[]) => {
|
||||
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
||||
return faintedPartyMemberCount * 3;
|
||||
}, 9),
|
||||
new WeightedModifierType(modifierTypes.SACRED_ASH, (party: Pokemon[]) => {
|
||||
return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0;
|
||||
}, 1),
|
||||
new WeightedModifierType(modifierTypes.HYPER_POTION, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625) && !p.isFainted()).length, 3);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
}, 9),
|
||||
new WeightedModifierType(modifierTypes.MAX_POTION, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3);
|
||||
return thresholdPartyMemberCount;
|
||||
}, 3),
|
||||
new WeightedModifierType(modifierTypes.FULL_RESTORE, (party: Pokemon[]) => {
|
||||
const statusEffectPartyMemberCount = Math.min(party.filter(p => p.hp && !!p.status && !p.getHeldItems().some(i => {
|
||||
if (i instanceof TurnStatusEffectModifier) {
|
||||
return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect;
|
||||
}
|
||||
return false;
|
||||
})).length, 3);
|
||||
const thresholdPartyMemberCount = Math.floor((Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3) + statusEffectPartyMemberCount) / 2);
|
||||
return thresholdPartyMemberCount;
|
||||
}, 3),
|
||||
new WeightedModifierType(modifierTypes.ELIXIR, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
|
||||
&& p.getMoveset().filter(m => m.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
}, 9),
|
||||
new WeightedModifierType(modifierTypes.MAX_ELIXIR, (party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
|
||||
&& p.getMoveset().filter(m => m.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
|
||||
return thresholdPartyMemberCount;
|
||||
}, 3),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.FULL_HEAL,
|
||||
(party: Pokemon[]) => {
|
||||
const statusEffectPartyMemberCount = Math.min(
|
||||
party.filter(
|
||||
p =>
|
||||
p.hp &&
|
||||
!!p.status &&
|
||||
!p.getHeldItems().some(i => {
|
||||
if (i instanceof TurnStatusEffectModifier) {
|
||||
return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect;
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
).length,
|
||||
3,
|
||||
);
|
||||
return statusEffectPartyMemberCount * 6;
|
||||
},
|
||||
18,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.REVIVE,
|
||||
(party: Pokemon[]) => {
|
||||
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
||||
return faintedPartyMemberCount * 9;
|
||||
},
|
||||
27,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.MAX_REVIVE,
|
||||
(party: Pokemon[]) => {
|
||||
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
||||
return faintedPartyMemberCount * 3;
|
||||
},
|
||||
9,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.SACRED_ASH,
|
||||
(party: Pokemon[]) => {
|
||||
return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0;
|
||||
},
|
||||
1,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.HYPER_POTION,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625 && !p.isFainted()).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
},
|
||||
9,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.MAX_POTION,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount;
|
||||
},
|
||||
3,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.FULL_RESTORE,
|
||||
(party: Pokemon[]) => {
|
||||
const statusEffectPartyMemberCount = Math.min(
|
||||
party.filter(
|
||||
p =>
|
||||
p.hp &&
|
||||
!!p.status &&
|
||||
!p.getHeldItems().some(i => {
|
||||
if (i instanceof TurnStatusEffectModifier) {
|
||||
return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect;
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
).length,
|
||||
3,
|
||||
);
|
||||
const thresholdPartyMemberCount = Math.floor(
|
||||
(Math.min(party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, 3) +
|
||||
statusEffectPartyMemberCount) /
|
||||
2,
|
||||
);
|
||||
return thresholdPartyMemberCount;
|
||||
},
|
||||
3,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.ELIXIR,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(
|
||||
p =>
|
||||
p.hp &&
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount * 3;
|
||||
},
|
||||
9,
|
||||
),
|
||||
new WeightedModifierType(
|
||||
modifierTypes.MAX_ELIXIR,
|
||||
(party: Pokemon[]) => {
|
||||
const thresholdPartyMemberCount = Math.min(
|
||||
party.filter(
|
||||
p =>
|
||||
p.hp &&
|
||||
!p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) &&
|
||||
p
|
||||
.getMoveset()
|
||||
.filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2))
|
||||
.length,
|
||||
).length,
|
||||
3,
|
||||
);
|
||||
return thresholdPartyMemberCount;
|
||||
},
|
||||
3,
|
||||
),
|
||||
new WeightedModifierType(modifierTypes.DIRE_HIT, 4),
|
||||
new WeightedModifierType(modifierTypes.SUPER_LURE, lureWeightFunc(15, 4)),
|
||||
new WeightedModifierType(modifierTypes.NUGGET, skipInLastClassicWaveOrDefault(5)),
|
||||
|
@ -99,9 +99,19 @@ export class CommandPhase extends FieldPhase {
|
||||
|
||||
const moveQueue = playerPokemon.getMoveQueue();
|
||||
|
||||
while (moveQueue.length && moveQueue[0]
|
||||
&& moveQueue[0].move && !moveQueue[0].virtual && (!playerPokemon.getMoveset().find(m => m.moveId === moveQueue[0].move)
|
||||
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m.moveId === moveQueue[0].move)].isUsable(playerPokemon, moveQueue[0].ignorePP))) {
|
||||
while (
|
||||
moveQueue.length &&
|
||||
moveQueue[0] &&
|
||||
moveQueue[0].move &&
|
||||
!moveQueue[0].virtual &&
|
||||
(!playerPokemon.getMoveset().find(m => m.moveId === moveQueue[0].move) ||
|
||||
!playerPokemon
|
||||
.getMoveset()
|
||||
[playerPokemon.getMoveset().findIndex(m => m.moveId === moveQueue[0].move)].isUsable(
|
||||
playerPokemon,
|
||||
moveQueue[0].ignorePP,
|
||||
))
|
||||
) {
|
||||
moveQueue.shift();
|
||||
}
|
||||
|
||||
@ -111,7 +121,10 @@ export class CommandPhase extends FieldPhase {
|
||||
this.handleCommand(Command.FIGHT, -1);
|
||||
} else {
|
||||
const moveIndex = playerPokemon.getMoveset().findIndex(m => m.moveId === queuedMove.move);
|
||||
if ((moveIndex > -1 && playerPokemon.getMoveset()[moveIndex].isUsable(playerPokemon, queuedMove.ignorePP)) || queuedMove.virtual) {
|
||||
if (
|
||||
(moveIndex > -1 && playerPokemon.getMoveset()[moveIndex].isUsable(playerPokemon, queuedMove.ignorePP)) ||
|
||||
queuedMove.virtual
|
||||
) {
|
||||
this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, queuedMove);
|
||||
} else {
|
||||
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
@ -138,11 +151,12 @@ export class CommandPhase extends FieldPhase {
|
||||
case Command.TERA:
|
||||
case Command.FIGHT:
|
||||
let useStruggle = false;
|
||||
const turnMove: TurnMove | undefined = (args.length === 2 ? (args[1] as TurnMove) : undefined);
|
||||
if (cursor === -1 ||
|
||||
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
|
||||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)) {
|
||||
|
||||
const turnMove: TurnMove | undefined = args.length === 2 ? (args[1] as TurnMove) : undefined;
|
||||
if (
|
||||
cursor === -1 ||
|
||||
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
|
||||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)
|
||||
) {
|
||||
let moveId: Moves;
|
||||
if (useStruggle) {
|
||||
moveId = Moves.STRUGGLE;
|
||||
@ -181,7 +195,11 @@ export class CommandPhase extends FieldPhase {
|
||||
}
|
||||
if (turnCommand.move && (moveTargets.targets.length <= 1 || moveTargets.multiple)) {
|
||||
turnCommand.move.targets = moveTargets.targets;
|
||||
} else if (turnCommand.move && playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) {
|
||||
} else if (
|
||||
turnCommand.move &&
|
||||
playerPokemon.getTag(BattlerTagType.CHARGING) &&
|
||||
playerPokemon.getMoveQueue().length >= 1
|
||||
) {
|
||||
turnCommand.move.targets = playerPokemon.getMoveQueue()[0].targets;
|
||||
} else {
|
||||
globalScene.unshiftPhase(new SelectTargetPhase(this.fieldIndex));
|
||||
|
@ -177,7 +177,9 @@ export class TurnStartPhase extends FieldPhase {
|
||||
if (!queuedMove) {
|
||||
continue;
|
||||
}
|
||||
const move = pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) || new PokemonMove(queuedMove.move);
|
||||
const move =
|
||||
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ||
|
||||
new PokemonMove(queuedMove.move);
|
||||
if (move.getMove().hasAttr(MoveHeaderAttr)) {
|
||||
globalScene.unshiftPhase(new MoveHeaderPhase(pokemon, move));
|
||||
}
|
||||
|
@ -284,17 +284,29 @@ export default class GameManager {
|
||||
* @param movePosition The index of the move in the pokemon's moveset array
|
||||
*/
|
||||
selectTarget(movePosition: number, targetIndex?: BattlerIndex) {
|
||||
this.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
|
||||
const handler = this.scene.ui.getHandler() as TargetSelectUiHandler;
|
||||
const move = (this.scene.getCurrentPhase() as SelectTargetPhase).getPokemon().getMoveset()[movePosition].getMove();
|
||||
if (!move.isMultiTarget()) {
|
||||
handler.setCursor(targetIndex !== undefined ? targetIndex : BattlerIndex.ENEMY);
|
||||
}
|
||||
if (move.isMultiTarget() && targetIndex !== undefined) {
|
||||
throw new Error(`targetIndex was passed to selectMove() but move ("${move.name}") is not targetted`);
|
||||
}
|
||||
handler.processInput(Button.ACTION);
|
||||
}, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(MovePhase) || this.isCurrentPhase(TurnStartPhase) || this.isCurrentPhase(TurnEndPhase));
|
||||
this.onNextPrompt(
|
||||
"SelectTargetPhase",
|
||||
Mode.TARGET_SELECT,
|
||||
() => {
|
||||
const handler = this.scene.ui.getHandler() as TargetSelectUiHandler;
|
||||
const move = (this.scene.getCurrentPhase() as SelectTargetPhase)
|
||||
.getPokemon()
|
||||
.getMoveset()
|
||||
[movePosition].getMove();
|
||||
if (!move.isMultiTarget()) {
|
||||
handler.setCursor(targetIndex !== undefined ? targetIndex : BattlerIndex.ENEMY);
|
||||
}
|
||||
if (move.isMultiTarget() && targetIndex !== undefined) {
|
||||
throw new Error(`targetIndex was passed to selectMove() but move ("${move.name}") is not targetted`);
|
||||
}
|
||||
handler.processInput(Button.ACTION);
|
||||
},
|
||||
() =>
|
||||
this.isCurrentPhase(CommandPhase) ||
|
||||
this.isCurrentPhase(MovePhase) ||
|
||||
this.isCurrentPhase(TurnStartPhase) ||
|
||||
this.isCurrentPhase(TurnEndPhase),
|
||||
);
|
||||
}
|
||||
|
||||
/** Faint all opponents currently on the field */
|
||||
|
@ -99,7 +99,7 @@ export function waitUntil(truth): Promise<unknown> {
|
||||
export function getMovePosition(scene: BattleScene, pokemonIndex: 0 | 1, move: Moves): number {
|
||||
const playerPokemon = scene.getPlayerField()[pokemonIndex];
|
||||
const moveSet = playerPokemon.getMoveset();
|
||||
const index = moveSet.findIndex((m) => m.moveId === move && m.ppUsed < m.getMovePp());
|
||||
const index = moveSet.findIndex(m => m.moveId === move && m.ppUsed < m.getMovePp());
|
||||
console.log(`Move position for ${Moves[move]} (=${move}):`, index);
|
||||
return index;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user