Added fixes

This commit is contained in:
frutescens 2024-10-01 11:46:40 -07:00
parent 45f6b23309
commit 3feccd792d
3 changed files with 21 additions and 10 deletions

View File

@ -137,9 +137,10 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag {
* Gets whether this tag is restricting a move.
*
* @param {Moves} move {@linkcode Moves} ID to check restriction for.
* @param {Pokemon} user {@linkcode Pokemon} optional parameter for move user
* @returns {boolean} `true` if the move is restricted by this tag, otherwise `false`.
*/
abstract isMoveRestricted(move: Moves): boolean;
abstract isMoveRestricted(move: Moves, user?: Pokemon): boolean;
/**
* Checks if this tag is restricting a move based on a user's decisions during the target selection phase
@ -297,7 +298,15 @@ export class GorillaTacticsTag extends MoveRestrictionBattlerTag {
}
/** @override */
override isMoveRestricted(move: Moves): boolean {
override isMoveRestricted(move: Moves, user: Pokemon): boolean {
if (this.moveId === Moves.NONE) {
const validMove = this.getLastValidMove(user);
if (validMove) {
this.moveId = validMove;
} else {
return true;
}
}
return move !== this.moveId;
}
@ -2482,7 +2491,6 @@ export class MysteryEncounterPostSummonTag extends BattlerTag {
* Torment does not interrupt the move if the move is performed consecutively in the same turn and right after Torment is applied
*/
export class TormentTag extends MoveRestrictionBattlerTag {
private target: Pokemon;
constructor(sourceId: number) {
super(BattlerTagType.TORMENT, BattlerTagLapseType.AFTER_MOVE, 1, Moves.TORMENT, sourceId);
@ -2495,7 +2503,6 @@ export class TormentTag extends MoveRestrictionBattlerTag {
*/
override onAdd(pokemon: Pokemon) {
super.onAdd(pokemon);
this.target = pokemon;
pokemon.scene.queueMessage(i18next.t("battlerTags:tormentOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500);
}
@ -2514,15 +2521,15 @@ export class TormentTag extends MoveRestrictionBattlerTag {
* @param {Moves} move the move under investigation
* @returns `true` if there is valid consecutive usage | `false` if the moves are different from each other
*/
override isMoveRestricted(move: Moves): boolean {
const lastMove = this.target.getLastXMoves(1)[0];
override isMoveRestricted(move: Moves, user: Pokemon): boolean {
const lastMove = user.getLastXMoves(1)[0];
if ( !lastMove ) {
return false;
}
// This checks for locking / momentum moves like Rollout and Hydro Cannon + if the user is under the influence of BattlerTagType.FRENZY
// Because Uproar's unique behavior is not implemented, it does not check for Uproar. Torment has been marked as partial in moves.ts
const moveObj = allMoves[lastMove.move];
const isUnaffected = moveObj.hasAttr(ConsecutiveUseDoublePowerAttr) || this.target.getTag(BattlerTagType.FRENZY) || moveObj.hasAttr(ChargeAttr);
const isUnaffected = moveObj.hasAttr(ConsecutiveUseDoublePowerAttr) || user.getTag(BattlerTagType.FRENZY) || moveObj.hasAttr(ChargeAttr);
const validLastMoveResult = (lastMove.result === MoveResult.SUCCESS) || (lastMove.result === MoveResult.MISS);
if (lastMove.move === move && validLastMoveResult && lastMove.move !== Moves.STRUGGLE && !isUnaffected) {
return true;
@ -2601,7 +2608,10 @@ export class ImprisonTag extends MoveRestrictionBattlerTag {
* @param {Moves} move the move under investigation
* @returns `false` if either condition is not met
*/
override isMoveRestricted(move: Moves): boolean {
override isMoveRestricted(move: Moves, user: Pokemon): boolean {
if (!this.source && this.sourceId) {
this.source = user.scene.getPokemonById(this.sourceId);
}
if (this.source) {
const sourceMoveset = this.source.getMoveset().map(m => m!.moveId);
return sourceMoveset?.includes(move) && this.source.isActive(true);

View File

@ -7606,7 +7606,8 @@ export function initMoves() {
.attr(SwitchAbilitiesAttr),
new StatusMove(Moves.IMPRISON, Type.PSYCHIC, 100, 10, -1, 0, 3)
.ignoresSubstitute()
.attr(AddArenaTagAttr, ArenaTagType.IMPRISON, 1, true, false),
.attr(AddArenaTagAttr, ArenaTagType.IMPRISON, 1, true, false)
.target(MoveTarget.ENEMY_SIDE),
new SelfStatusMove(Moves.REFRESH, Type.NORMAL, -1, 20, -1, 0, 3)
.attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN)
.condition((user, target, move) => !!user.status && (user.status.effect === StatusEffect.PARALYSIS || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.BURN)),

View File

@ -3059,7 +3059,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
*/
getRestrictingTag(moveId: Moves, user?: Pokemon, target?: Pokemon): MoveRestrictionBattlerTag | null {
for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) {
if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId)) {
if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId, user)) {
return tag as MoveRestrictionBattlerTag;
} else if (user && target && (tag as MoveRestrictionBattlerTag).isMoveTargetRestricted(moveId, user, target)) {
return tag as MoveRestrictionBattlerTag;