mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 15:52:18 +02:00
Update CheckTrapped and PostBattle
This commit is contained in:
parent
89e4912889
commit
dba1993176
@ -4146,6 +4146,10 @@ export class CheckTrappedAbAttr extends AbAttr {
|
|||||||
this.arenaTrapCondition = condition;
|
this.arenaTrapCondition = condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
willSucceedCheckTrapped(pokemon: Pokemon, passive: boolean, simulated: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
applyCheckTrapped(pokemon: Pokemon, passive: boolean, simulated: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean | Promise<boolean> {
|
applyCheckTrapped(pokemon: Pokemon, passive: boolean, simulated: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean | Promise<boolean> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -4158,6 +4162,12 @@ export class CheckTrappedAbAttr extends AbAttr {
|
|||||||
* @see {@linkcode applyCheckTrapped}
|
* @see {@linkcode applyCheckTrapped}
|
||||||
*/
|
*/
|
||||||
export class ArenaTrapAbAttr extends CheckTrappedAbAttr {
|
export class ArenaTrapAbAttr extends CheckTrappedAbAttr {
|
||||||
|
willSucceedCheckTrapped(pokemon: Pokemon, passive: boolean, simulated: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean {
|
||||||
|
return this.arenaTrapCondition(pokemon, otherPokemon)
|
||||||
|
&& !(otherPokemon.getTypes(true).includes(Type.GHOST) || (otherPokemon.getTypes(true).includes(Type.STELLAR) && otherPokemon.getTypes().includes(Type.GHOST)))
|
||||||
|
&& !otherPokemon.hasAbility(Abilities.RUN_AWAY);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if enemy Pokemon is trapped by an Arena Trap-esque ability
|
* Checks if enemy Pokemon is trapped by an Arena Trap-esque ability
|
||||||
* If the enemy is a Ghost type, it is not trapped
|
* If the enemy is a Ghost type, it is not trapped
|
||||||
@ -4205,19 +4215,27 @@ export class PostBattleAbAttr extends AbAttr {
|
|||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
willSucceedPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
||||||
|
willSucceedPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
|
const postBattleLoot = globalScene.currentBattle.postBattleLoot;
|
||||||
|
return !simulated && postBattleLoot.length && args[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args - `[0]`: boolean for if the battle ended in a victory
|
* @param args - `[0]`: boolean for if the battle ended in a victory
|
||||||
* @returns `true` if successful
|
* @returns `true` if successful
|
||||||
*/
|
*/
|
||||||
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
const postBattleLoot = globalScene.currentBattle.postBattleLoot;
|
const postBattleLoot = globalScene.currentBattle.postBattleLoot;
|
||||||
if (!simulated && postBattleLoot.length && args[0]) {
|
|
||||||
const randItem = Utils.randSeedItem(postBattleLoot);
|
const randItem = Utils.randSeedItem(postBattleLoot);
|
||||||
//@ts-ignore - TODO see below
|
//@ts-ignore - TODO see below
|
||||||
if (globalScene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true, undefined, false)) { // TODO: fix. This is a promise!?
|
if (globalScene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true, undefined, false)) { // TODO: fix. This is a promise!?
|
||||||
@ -4225,7 +4243,6 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
|||||||
globalScene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
|
globalScene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -4681,6 +4698,10 @@ export class MoneyAbAttr extends PostBattleAbAttr {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
willSucceedPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
|
return !simulated && args[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param pokemon {@linkcode Pokemon} that is the user of this ability.
|
* @param pokemon {@linkcode Pokemon} that is the user of this ability.
|
||||||
* @param passive N/A
|
* @param passive N/A
|
||||||
@ -4688,12 +4709,9 @@ export class MoneyAbAttr extends PostBattleAbAttr {
|
|||||||
* @returns `true` if successful
|
* @returns `true` if successful
|
||||||
*/
|
*/
|
||||||
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
if (!simulated && args[0]) {
|
|
||||||
globalScene.currentBattle.moneyScattered += globalScene.getWaveMoneyAmount(0.2);
|
globalScene.currentBattle.moneyScattered += globalScene.getWaveMoneyAmount(0.2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5404,12 +5422,14 @@ export function applyPostTerrainChangeAbAttrs(attrType: Constructor<PostTerrainC
|
|||||||
|
|
||||||
export function applyCheckTrappedAbAttrs(attrType: Constructor<CheckTrappedAbAttr>,
|
export function applyCheckTrappedAbAttrs(attrType: Constructor<CheckTrappedAbAttr>,
|
||||||
pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, messages: string[], simulated: boolean = false, ...args: any[]): Promise<void> {
|
pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, messages: string[], simulated: boolean = false, ...args: any[]): Promise<void> {
|
||||||
return applyAbAttrsInternal<CheckTrappedAbAttr>(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), args, false, simulated, messages);
|
return applyAbAttrsInternal<CheckTrappedAbAttr>(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args),
|
||||||
|
(attr, passive) => attr.willSucceedCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), args, false, simulated, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyPostBattleAbAttrs(attrType: Constructor<PostBattleAbAttr>,
|
export function applyPostBattleAbAttrs(attrType: Constructor<PostBattleAbAttr>,
|
||||||
pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise<void> {
|
pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise<void> {
|
||||||
return applyAbAttrsInternal<PostBattleAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPostBattle(pokemon, passive, simulated, args), args, false, simulated);
|
return applyAbAttrsInternal<PostBattleAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPostBattle(pokemon, passive, simulated, args),
|
||||||
|
(attr, passive) => attr.willSucceedPostBattle(pokemon, passive, simulated, args), args, false, simulated);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyPostFaintAbAttrs(attrType: Constructor<PostFaintAbAttr>,
|
export function applyPostFaintAbAttrs(attrType: Constructor<PostFaintAbAttr>,
|
||||||
|
Loading…
Reference in New Issue
Block a user