mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Fix some strict-null issues
This commit is contained in:
parent
91e50f7303
commit
73f7a340a2
@ -572,7 +572,7 @@ export default class Move implements Localizable {
|
|||||||
* example: @see {@linkcode Moves.WHIRLWIND}
|
* example: @see {@linkcode Moves.WHIRLWIND}
|
||||||
* @returns The {@linkcode Move} that called this function
|
* @returns The {@linkcode Move} that called this function
|
||||||
*/
|
*/
|
||||||
ignoresSubstitute(ignoresSubstitute?: boolean): this {
|
ignoresSubstitute(ignoresSubstitute: boolean = true): this {
|
||||||
this.setFlag(MoveFlags.IGNORE_SUBSTITUTE, ignoresSubstitute);
|
this.setFlag(MoveFlags.IGNORE_SUBSTITUTE, ignoresSubstitute);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -2924,7 +2924,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
// If this Pokemon has a Substitute when loading in, play an animation to add its sprite
|
// If this Pokemon has a Substitute when loading in, play an animation to add its sprite
|
||||||
if (!!this.getTag(SubstituteTag)) {
|
if (!!this.getTag(SubstituteTag)) {
|
||||||
this.scene.triggerPokemonBattleAnim(this, PokemonAnimType.SUBSTITUTE_ADD);
|
this.scene.triggerPokemonBattleAnim(this, PokemonAnimType.SUBSTITUTE_ADD);
|
||||||
this.getTag(SubstituteTag).sourceInFocus = false;
|
this.getTag(SubstituteTag)!.sourceInFocus = false;
|
||||||
}
|
}
|
||||||
this.summonDataPrimer = null;
|
this.summonDataPrimer = null;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ describe("Moves - Substitute", () => {
|
|||||||
async () => {
|
async () => {
|
||||||
await game.startBattle([Species.MAGIKARP]);
|
await game.startBattle([Species.MAGIKARP]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.SKARMORY]);
|
await game.startBattle([Species.SKARMORY]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.MAGIKARP]);
|
await game.startBattle([Species.MAGIKARP]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.MAGIKARP]);
|
await game.startBattle([Species.MAGIKARP]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ describe("Moves - Substitute", () => {
|
|||||||
async () => {
|
async () => {
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SUBSTITUTE));
|
||||||
|
|
||||||
@ -201,10 +201,10 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
||||||
|
|
||||||
@ -222,9 +222,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
|
|
||||||
@ -242,9 +242,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
|
|
||||||
@ -261,9 +261,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
|
|
||||||
@ -282,9 +282,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
|
|
||||||
@ -302,9 +302,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, enemyPokemon.id);
|
enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id);
|
||||||
const enemyNumItems = enemyPokemon.getHeldItems().length;
|
const enemyNumItems = enemyPokemon.getHeldItems().length;
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.KNOCK_OFF));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.KNOCK_OFF));
|
||||||
@ -323,10 +323,10 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
||||||
|
|
||||||
@ -347,9 +347,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE));
|
||||||
|
|
||||||
@ -367,9 +367,9 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE]);
|
await game.startBattle([Species.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE));
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SWORDS_DANCE));
|
||||||
|
|
||||||
@ -387,16 +387,16 @@ describe("Moves - Substitute", () => {
|
|||||||
|
|
||||||
await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
|
await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon();
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, null, null, leadPokemon.id);
|
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||||
|
|
||||||
game.doSwitchPokemon(1, true);
|
game.doSwitchPokemon(1, true);
|
||||||
|
|
||||||
await game.phaseInterceptor.to(MovePhase, false);
|
await game.phaseInterceptor.to(MovePhase, false);
|
||||||
|
|
||||||
const switchedPokemon = game.scene.getPlayerPokemon();
|
const switchedPokemon = game.scene.getPlayerPokemon()!;
|
||||||
const subTag = switchedPokemon.getTag(SubstituteTag);
|
const subTag = switchedPokemon.getTag(SubstituteTag)!;
|
||||||
expect(subTag).toBeDefined();
|
expect(subTag).toBeDefined();
|
||||||
expect(subTag.hp).toBe(Math.floor(leadPokemon.getMaxHp() * 1/4));
|
expect(subTag.hp).toBe(Math.floor(leadPokemon.getMaxHp() * 1/4));
|
||||||
}, TIMEOUT
|
}, TIMEOUT
|
||||||
|
@ -105,7 +105,7 @@ describe("Moves - Tidy Up", () => {
|
|||||||
const pokemon = [ game.scene.getPlayerPokemon(), game.scene.getEnemyPokemon() ];
|
const pokemon = [ game.scene.getPlayerPokemon(), game.scene.getEnemyPokemon() ];
|
||||||
pokemon.forEach(p => {
|
pokemon.forEach(p => {
|
||||||
expect(p).toBeDefined();
|
expect(p).toBeDefined();
|
||||||
expect(p.getTag(SubstituteTag)).toBeUndefined();
|
expect(p!.getTag(SubstituteTag)).toBeUndefined();
|
||||||
});
|
});
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user