mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-15 12:52:20 +02:00
Fix reviver seed ohko, remove leftover dead code
Co-authored-by: innerthunder <brandonerickson98@gmail.com>
This commit is contained in:
parent
c229e60932
commit
e339d1167a
@ -1504,7 +1504,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
* @returns The given move's final category
|
* @returns The given move's final category
|
||||||
*/
|
*/
|
||||||
getMoveCategory(target: Pokemon, move: Move): MoveCategory {
|
getMoveCategory(target: Pokemon, move: Move): MoveCategory {
|
||||||
const moveCategory = new Utils.NumberHolder(move.category);
|
const moveCategory = new NumberHolder(move.category);
|
||||||
applyMoveAttrs(VariableMoveCategoryAttr, this, target, move, moveCategory);
|
applyMoveAttrs(VariableMoveCategoryAttr, this, target, move, moveCategory);
|
||||||
return moveCategory.value;
|
return moveCategory.value;
|
||||||
}
|
}
|
||||||
|
@ -35,19 +35,19 @@ import { BattlerTagType } from "#enums/battler-tag-type";
|
|||||||
|
|
||||||
export class FaintPhase extends PokemonPhase {
|
export class FaintPhase extends PokemonPhase {
|
||||||
/**
|
/**
|
||||||
* Whether or not enduring (for this phase's purposes, Reviver Seed) should be prevented
|
* Whether or not instant revive should be prevented
|
||||||
*/
|
*/
|
||||||
private preventEndure: boolean;
|
private preventInstantRevive: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The source Pokemon that dealt fatal damage
|
* The source Pokemon that dealt fatal damage
|
||||||
*/
|
*/
|
||||||
private source?: Pokemon;
|
private source?: Pokemon;
|
||||||
|
|
||||||
constructor(battlerIndex: BattlerIndex, preventEndure = false, source?: Pokemon) {
|
constructor(battlerIndex: BattlerIndex, preventInstantRevive = false, source?: Pokemon) {
|
||||||
super(battlerIndex);
|
super(battlerIndex);
|
||||||
|
|
||||||
this.preventEndure = preventEndure;
|
this.preventInstantRevive = preventInstantRevive;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ export class FaintPhase extends PokemonPhase {
|
|||||||
|
|
||||||
faintPokemon.resetSummonData();
|
faintPokemon.resetSummonData();
|
||||||
|
|
||||||
if (!this.preventEndure) {
|
if (!this.preventInstantRevive) {
|
||||||
const instantReviveModifier = globalScene.applyModifier(
|
const instantReviveModifier = globalScene.applyModifier(
|
||||||
PokemonInstantReviveModifier,
|
PokemonInstantReviveModifier,
|
||||||
this.player,
|
this.player,
|
||||||
|
@ -239,6 +239,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
break;
|
break;
|
||||||
case HitCheckResult.REFLECTED:
|
case HitCheckResult.REFLECTED:
|
||||||
this.queueReflectedMove(user, target);
|
this.queueReflectedMove(user, target);
|
||||||
|
break;
|
||||||
case HitCheckResult.PENDING:
|
case HitCheckResult.PENDING:
|
||||||
case HitCheckResult.ERROR:
|
case HitCheckResult.ERROR:
|
||||||
throw new Error("Unexpected hit check result");
|
throw new Error("Unexpected hit check result");
|
||||||
@ -253,7 +254,8 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
const user = this.getUserPokemon();
|
const user = this.getUserPokemon();
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return super.end();
|
super.end();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If an enemy used this move, set this as last enemy that used move or ability */
|
/** If an enemy used this move, set this as last enemy that used move or ability */
|
||||||
@ -267,7 +269,8 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
/** If the user was somehow removed from the field and it's not a delayed attack, end this phase */
|
/** If the user was somehow removed from the field and it's not a delayed attack, end this phase */
|
||||||
if (!user.isOnField()) {
|
if (!user.isOnField()) {
|
||||||
if (!isDelayedAttack) {
|
if (!isDelayedAttack) {
|
||||||
return super.end();
|
super.end();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!user.scene) {
|
if (!user.scene) {
|
||||||
/*
|
/*
|
||||||
@ -275,7 +278,8 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
* on the turn the attack would have triggered. Having access to the global scene
|
* on the turn the attack would have triggered. Having access to the global scene
|
||||||
* in the future may solve this entirely, so for now we just cancel the hit
|
* in the future may solve this entirely, so for now we just cancel the hit
|
||||||
*/
|
*/
|
||||||
return super.end();
|
super.end();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (isNullOrUndefined(user.turnData)) {
|
if (isNullOrUndefined(user.turnData)) {
|
||||||
user.resetTurnData();
|
user.resetTurnData();
|
||||||
@ -370,7 +374,6 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
* Callback to be called after the move animation is played
|
* Callback to be called after the move animation is played
|
||||||
*/
|
*/
|
||||||
private postAnimCallback(user: Pokemon, targets: Pokemon[]) {
|
private postAnimCallback(user: Pokemon, targets: Pokemon[]) {
|
||||||
console.log("============Inside post anim callback======");
|
|
||||||
// Add to the move history entry
|
// Add to the move history entry
|
||||||
if (this.firstHit) {
|
if (this.firstHit) {
|
||||||
user.pushMoveHistory(this.moveHistoryEntry);
|
user.pushMoveHistory(this.moveHistoryEntry);
|
||||||
@ -382,6 +385,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(e.message || "Unexpected error in move effect phase");
|
console.warn(e.message || "Unexpected error in move effect phase");
|
||||||
this.end();
|
this.end();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Apply queued phases
|
// Apply queued phases
|
||||||
if (this.queuedPhases.length) {
|
if (this.queuedPhases.length) {
|
||||||
@ -429,82 +433,6 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
super.end();
|
super.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply self-targeted effects that trigger `POST_APPLY`
|
|
||||||
*
|
|
||||||
* @param user - The {@linkcode Pokemon} using this phase's invoked move
|
|
||||||
* @param target - {@linkcode Pokemon} the current target of this phase's invoked move
|
|
||||||
* @param firstHit - `true` if this is the first hit in a multi-hit attack
|
|
||||||
* @param lastHit - `true` if this is the last hit in a multi-hit attack
|
|
||||||
* @returns a function intended to be passed into a `then()` call.
|
|
||||||
*/
|
|
||||||
protected applySelfTargetEffects(user: Pokemon, target: Pokemon, firstHit: boolean, lastHit: boolean): void {
|
|
||||||
applyFilteredMoveAttrs(
|
|
||||||
(attr: MoveAttr) =>
|
|
||||||
attr instanceof MoveEffectAttr &&
|
|
||||||
attr.trigger === MoveEffectTrigger.POST_APPLY &&
|
|
||||||
attr.selfTarget &&
|
|
||||||
(!attr.firstHitOnly || firstHit) &&
|
|
||||||
(!attr.lastHitOnly || lastHit),
|
|
||||||
user,
|
|
||||||
target,
|
|
||||||
this.move,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies non-self-targeted effects that trigger `POST_APPLY`
|
|
||||||
* (i.e. Smelling Salts curing Paralysis, and the forced switch from U-Turn, Dragon Tail, etc)
|
|
||||||
* @param user - The {@linkcode Pokemon} using this phase's invoked move
|
|
||||||
* @param target - {@linkcode Pokemon} the current target of this phase's invoked move
|
|
||||||
* @param firstHit - `true` if this is the first hit in a multi-hit attack
|
|
||||||
* @param lastHit - `true` if this is the last hit in a multi-hit attack
|
|
||||||
* @returns a function intended to be passed into a `then()` call.
|
|
||||||
*/
|
|
||||||
protected applyPostApplyEffects(user: Pokemon, target: Pokemon, firstHit: boolean, lastHit: boolean): void {
|
|
||||||
applyFilteredMoveAttrs(
|
|
||||||
(attr: MoveAttr) =>
|
|
||||||
attr instanceof MoveEffectAttr &&
|
|
||||||
attr.trigger === MoveEffectTrigger.POST_APPLY &&
|
|
||||||
!attr.selfTarget &&
|
|
||||||
(!attr.firstHitOnly || firstHit) &&
|
|
||||||
(!attr.lastHitOnly || lastHit),
|
|
||||||
user,
|
|
||||||
target,
|
|
||||||
this.move,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies effects that trigger on HIT
|
|
||||||
* (i.e. Final Gambit, Power-Up Punch, Drain Punch)
|
|
||||||
* @param user - The {@linkcode Pokemon} using this phase's invoked move
|
|
||||||
* @param target - {@linkcode Pokemon} the current target of this phase's invoked move
|
|
||||||
* @param firstHit - `true` if this is the first hit in a multi-hit attack
|
|
||||||
* @param lastHit - `true` if this is the last hit in a multi-hit attack
|
|
||||||
* @param firstTarget - `true` if {@linkcode target} is the first target hit by this strike of {@linkcode move}
|
|
||||||
* @returns a function intended to be passed into a `then()` call.
|
|
||||||
*/
|
|
||||||
protected applyOnHitEffects(
|
|
||||||
user: Pokemon,
|
|
||||||
target: Pokemon,
|
|
||||||
firstHit: boolean,
|
|
||||||
lastHit: boolean,
|
|
||||||
firstTarget: boolean,
|
|
||||||
): void {
|
|
||||||
applyFilteredMoveAttrs(
|
|
||||||
(attr: MoveAttr) =>
|
|
||||||
attr instanceof MoveEffectAttr &&
|
|
||||||
attr.trigger === MoveEffectTrigger.HIT &&
|
|
||||||
(!attr.firstHitOnly || firstHit) &&
|
|
||||||
(!attr.lastHitOnly || lastHit) &&
|
|
||||||
(!attr.firstTargetOnly || firstTarget),
|
|
||||||
user,
|
|
||||||
target,
|
|
||||||
this.move,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies reactive effects that occur when a Pokémon is hit.
|
* Applies reactive effects that occur when a Pokémon is hit.
|
||||||
* (i.e. Effect Spore, Disguise, Liquid Ooze, Beak Blast)
|
* (i.e. Effect Spore, Disguise, Liquid Ooze, Beak Blast)
|
||||||
@ -513,51 +441,9 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
* @param hitResult - The {@linkcode HitResult} of the attempted move
|
* @param hitResult - The {@linkcode HitResult} of the attempted move
|
||||||
* @returns a `Promise` intended to be passed into a `then()` call.
|
* @returns a `Promise` intended to be passed into a `then()` call.
|
||||||
*/
|
*/
|
||||||
protected applyOnGetHitAbEffects(user: Pokemon, target: Pokemon, hitResult: HitResult) {
|
protected applyOnGetHitAbEffects(user: Pokemon, target: Pokemon, hitResult: HitResult): void {
|
||||||
const hitsSubstitute = this.move.hitsSubstitute(user, target);
|
applyPostDefendAbAttrs(PostDefendAbAttr, target, user, this.move, hitResult);
|
||||||
if (!target.isFainted() || target.canApplyAbility()) {
|
target.lapseTags(BattlerTagLapseType.AFTER_HIT);
|
||||||
applyPostDefendAbAttrs(PostDefendAbAttr, target, user, this.move, hitResult);
|
|
||||||
|
|
||||||
if (!this.move.hitsSubstitute(user, target)) {
|
|
||||||
if (!user.isPlayer() && this.move instanceof AttackMove) {
|
|
||||||
globalScene.applyShuffledModifiers(EnemyAttackStatusEffectChanceModifier, false, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hitsSubstitute) {
|
|
||||||
target.lapseTags(BattlerTagLapseType.AFTER_HIT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies all effects and attributes that require a move to connect with a target,
|
|
||||||
* namely reactive effects like Weak Armor, on-hit effects like that of Power-Up Punch, and item stealing effects
|
|
||||||
* @param user - The {@linkcode Pokemon} using this phase's invoked move
|
|
||||||
* @param target - {@linkcode Pokemon} the current target of this phase's invoked move
|
|
||||||
* @param firstHit - `true` if this is the first hit in a multi-hit attack
|
|
||||||
* @param lastHit - `true` if this is the last hit in a multi-hit attack
|
|
||||||
* @param isProtected - `true` if the target is protected by effects such as Protect
|
|
||||||
* @param hitResult - The {@linkcode HitResult} of the attempted move
|
|
||||||
* @param firstTarget - `true` if {@linkcode target} is the first target hit by this strike of {@linkcode move}
|
|
||||||
* @returns a function intended to be passed into a `then()` call.
|
|
||||||
*/
|
|
||||||
protected applySuccessfulAttackEffects(
|
|
||||||
user: Pokemon,
|
|
||||||
target: Pokemon,
|
|
||||||
firstHit: boolean,
|
|
||||||
lastHit: boolean,
|
|
||||||
isProtected: boolean,
|
|
||||||
hitResult: HitResult,
|
|
||||||
firstTarget: boolean,
|
|
||||||
): void {
|
|
||||||
if (!isProtected) {
|
|
||||||
this.applyOnHitEffects(user, target, firstHit, lastHit, firstTarget);
|
|
||||||
this.applyOnGetHitAbEffects(user, target, hitResult);
|
|
||||||
applyPostAttackAbAttrs(PostAttackAbAttr, user, target, this.move, hitResult);
|
|
||||||
if (this.move instanceof AttackMove && hitResult !== HitResult.STATUS) {
|
|
||||||
globalScene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -672,7 +558,6 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fieldTargeted && this.protectedCheck(user, target)) {
|
if (!fieldTargeted && this.protectedCheck(user, target)) {
|
||||||
console.log("====== Protected ========");
|
|
||||||
return [HitCheckResult.PROTECTED, 0];
|
return [HitCheckResult.PROTECTED, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,7 +567,6 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
|
|
||||||
// After the magic bounce check, field targeted moves are always successful
|
// After the magic bounce check, field targeted moves are always successful
|
||||||
if (fieldTargeted) {
|
if (fieldTargeted) {
|
||||||
console.log("====== Field targeted moves overriding hit check ========");
|
|
||||||
return [HitCheckResult.HIT, 1];
|
return [HitCheckResult.HIT, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,12 +908,12 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
* Sub-method of {@linkcode applyMove} that handles the event of a target fainting.
|
* Sub-method of {@linkcode applyMove} that handles the event of a target fainting.
|
||||||
* @param user - The {@linkcode Pokemon} using this phase's invoked move
|
* @param user - The {@linkcode Pokemon} using this phase's invoked move
|
||||||
* @param target - The {@linkcode Pokemon} that fainted
|
* @param target - The {@linkcode Pokemon} that fainted
|
||||||
* @param preventEndure - `true` if the endure effect should be prevented
|
|
||||||
*/
|
*/
|
||||||
protected onFaintTarget(user: Pokemon, target: Pokemon, preventEndure: boolean): void {
|
protected onFaintTarget(user: Pokemon, target: Pokemon): void {
|
||||||
// set splice index here, so future scene queues happen before FaintedPhase
|
// set splice index here, so future scene queues happen before FaintedPhase
|
||||||
globalScene.setPhaseQueueSplice();
|
globalScene.setPhaseQueueSplice();
|
||||||
globalScene.unshiftPhase(new FaintPhase(target.getBattlerIndex(), preventEndure, user));
|
|
||||||
|
globalScene.unshiftPhase(new FaintPhase(target.getBattlerIndex(), false, user));
|
||||||
|
|
||||||
target.destroySubstitute();
|
target.destroySubstitute();
|
||||||
target.lapseTag(BattlerTagType.COMMANDED);
|
target.lapseTag(BattlerTagType.COMMANDED);
|
||||||
@ -1077,7 +961,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target.isFainted()) {
|
if (target.isFainted()) {
|
||||||
this.onFaintTarget(user, target, result === HitResult.ONE_HIT_KO);
|
this.onFaintTarget(user, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user