From 11150254f568b8575211693919c9c5deeb3d8dcd Mon Sep 17 00:00:00 2001 From: Frutescens Date: Tue, 13 Aug 2024 21:01:35 -0700 Subject: [PATCH] Cleaned up bypass speed checks --- src/data/ability.ts | 9 +++------ src/phases.ts | 46 ++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 7e270f4d3f2..3920a3c2cbb 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -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} canCheckHeldItems - determines if a Pokemon has access to Quick Claw's effects or not + * @argument {boolean} canBypassSpeed - determines if a Pokemon is able to bypass speed at the moment */ apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - const bypassSpeed = args[0] as Utils.BooleanHolder; - const canCheckHeldItems = args[1] as Utils.BooleanHolder; + const canBypassSpeed = args[0] as Utils.BooleanHolder; const turnCommand = pokemon.scene.currentBattle.turnCommands[pokemon.getBattlerIndex()]; const isCommandFight = turnCommand?.command === Command.FIGHT; const move = turnCommand?.move?.move ? allMoves[turnCommand.move.move] : null; if (this.condition(pokemon, move!) && isCommandFight) { - bypassSpeed.value = false; - canCheckHeldItems.value = false; + canBypassSpeed.value = false; return false; } return true; diff --git a/src/phases.ts b/src/phases.ts index 083e9d4338e..90ea6ef8b38 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2305,21 +2305,6 @@ export class TurnStartPhase extends FieldPhase { 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); 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 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 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() === b)!, null, bMove, bPriority); //TODO: is the bang correct here? - if (aPriority.value !== bPriority.value) { - const bracketDifference = Math.ceil(aPriority.value) - Math.ceil(bPriority.value); - const hasSpeedDifference = battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value; - if (bracketDifference === 0 && hasSpeedDifference) { + const battlerBypassSpeed = {}; + + //If the two moves compared here share the same base priority, the game then determines if the ability Quick Draw / Quick Claw can activate + //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; } + } + + //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; } } - if (battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) { - return battlerBypassSpeed[a].value ? -1 : 1; - } - const aIndex = orderedTargets.indexOf(a); const bIndex = orderedTargets.indexOf(b);