Cleaned up bypass speed checks
This commit is contained in:
parent
1a2d7e88b2
commit
11150254f5
|
@ -4117,19 +4117,16 @@ export class PreventBypassSpeedChanceAbAttr extends AbAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @argument {boolean} bypassSpeed - determines if a Pokemon is able to bypass speed at the moment
|
* @argument {boolean} canBypassSpeed - determines if a Pokemon is able to bypass speed at the moment
|
||||||
* @argument {boolean} canCheckHeldItems - determines if a Pokemon has access to Quick Claw's effects or not
|
|
||||||
*/
|
*/
|
||||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
const bypassSpeed = args[0] as Utils.BooleanHolder;
|
const canBypassSpeed = args[0] as Utils.BooleanHolder;
|
||||||
const canCheckHeldItems = args[1] as Utils.BooleanHolder;
|
|
||||||
|
|
||||||
const turnCommand = pokemon.scene.currentBattle.turnCommands[pokemon.getBattlerIndex()];
|
const turnCommand = pokemon.scene.currentBattle.turnCommands[pokemon.getBattlerIndex()];
|
||||||
const isCommandFight = turnCommand?.command === Command.FIGHT;
|
const isCommandFight = turnCommand?.command === Command.FIGHT;
|
||||||
const move = turnCommand?.move?.move ? allMoves[turnCommand.move.move] : null;
|
const move = turnCommand?.move?.move ? allMoves[turnCommand.move.move] : null;
|
||||||
if (this.condition(pokemon, move!) && isCommandFight) {
|
if (this.condition(pokemon, move!) && isCommandFight) {
|
||||||
bypassSpeed.value = false;
|
canBypassSpeed.value = false;
|
||||||
canCheckHeldItems.value = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2305,21 +2305,6 @@ export class TurnStartPhase extends FieldPhase {
|
||||||
|
|
||||||
orderedTargets = orderedTargets.map(t => t.getFieldIndex() + (!t.isPlayer() ? BattlerIndex.ENEMY : 0));
|
orderedTargets = orderedTargets.map(t => t.getFieldIndex() + (!t.isPlayer() ? BattlerIndex.ENEMY : 0));
|
||||||
|
|
||||||
//The creation of the battlerBypassSpeed object contains checks for the ability Quick Draw and the held item Quick Claw
|
|
||||||
//The ability Mycelium Might disables Quick Claw's activation when using a status move
|
|
||||||
const battlerBypassSpeed = {};
|
|
||||||
|
|
||||||
this.scene.getField(true).filter(p => p.summonData).map(p => {
|
|
||||||
const bypassSpeed = new Utils.BooleanHolder(false);
|
|
||||||
const canCheckHeldItems = new Utils.BooleanHolder(true);
|
|
||||||
applyAbAttrs(BypassSpeedChanceAbAttr, p, null, bypassSpeed);
|
|
||||||
applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, bypassSpeed, canCheckHeldItems);
|
|
||||||
if (canCheckHeldItems.value) {
|
|
||||||
this.scene.applyModifiers(BypassSpeedChanceModifier, p.isPlayer(), p, bypassSpeed);
|
|
||||||
}
|
|
||||||
battlerBypassSpeed[p.getBattlerIndex()] = bypassSpeed;
|
|
||||||
});
|
|
||||||
|
|
||||||
const moveOrder = orderedTargets.slice(0);
|
const moveOrder = orderedTargets.slice(0);
|
||||||
|
|
||||||
moveOrder.sort((a, b) => {
|
moveOrder.sort((a, b) => {
|
||||||
|
@ -2336,7 +2321,7 @@ export class TurnStartPhase extends FieldPhase {
|
||||||
const aMove = allMoves[aCommand.move!.move];//TODO: is the bang correct here?
|
const aMove = allMoves[aCommand.move!.move];//TODO: is the bang correct here?
|
||||||
const bMove = allMoves[bCommand!.move!.move];//TODO: is the bang correct here?
|
const bMove = allMoves[bCommand!.move!.move];//TODO: is the bang correct here?
|
||||||
|
|
||||||
//The game now considers priority
|
//The game now considers priority and checks if IncrementMovePriorityAttr / ChangeMovePriorityAbAttr applies
|
||||||
const aPriority = new Utils.IntegerHolder(aMove.priority);
|
const aPriority = new Utils.IntegerHolder(aMove.priority);
|
||||||
const bPriority = new Utils.IntegerHolder(bMove.priority);
|
const bPriority = new Utils.IntegerHolder(bMove.priority);
|
||||||
|
|
||||||
|
@ -2346,20 +2331,33 @@ export class TurnStartPhase extends FieldPhase {
|
||||||
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority); //TODO: is the bang correct here?
|
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority); //TODO: is the bang correct here?
|
||||||
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority); //TODO: is the bang correct here?
|
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority); //TODO: is the bang correct here?
|
||||||
|
|
||||||
if (aPriority.value !== bPriority.value) {
|
const battlerBypassSpeed = {};
|
||||||
const bracketDifference = Math.ceil(aPriority.value) - Math.ceil(bPriority.value);
|
|
||||||
const hasSpeedDifference = battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value;
|
//If the two moves compared here share the same base priority, the game then determines if the ability Quick Draw / Quick Claw can activate
|
||||||
if (bracketDifference === 0 && hasSpeedDifference) {
|
//The ability Mycelium Might, however, disables Quick Claw if the holder uses a status move.
|
||||||
|
if (Math.ceil(aPriority.value) - Math.ceil(bPriority.value) === 0) {
|
||||||
|
this.scene.getField(true).filter(p => p.summonData).map(p => {
|
||||||
|
const canBypassSpeed = new Utils.BooleanHolder(true);
|
||||||
|
applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, canBypassSpeed);
|
||||||
|
const bypassSpeed = new Utils.BooleanHolder(false);
|
||||||
|
if (canBypassSpeed.value) {
|
||||||
|
applyAbAttrs(BypassSpeedChanceAbAttr, p, null, bypassSpeed);
|
||||||
|
this.scene.applyModifiers(BypassSpeedChanceModifier, p.isPlayer(), p, bypassSpeed);
|
||||||
|
}
|
||||||
|
battlerBypassSpeed[p.getBattlerIndex()] = bypassSpeed;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) {
|
||||||
return battlerBypassSpeed[a].value ? -1 : 1;
|
return battlerBypassSpeed[a].value ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the two moves compared here do not share the same base priority, the game does not consider battlerBypassSpeed
|
||||||
|
if (aPriority.value !== bPriority.value) {
|
||||||
return aPriority.value < bPriority.value ? 1 : -1;
|
return aPriority.value < bPriority.value ? 1 : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) {
|
|
||||||
return battlerBypassSpeed[a].value ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const aIndex = orderedTargets.indexOf(a);
|
const aIndex = orderedTargets.indexOf(a);
|
||||||
const bIndex = orderedTargets.indexOf(b);
|
const bIndex = orderedTargets.indexOf(b);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue