From 62e51093c94620ce0bc1154f47da6c8276871372 Mon Sep 17 00:00:00 2001 From: DustinLin Date: Sun, 12 May 2024 13:05:23 -0400 Subject: [PATCH] fixing messages not appearing for multi-hit moves on faint --- src/battle-scene.ts | 3 ++- src/field/pokemon.ts | 29 +++++++++++++++++------------ src/phases.ts | 9 +++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index da40d850c3a..b9134bc0dfd 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1489,7 +1489,8 @@ export default class BattleScene extends SceneBase { this.phaseQueuePrepend.push(phase); else this.phaseQueuePrepend.splice(this.phaseQueuePrependSpliceIndex, 0, phase); - this.phaseQueuePrepend.forEach(p => console.log(p.constructor.name)) + // debug: printing out phase queue + //this.phaseQueuePrepend.forEach(p => console.log(p.constructor.name)); } clearPhaseQueue(): void { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 1e11058fb9d..c38522a9e1d 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1473,16 +1473,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // requires passing in hitsLeft damage.value = this.damageAndUpdate(damage.value, result as DamageResult, isCritical, oneHitKo, oneHitKo, source.turnData.hitsLeft); this.turnData.damageTaken += damage.value; - // eg: bullet seed 1 shots, double-slap 1 shots, this isbroken right now - if (this.isFainted() && (this.turnData.hitsLeft > 0 || this.turnData.hitCount > 1)) { - // also want to check if it was a multi hit move? - //const hitsTotal = this.turnData.hitCount - Math.max(this.turnData.hitsLeft, 0); - // multi hit move killed early, then queue how many hits were made before - this.scene.queueMessage(i18next.t('battle:attackHitsCount', { count: this.turnData.hitCount})); - } + // hitsLeft: for multi-hit moves, only want to render effectiveness text at end. - // also want to render if opponent is fainting?, or if you are fainting? - if (this.turnData.hitsLeft === 1 || this.isFainted()) { + // also want to render if a pokemon fainted + console.log(`the number of hits left for this turn for ${this.name} is ${source.turnData.hitsLeft}`) + if (source.turnData.hitsLeft === 1 || this.isFainted()) { switch (result as HitResult) { case HitResult.SUPER_EFFECTIVE: this.scene.queueMessage(i18next.t('battle:hitResultSuperEffective')); @@ -1499,8 +1494,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - // forbidden phasequeue splice udpate, idk what happens after this - this.scene.setPhaseQueueSplice(); if (source.isPlayer()) { this.scene.validateAchvs(DamageAchv, damage); if (damage.value > this.scene.gameData.gameStats.highestDamage) @@ -1513,8 +1506,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (source.isPlayer() && !this.isPlayer()) this.scene.applyModifiers(DamageMoneyRewardModifier, true, source, damage) + // case when multi hit move killed early, then queue how many hits were made before + // eg: bullet seed 1 shots, double-slap 1 shots, + // note that simply looking at this.turnData.attacksReceived doesn't work for double battles + if (this.isFainted() && source.turnData.hitsLeft > 0){ + console.log(`${this.name} fainted: they received this many hits: ${this.turnData.attacksReceived.length}`); + // off by one from decrement, test more + const hitsTotal = source.turnData.hitCount - Math.max(source.turnData.hitsLeft, 0) + 1; + this.scene.queueMessage(i18next.t('battle:attackHitsCount', { count: hitsTotal})); + } + + // not sure what this set function is accomplishing, perhaps for the faint phase? it messes up with the queueMessage() + this.scene.setPhaseQueueSplice(); + if (this.isFainted()) { - console.log(`${this.name} is fainting! ${this.turnData.hitCount}, ${this.turnData.hitsLeft}`) this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), oneHitKo)); this.resetSummonData(); } diff --git a/src/phases.ts b/src/phases.ts index b697f7acbc2..b7363287753 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2518,9 +2518,13 @@ export class MoveEffectPhase extends PokemonPhase { if (--user.turnData.hitsLeft >= 1 && this.getTarget()?.isActive()) this.scene.unshiftPhase(this.getNewHitPhase()); else { + // queue message for number of hits made by multi-move + // BUG: when fainting occurs, the resulting message isn't rendered - has to do with FaintPhase + // temp fix in pokemon.ts apply() that checks, but ideally want to fix it here at the source const hitsTotal = user.turnData.hitCount - Math.max(user.turnData.hitsLeft, 0); - if (hitsTotal > 1) + if (hitsTotal > 1 || user.turnData.hitsLeft > 0){ this.scene.queueMessage(i18next.t('battle:attackHitsCount', { count: hitsTotal })); + } this.scene.applyModifiers(HitHealModifier, this.player, user); } } @@ -2985,7 +2989,8 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { } export class MessagePhase extends Phase { - private text: string; + // todo change backlk to private + public text: string; private callbackDelay: integer; private prompt: boolean; private promptDelay: integer;