Compare commits

...

15 Commits

Author SHA1 Message Date
Wlowscha
bafc85f3e1
Merge b9c42bfaea into 3b36ab17e4 2025-08-05 00:57:38 -05:00
Jimmybald1
3b36ab17e4
[Bug] Protect now tracks success chance properly (#5869)
* Protect rng now resets on new waves and fixed to look at all turns in the same wave.

* Added per-wave move history object to fix issues

@Jimmybald1 I added a commented out `console.log` in the protect code (L5797) for you to use for testing

* Added many tests

* Wave move history has to be looped in reverse

* Update src/data/moves/move.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update src/data/moves/move.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* comments

* Fixed forceEnemyMove references after merge

* Removed console log

Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>

* Fixed test message

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>

* Apply Biome

* Fix merge issues

* Fix Crafty Shield test

* Remove protect chance reset on wave change

* Fix merge issue

---------

Co-authored-by: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
2025-08-05 07:35:14 +02:00
Wlowscha
b9c42bfaea
Fixed unused scale parameter 2025-08-03 22:10:09 +02:00
Wlowscha
157df79403
Merge branch 'beta' into clean-up-move-info-overlay 2025-08-03 22:03:44 +02:00
Wlowscha
93911a4f5d
Merge branch 'beta' into clean-up-move-info-overlay 2025-07-31 08:39:26 +02:00
Wlowscha
dcd1ca3a54
Merge branch 'beta' into clean-up-move-info-overlay 2025-07-30 00:01:45 +02:00
Wlowscha
67729111a6
Merge branch 'clean-up-move-info-overlay' of https://github.com/Wlowscha/pokerogue into clean-up-move-info-overlay 2025-07-29 23:07:26 +02:00
Wlowscha
17ea39d836
Caught a few more instances of width / 6 etc 2025-07-29 23:07:05 +02:00
Wlowscha
760f366f1e
Merge branch 'beta' into clean-up-move-info-overlay 2025-07-29 22:35:49 +02:00
NightKev
2b7dc32d80 Fix typo 2025-07-28 14:56:46 -07:00
NightKev
b3af6a8a0a Convert comments to TSDocs 2025-07-28 14:55:52 -07:00
Wlowscha
f6e477c2f9
Replaced some sneaky instances of scaledCanvas / 2 2025-07-28 22:51:45 +02:00
Wlowscha
2df8a7f255
Using scaledCanvas everywhere 2025-07-28 22:45:04 +02:00
Wlowscha
5fb381cc48
Using globalScene.scaledCanvas.width 2025-07-28 22:42:33 +02:00
Wlowscha
6c5277854b
Removed unused scale parameter from InfoOverlay s 2025-07-28 22:31:41 +02:00
60 changed files with 590 additions and 467 deletions

View File

@ -478,8 +478,8 @@ export class BattleScene extends SceneBase {
this.uiContainer = uiContainer; this.uiContainer = uiContainer;
const overlayWidth = this.game.canvas.width / 6; const overlayWidth = this.scaledCanvas.width;
const overlayHeight = this.game.canvas.height / 6 - 48; const overlayHeight = this.scaledCanvas.height - 48;
this.fieldOverlay = this.add.rectangle(0, overlayHeight * -1 - 48, overlayWidth, overlayHeight, 0x424242); this.fieldOverlay = this.add.rectangle(0, overlayHeight * -1 - 48, overlayWidth, overlayHeight, 0x424242);
this.fieldOverlay.setName("rect-field-overlay"); this.fieldOverlay.setName("rect-field-overlay");
this.fieldOverlay.setOrigin(0, 0); this.fieldOverlay.setOrigin(0, 0);
@ -537,34 +537,29 @@ export class BattleScene extends SceneBase {
this.candyBar.setup(); this.candyBar.setup();
this.fieldUI.add(this.candyBar); this.fieldUI.add(this.candyBar);
this.biomeWaveText = addTextObject( this.biomeWaveText = addTextObject(this.scaledCanvas.width - 2, 0, startingWave.toString(), TextStyle.BATTLE_INFO);
this.game.canvas.width / 6 - 2,
0,
startingWave.toString(),
TextStyle.BATTLE_INFO,
);
this.biomeWaveText.setName("text-biome-wave"); this.biomeWaveText.setName("text-biome-wave");
this.biomeWaveText.setOrigin(1, 0.5); this.biomeWaveText.setOrigin(1, 0.5);
this.fieldUI.add(this.biomeWaveText); this.fieldUI.add(this.biomeWaveText);
this.moneyText = addTextObject(this.game.canvas.width / 6 - 2, 0, "", TextStyle.MONEY); this.moneyText = addTextObject(this.scaledCanvas.width - 2, 0, "", TextStyle.MONEY);
this.moneyText.setName("text-money"); this.moneyText.setName("text-money");
this.moneyText.setOrigin(1, 0.5); this.moneyText.setOrigin(1, 0.5);
this.fieldUI.add(this.moneyText); this.fieldUI.add(this.moneyText);
this.scoreText = addTextObject(this.game.canvas.width / 6 - 2, 0, "", TextStyle.PARTY, { fontSize: "54px" }); this.scoreText = addTextObject(this.scaledCanvas.width - 2, 0, "", TextStyle.PARTY, { fontSize: "54px" });
this.scoreText.setName("text-score"); this.scoreText.setName("text-score");
this.scoreText.setOrigin(1, 0.5); this.scoreText.setOrigin(1, 0.5);
this.fieldUI.add(this.scoreText); this.fieldUI.add(this.scoreText);
this.luckText = addTextObject(this.game.canvas.width / 6 - 2, 0, "", TextStyle.PARTY, { fontSize: "54px" }); this.luckText = addTextObject(this.scaledCanvas.width - 2, 0, "", TextStyle.PARTY, { fontSize: "54px" });
this.luckText.setName("text-luck"); this.luckText.setName("text-luck");
this.luckText.setOrigin(1, 0.5); this.luckText.setOrigin(1, 0.5);
this.luckText.setVisible(false); this.luckText.setVisible(false);
this.fieldUI.add(this.luckText); this.fieldUI.add(this.luckText);
this.luckLabelText = addTextObject( this.luckLabelText = addTextObject(
this.game.canvas.width / 6 - 2, this.scaledCanvas.width - 2,
0, 0,
i18next.t("common:luckIndicator"), i18next.t("common:luckIndicator"),
TextStyle.PARTY, TextStyle.PARTY,
@ -586,10 +581,7 @@ export class BattleScene extends SceneBase {
this.spriteSparkleHandler = new PokemonSpriteSparkleHandler(); this.spriteSparkleHandler = new PokemonSpriteSparkleHandler();
this.spriteSparkleHandler.setup(); this.spriteSparkleHandler.setup();
this.pokemonInfoContainer = new PokemonInfoContainer( this.pokemonInfoContainer = new PokemonInfoContainer(this.scaledCanvas.width + 52, -this.scaledCanvas.height + 66);
this.game.canvas.width / 6 + 52,
-(this.game.canvas.height / 6) + 66,
);
this.pokemonInfoContainer.setup(); this.pokemonInfoContainer.setup();
this.fieldUI.add(this.pokemonInfoContainer); this.fieldUI.add(this.pokemonInfoContainer);
@ -2054,7 +2046,7 @@ export class BattleScene extends SceneBase {
} else { } else {
this.luckText.setTint(0xffef5c, 0x47ff69, 0x6b6bff, 0xff6969); this.luckText.setTint(0xffef5c, 0x47ff69, 0x6b6bff, 0xff6969);
} }
this.luckLabelText.setX(this.game.canvas.width / 6 - 2 - (this.luckText.displayWidth + 2)); this.luckLabelText.setX(this.scaledCanvas.width - 2 - (this.luckText.displayWidth + 2));
this.tweens.add({ this.tweens.add({
targets: labels, targets: labels,
duration: duration, duration: duration,
@ -2088,7 +2080,7 @@ export class BattleScene extends SceneBase {
const enemyModifierCount = this.enemyModifiers.filter(m => m.isIconVisible()).length; const enemyModifierCount = this.enemyModifiers.filter(m => m.isIconVisible()).length;
const biomeWaveTextHeight = this.biomeWaveText.getBottomLeft().y - this.biomeWaveText.getTopLeft().y; const biomeWaveTextHeight = this.biomeWaveText.getBottomLeft().y - this.biomeWaveText.getTopLeft().y;
this.biomeWaveText.setY( this.biomeWaveText.setY(
-(this.game.canvas.height / 6) + -this.scaledCanvas.height +
(enemyModifierCount ? (enemyModifierCount <= 12 ? 15 : 24) : 0) + (enemyModifierCount ? (enemyModifierCount <= 12 ? 15 : 24) : 0) +
biomeWaveTextHeight / 2, biomeWaveTextHeight / 2,
); );
@ -2100,7 +2092,7 @@ export class BattleScene extends SceneBase {
const offsetY = (this.scoreText.visible ? this.scoreText : this.moneyText).y + 15; const offsetY = (this.scoreText.visible ? this.scoreText : this.moneyText).y + 15;
this.partyExpBar.setY(offsetY); this.partyExpBar.setY(offsetY);
this.candyBar.setY(offsetY + 15); this.candyBar.setY(offsetY + 15);
this.ui?.achvBar.setY(this.game.canvas.height / 6 + offsetY); this.ui?.achvBar.setY(this.scaledCanvas.height + offsetY);
} }
/** /**

View File

@ -5912,20 +5912,21 @@ export class ProtectAttr extends AddBattlerTagAttr {
getCondition(): MoveConditionFunc { getCondition(): MoveConditionFunc {
return ((user, target, move): boolean => { return ((user, target, move): boolean => {
let timesUsed = 0; let timesUsed = 0;
const moveHistory = user.getLastXMoves();
let turnMove: TurnMove | undefined;
while (moveHistory.length) { for (const turnMove of user.getLastXMoves(-1).slice()) {
turnMove = moveHistory.shift(); if (
if (!allMoves[turnMove?.move ?? MoveId.NONE].hasAttr("ProtectAttr") || turnMove?.result !== MoveResult.SUCCESS) { // Quick & Wide guard increment the Protect counter without using it for fail chance
!(allMoves[turnMove.move].hasAttr("ProtectAttr") ||
[MoveId.QUICK_GUARD, MoveId.WIDE_GUARD].includes(turnMove.move)) ||
turnMove.result !== MoveResult.SUCCESS
) {
break; break;
} }
timesUsed++;
timesUsed++
} }
if (timesUsed) {
return !user.randBattleSeedInt(Math.pow(3, timesUsed)); return timesUsed === 0 || user.randBattleSeedInt(Math.pow(3, timesUsed)) === 0;
}
return true;
}); });
} }
} }

View File

@ -715,15 +715,13 @@ function doBugTypeMoveTutor(): Promise<void> {
const moveOptions = globalScene.currentBattle.mysteryEncounter!.misc.moveTutorOptions; const moveOptions = globalScene.currentBattle.mysteryEncounter!.misc.moveTutorOptions;
await showEncounterDialogue(`${namespace}:battle_won`, `${namespace}:speaker`); await showEncounterDialogue(`${namespace}:battle_won`, `${namespace}:speaker`);
const overlayScale = 1;
const moveInfoOverlay = new MoveInfoOverlay({ const moveInfoOverlay = new MoveInfoOverlay({
delayVisibility: false, delayVisibility: false,
scale: overlayScale,
onSide: true, onSide: true,
right: true, right: true,
x: 1, x: 1,
y: -MoveInfoOverlay.getHeight(overlayScale, true) - 1, y: -MoveInfoOverlay.getHeight(true) - 1,
width: globalScene.game.canvas.width / 6 - 2, width: globalScene.scaledCanvas.width - 2,
}); });
globalScene.ui.add(moveInfoOverlay); globalScene.ui.add(moveInfoOverlay);

View File

@ -564,14 +564,14 @@ function generateTradeOption(alreadyUsedSpecies: PokemonSpecies[], originalBst?:
function showTradeBackground() { function showTradeBackground() {
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
const tradeContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); const tradeContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
tradeContainer.setName("Trade Background"); tradeContainer.setName("Trade Background");
const flyByStaticBg = globalScene.add.rectangle( const flyByStaticBg = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0, 0,
); );
flyByStaticBg.setName("Black Background"); flyByStaticBg.setName("Black Background");

View File

@ -648,15 +648,15 @@ function getTransformedSpecies(
} }
function doShowDreamBackground() { function doShowDreamBackground() {
const transformationContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); const transformationContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
transformationContainer.name = "Dream Background"; transformationContainer.name = "Dream Background";
// In case it takes a bit for video to load // In case it takes a bit for video to load
const transformationStaticBg = globalScene.add.rectangle( const transformationStaticBg = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0, 0,
); );
transformationStaticBg.setName("Black Background"); transformationStaticBg.setName("Black Background");

View File

@ -253,7 +253,6 @@ export class PokemonTempSummonData {
* Only currently used for positioning the battle cursor. * Only currently used for positioning the battle cursor.
*/ */
turnCount = 1; turnCount = 1;
/** /**
* The number of turns this pokemon has spent in the active position since the start of the wave * The number of turns this pokemon has spent in the active position since the start of the wave
* without switching out. * without switching out.

View File

@ -30,7 +30,7 @@ export class DamageNumberHandler {
const baseScale = target.getSpriteScale() / 6; const baseScale = target.getSpriteScale() / 6;
const damageNumber = addTextObject( const damageNumber = addTextObject(
target.x, target.x,
-(globalScene.game.canvas.height / 6) + target.y - target.getSprite().height / 2, -globalScene.scaledCanvas.height + target.y - target.getSprite().height / 2,
formatStat(amount, true), formatStat(amount, true),
TextStyle.SUMMARY, TextStyle.SUMMARY,
); );

View File

@ -5094,6 +5094,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
*/ */
resetWaveData(): void { resetWaveData(): void {
this.waveData = new PokemonWaveData(); this.waveData = new PokemonWaveData();
this.tempSummonData.waveTurnCount = 1;
} }
resetTera(): void { resetTera(): void {

View File

@ -58,12 +58,6 @@ export class BattleEndPhase extends BattlePhase {
globalScene.phaseManager.unshiftNew("GameOverPhase", true); globalScene.phaseManager.unshiftNew("GameOverPhase", true);
} }
for (const pokemon of globalScene.getField()) {
if (pokemon) {
pokemon.tempSummonData.waveTurnCount = 1;
}
}
for (const pokemon of globalScene.getPokemonAllowedInBattle()) { for (const pokemon of globalScene.getPokemonAllowedInBattle()) {
applyAbAttrs("PostBattleAbAttr", { pokemon, victory: this.isVictory }); applyAbAttrs("PostBattleAbAttr", { pokemon, victory: this.isVictory });
} }

View File

@ -148,9 +148,9 @@ export class EggHatchPhase extends Phase {
this.eggHatchOverlay = globalScene.add.rectangle( this.eggHatchOverlay = globalScene.add.rectangle(
0, 0,
-globalScene.game.canvas.height / 6, -globalScene.scaledCanvas.height,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0xffffff, 0xffffff,
); );
this.eggHatchOverlay.setOrigin(0, 0); this.eggHatchOverlay.setOrigin(0, 0);

View File

@ -25,8 +25,8 @@ export class EndCardPhase extends Phase {
globalScene.field.add(this.endCard); globalScene.field.add(this.endCard);
this.text = addTextObject( this.text = addTextObject(
globalScene.game.canvas.width / 12, globalScene.scaledCanvas.width / 2,
globalScene.game.canvas.height / 6 - 16, globalScene.scaledCanvas.height - 16,
i18next.t("battle:congratulations"), i18next.t("battle:congratulations"),
TextStyle.SUMMARY, TextStyle.SUMMARY,
{ fontSize: "128px" }, { fontSize: "128px" },

View File

@ -90,16 +90,16 @@ export class EvolutionPhase extends Phase {
.setVisible(false); .setVisible(false);
this.evolutionBgOverlay = globalScene.add this.evolutionBgOverlay = globalScene.add
.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x262626) .rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height, 0x262626)
.setOrigin(0) .setOrigin(0)
.setAlpha(0); .setAlpha(0);
this.evolutionContainer.add([this.evolutionBaseBg, this.evolutionBgOverlay, this.evolutionBg]); this.evolutionContainer.add([this.evolutionBaseBg, this.evolutionBgOverlay, this.evolutionBg]);
this.evolutionOverlay = globalScene.add.rectangle( this.evolutionOverlay = globalScene.add.rectangle(
0, 0,
-globalScene.game.canvas.height / 6, -globalScene.scaledCanvas.height,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6 - 48, globalScene.scaledCanvas.height - 48,
0xffffff, 0xffffff,
); );
this.evolutionOverlay.setOrigin(0).setAlpha(0); this.evolutionOverlay.setOrigin(0).setAlpha(0);

View File

@ -653,7 +653,7 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container {
console.log(this.event.bannerKey); console.log(this.event.bannerKey);
const padding = 5; const padding = 5;
const showTimer = this.event.eventType !== EventType.NO_TIMER_DISPLAY; const showTimer = this.event.eventType !== EventType.NO_TIMER_DISPLAY;
const yPosition = globalScene.game.canvas.height / 6 - padding - (showTimer ? 10 : 0) - (this.event.yOffset ?? 0); const yPosition = globalScene.scaledCanvas.height - padding - (showTimer ? 10 : 0) - (this.event.yOffset ?? 0);
this.banner = new Phaser.GameObjects.Image(globalScene, this.availableWidth / 2, yPosition - padding, key); this.banner = new Phaser.GameObjects.Image(globalScene, this.availableWidth / 2, yPosition - padding, key);
this.banner.setName("img-event-banner"); this.banner.setName("img-event-banner");
this.banner.setOrigin(0.5, 1); this.banner.setOrigin(0.5, 1);

View File

@ -66,7 +66,7 @@ export abstract class AbstractOptionSelectUiHandler extends UiHandler {
setup() { setup() {
const ui = this.getUi(); const ui = this.getUi();
this.optionSelectContainer = globalScene.add.container(globalScene.game.canvas.width / 6 - 1, -48); this.optionSelectContainer = globalScene.add.container(globalScene.scaledCanvas.width - 1, -48);
this.optionSelectContainer.setName(`option-select-${this.mode ? UiMode[this.mode] : "UNKNOWN"}`); this.optionSelectContainer.setName(`option-select-${this.mode ? UiMode[this.mode] : "UNKNOWN"}`);
this.optionSelectContainer.setVisible(false); this.optionSelectContainer.setVisible(false);
ui.add(this.optionSelectContainer); ui.add(this.optionSelectContainer);
@ -135,7 +135,7 @@ export abstract class AbstractOptionSelectUiHandler extends UiHandler {
this.optionSelectText.setName("text-option-select"); this.optionSelectText.setName("text-option-select");
this.optionSelectTextContainer.add(this.optionSelectText); this.optionSelectTextContainer.add(this.optionSelectText);
this.optionSelectContainer.setPosition( this.optionSelectContainer.setPosition(
globalScene.game.canvas.width / 6 - 1 - (this.config?.xOffset || 0), globalScene.scaledCanvas.width - 1 - (this.config?.xOffset || 0),
-48 + (this.config?.yOffset || 0), -48 + (this.config?.yOffset || 0),
); );
this.optionSelectBg.width = Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth()); this.optionSelectBg.width = Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth());

View File

@ -21,7 +21,7 @@ export class AchvBar extends Phaser.GameObjects.Container {
public shown: boolean; public shown: boolean;
constructor() { constructor() {
super(globalScene, globalScene.game.canvas.width / 6, 0); super(globalScene, globalScene.scaledCanvas.width, 0);
this.playerGender = globalScene.gameData.gender; this.playerGender = globalScene.gameData.gender;
} }
@ -118,7 +118,7 @@ export class AchvBar extends Phaser.GameObjects.Container {
globalScene.tweens.add({ globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6 - this.bg.width / 2, x: globalScene.scaledCanvas.width - this.bg.width / 2,
duration: 500, duration: 500,
ease: "Sine.easeOut", ease: "Sine.easeOut",
}); });
@ -136,7 +136,7 @@ export class AchvBar extends Phaser.GameObjects.Container {
globalScene.tweens.add({ globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6, x: globalScene.scaledCanvas.width,
duration: 500, duration: 500,
ease: "Sine.easeIn", ease: "Sine.easeIn",
onComplete: () => { onComplete: () => {

View File

@ -72,9 +72,9 @@ export class AchvsUiHandler extends MessageUiHandler {
const ui = this.getUi(); const ui = this.getUi();
/** Width of the global canvas / 6 */ /** Width of the global canvas / 6 */
const WIDTH = globalScene.game.canvas.width / 6; const WIDTH = globalScene.scaledCanvas.width;
/** Height of the global canvas / 6 */ /** Height of the global canvas / 6 */
const HEIGHT = globalScene.game.canvas.height / 6; const HEIGHT = globalScene.scaledCanvas.height;
this.mainContainer = globalScene.add.container(1, -HEIGHT + 1); this.mainContainer = globalScene.add.container(1, -HEIGHT + 1);

View File

@ -37,7 +37,7 @@ export class BallUiHandler extends UiHandler {
const optionsText = addTextObject(0, 0, optionsTextContent, TextStyle.WINDOW, { align: "right", maxLines: 6 }); const optionsText = addTextObject(0, 0, optionsTextContent, TextStyle.WINDOW, { align: "right", maxLines: 6 });
const optionsTextWidth = optionsText.displayWidth; const optionsTextWidth = optionsText.displayWidth;
this.pokeballSelectContainer = globalScene.add.container( this.pokeballSelectContainer = globalScene.add.container(
globalScene.game.canvas.width / 6 - 51 - Math.max(64, optionsTextWidth), globalScene.scaledCanvas.width - 51 - Math.max(64, optionsTextWidth),
-49, -49,
); );
this.pokeballSelectContainer.setVisible(false); this.pokeballSelectContainer.setVisible(false);

View File

@ -16,7 +16,6 @@ interface BaseStatsOverlaySettings {
const HEIGHT = 120; const HEIGHT = 120;
const BORDER = 8; const BORDER = 8;
const GLOBAL_SCALE = 6;
const shortStats = ["HP", "ATK", "DEF", "SPATK", "SPDEF", "SPD"]; const shortStats = ["HP", "ATK", "DEF", "SPATK", "SPDEF", "SPD"];
export class BaseStatsOverlay extends Phaser.GameObjects.Container implements InfoToggle { export class BaseStatsOverlay extends Phaser.GameObjects.Container implements InfoToggle {
@ -109,7 +108,7 @@ export class BaseStatsOverlay extends Phaser.GameObjects.Container implements In
// width of this element // width of this element
static getWidth(_scale: number): number { static getWidth(_scale: number): number {
return globalScene.game.canvas.width / GLOBAL_SCALE / 2; return globalScene.scaledCanvas.width / 2;
} }
// height of this element // height of this element

View File

@ -39,7 +39,7 @@ export class PlayerBattleInfo extends BattleInfo {
statOverflow: 1, statOverflow: 1,
}, },
}; };
super(Math.floor(globalScene.game.canvas.width / 6) - 10, -72, true, posParams); super(Math.floor(globalScene.scaledCanvas.width) - 10, -72, true, posParams);
this.hpNumbersContainer = globalScene.add.container(-15, 10).setName("container_hp"); this.hpNumbersContainer = globalScene.add.container(-15, 10).setName("container_hp");

View File

@ -94,7 +94,7 @@ export class BattleMessageUiHandler extends MessageUiHandler {
this.levelUpStatsContainer = levelUpStatsContainer; this.levelUpStatsContainer = levelUpStatsContainer;
const levelUpStatsLabelsContent = addTextObject(globalScene.game.canvas.width / 6 - 73, -94, "", TextStyle.WINDOW, { const levelUpStatsLabelsContent = addTextObject(globalScene.scaledCanvas.width - 73, -94, "", TextStyle.WINDOW, {
maxLines: 6, maxLines: 6,
}); });
let levelUpStatsLabelText = ""; let levelUpStatsLabelText = "";
@ -106,7 +106,7 @@ export class BattleMessageUiHandler extends MessageUiHandler {
levelUpStatsLabelsContent.x -= levelUpStatsLabelsContent.displayWidth; levelUpStatsLabelsContent.x -= levelUpStatsLabelsContent.displayWidth;
const levelUpStatsBg = addWindow( const levelUpStatsBg = addWindow(
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
-100, -100,
80 + levelUpStatsLabelsContent.displayWidth, 80 + levelUpStatsLabelsContent.displayWidth,
100, 100,
@ -117,7 +117,7 @@ export class BattleMessageUiHandler extends MessageUiHandler {
levelUpStatsContainer.add(levelUpStatsLabelsContent); levelUpStatsContainer.add(levelUpStatsLabelsContent);
const levelUpStatsIncrContent = addTextObject( const levelUpStatsIncrContent = addTextObject(
globalScene.game.canvas.width / 6 - 50, globalScene.scaledCanvas.width - 50,
-94, -94,
"+\n+\n+\n+\n+\n+", "+\n+\n+\n+\n+\n+",
TextStyle.WINDOW, TextStyle.WINDOW,
@ -128,7 +128,7 @@ export class BattleMessageUiHandler extends MessageUiHandler {
this.levelUpStatsIncrContent = levelUpStatsIncrContent; this.levelUpStatsIncrContent = levelUpStatsIncrContent;
const levelUpStatsValuesContent = addBBCodeTextObject( const levelUpStatsValuesContent = addBBCodeTextObject(
globalScene.game.canvas.width / 6 - 7, globalScene.scaledCanvas.width - 7,
-94, -94,
"", "",
TextStyle.WINDOW, TextStyle.WINDOW,

View File

@ -19,7 +19,7 @@ export class CandyBar extends Phaser.GameObjects.Container {
public shown: boolean; public shown: boolean;
constructor() { constructor() {
super(globalScene, globalScene.game.canvas.width / 6, -(globalScene.game.canvas.height / 6) + 15); super(globalScene, globalScene.scaledCanvas.width, -globalScene.scaledCanvas.height + 15);
} }
setup(): void { setup(): void {
@ -80,7 +80,7 @@ export class CandyBar extends Phaser.GameObjects.Container {
this.tween = globalScene.tweens.add({ this.tween = globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6 - (this.bg.width - 5), x: globalScene.scaledCanvas.width - (this.bg.width - 5),
duration: 500, duration: 500,
ease: "Sine.easeOut", ease: "Sine.easeOut",
onComplete: () => { onComplete: () => {
@ -111,7 +111,7 @@ export class CandyBar extends Phaser.GameObjects.Container {
this.tween = globalScene.tweens.add({ this.tween = globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6, x: globalScene.scaledCanvas.width,
duration: 500, duration: 500,
ease: "Sine.easeIn", ease: "Sine.easeIn",
onComplete: () => { onComplete: () => {

View File

@ -58,11 +58,11 @@ export class GameChallengesUiHandler extends UiHandler {
this.widestTextBox = 0; this.widestTextBox = 0;
this.challengesContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.challengesContainer = globalScene.add.container(1, -globalScene.scaledCanvas.height + 1);
this.challengesContainer.setName("challenges"); this.challengesContainer.setName("challenges");
this.challengesContainer.setInteractive( this.challengesContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
@ -79,7 +79,7 @@ export class GameChallengesUiHandler extends UiHandler {
this.challengesContainer.add(bgOverlay); this.challengesContainer.add(bgOverlay);
// TODO: Change this back to /9 when adding in difficulty // TODO: Change this back to /9 when adding in difficulty
const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6, 24); const headerBg = addWindow(0, 0, globalScene.scaledCanvas.width, 24);
headerBg.setName("window-header-bg"); headerBg.setName("window-header-bg");
headerBg.setOrigin(0, 0); headerBg.setOrigin(0, 0);

View File

@ -10,7 +10,7 @@ export class CharSprite extends Phaser.GameObjects.Container {
public shown: boolean; public shown: boolean;
constructor() { constructor() {
super(globalScene, globalScene.game.canvas.width / 6 + 32, -42); super(globalScene, globalScene.scaledCanvas.width + 32, -42);
} }
setup(): void { setup(): void {
@ -49,7 +49,7 @@ export class CharSprite extends Phaser.GameObjects.Container {
globalScene.tweens.add({ globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6 - 102, x: globalScene.scaledCanvas.width - 102,
duration: 750, duration: 750,
ease: "Cubic.easeOut", ease: "Cubic.easeOut",
onComplete: () => { onComplete: () => {
@ -95,7 +95,7 @@ export class CharSprite extends Phaser.GameObjects.Container {
globalScene.tweens.add({ globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6 + 32, x: globalScene.scaledCanvas.width + 32,
duration: 750, duration: 750,
ease: "Cubic.easeIn", ease: "Cubic.easeIn",
onComplete: () => { onComplete: () => {

View File

@ -69,7 +69,7 @@ export class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
const xOffset = args.length >= 7 && args[6] !== null ? (args[6] as number) : 0; const xOffset = args.length >= 7 && args[6] !== null ? (args[6] as number) : 0;
const yOffset = args.length >= 8 && args[7] !== null ? (args[7] as number) : 0; const yOffset = args.length >= 8 && args[7] !== null ? (args[7] as number) : 0;
this.optionSelectContainer.setPosition(globalScene.game.canvas.width / 6 - 1 + xOffset, -48 + yOffset); this.optionSelectContainer.setPosition(globalScene.scaledCanvas.width - 1 + xOffset, -48 + yOffset);
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);
return true; return true;
@ -103,7 +103,7 @@ export class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
const xOffset = args.length >= 4 && args[3] !== null ? (args[3] as number) : 0; const xOffset = args.length >= 4 && args[3] !== null ? (args[3] as number) : 0;
const yOffset = args.length >= 5 && args[4] !== null ? (args[4] as number) : 0; const yOffset = args.length >= 5 && args[4] !== null ? (args[4] as number) : 0;
this.optionSelectContainer.setPosition(globalScene.game.canvas.width / 6 - 1 + xOffset, -48 + yOffset); this.optionSelectContainer.setPosition(globalScene.scaledCanvas.width - 1 + xOffset, -48 + yOffset);
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);

View File

@ -174,7 +174,7 @@ export class EggGachaUiHandler extends MessageUiHandler {
const ui = this.getUi(); const ui = this.getUi();
this.eggGachaContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6).setVisible(false); this.eggGachaContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height).setVisible(false);
ui.add(this.eggGachaContainer); ui.add(this.eggGachaContainer);
const bg = globalScene.add.nineslice(0, 0, "default_bg", undefined, 320, 180, 0, 0, 16, 0).setOrigin(0); const bg = globalScene.add.nineslice(0, 0, "default_bg", undefined, 320, 180, 0, 0, 16, 0).setOrigin(0);
@ -212,7 +212,7 @@ export class EggGachaUiHandler extends MessageUiHandler {
this.eggGachaOptionSelectBg = addWindow(0, 0, eggGachaOptionSelectWidth, 16 + 576 * this.scale).setOrigin(1); this.eggGachaOptionSelectBg = addWindow(0, 0, eggGachaOptionSelectWidth, 16 + 576 * this.scale).setOrigin(1);
this.eggGachaOptionsContainer = globalScene.add this.eggGachaOptionsContainer = globalScene.add
.container(globalScene.game.canvas.width / 6, 148) .container(globalScene.scaledCanvas.width, 148)
.add(this.eggGachaOptionSelectBg); .add(this.eggGachaOptionSelectBg);
this.eggGachaContainer.add(this.eggGachaOptionsContainer); this.eggGachaContainer.add(this.eggGachaOptionsContainer);
@ -278,7 +278,7 @@ export class EggGachaUiHandler extends MessageUiHandler {
this.eggGachaContainer.add(this.eggGachaOptionsContainer); this.eggGachaContainer.add(this.eggGachaOptionsContainer);
for (const voucher of getEnumValues(VoucherType)) { for (const voucher of getEnumValues(VoucherType)) {
const container = globalScene.add.container(globalScene.game.canvas.width / 6 - 56 * voucher, 0); const container = globalScene.add.container(globalScene.scaledCanvas.width - 56 * voucher, 0);
const bg = addWindow(0, 0, 56, 22).setOrigin(1, 0); const bg = addWindow(0, 0, 56, 22).setOrigin(1, 0);
container.add(bg); container.add(bg);

View File

@ -19,7 +19,7 @@ export class EggHatchSceneHandler extends UiHandler {
} }
setup() { setup() {
this.eggHatchContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.eggHatchContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
globalScene.fieldUI.add(this.eggHatchContainer); globalScene.fieldUI.add(this.eggHatchContainer);
const eggLightraysAnimFrames = globalScene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 }); const eggLightraysAnimFrames = globalScene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 });

View File

@ -36,11 +36,11 @@ export class EggListUiHandler extends MessageUiHandler {
setup() { setup() {
const ui = this.getUi(); const ui = this.getUi();
this.eggListContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6).setVisible(false); this.eggListContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height).setVisible(false);
ui.add(this.eggListContainer); ui.add(this.eggListContainer);
const bgColor = globalScene.add const bgColor = globalScene.add
.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860) .rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height, 0x006860)
.setOrigin(0); .setOrigin(0);
const eggListBg = globalScene.add.image(0, 0, "egg_list_bg").setOrigin(0); const eggListBg = globalScene.add.image(0, 0, "egg_list_bg").setOrigin(0);
@ -69,9 +69,7 @@ export class EggListUiHandler extends MessageUiHandler {
.withUpdateGridCallBack(() => this.updateEggIcons()) .withUpdateGridCallBack(() => this.updateEggIcons())
.withUpdateSingleElementCallback((i: number) => this.setEggDetails(i)); .withUpdateSingleElementCallback((i: number) => this.setEggDetails(i));
this.eggListMessageBoxContainer = globalScene.add this.eggListMessageBoxContainer = globalScene.add.container(0, globalScene.scaledCanvas.height).setVisible(false);
.container(0, globalScene.game.canvas.height / 6)
.setVisible(false);
const eggListMessageBox = addWindow(1, -1, 318, 28).setOrigin(0, 1); const eggListMessageBox = addWindow(1, -1, 318, 28).setOrigin(0, 1);
this.eggListMessageBoxContainer.add(eggListMessageBox); this.eggListMessageBoxContainer.add(eggListMessageBox);

View File

@ -59,11 +59,11 @@ export class EggSummaryUiHandler extends MessageUiHandler {
setup() { setup() {
const ui = this.getUi(); const ui = this.getUi();
this.summaryContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.summaryContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
this.summaryContainer.setVisible(false); this.summaryContainer.setVisible(false);
ui.add(this.summaryContainer); ui.add(this.summaryContainer);
this.eggHatchContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.eggHatchContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
this.eggHatchContainer.setVisible(false); this.eggHatchContainer.setVisible(false);
ui.add(this.eggHatchContainer); ui.add(this.eggHatchContainer);
@ -92,7 +92,7 @@ export class EggSummaryUiHandler extends MessageUiHandler {
iconContainerX + numCols * iconSize, iconContainerX + numCols * iconSize,
iconContainerY + 3, iconContainerY + 3,
4, 4,
globalScene.game.canvas.height / 6 - 20, globalScene.scaledCanvas.height - 20,
numRows, numRows,
); );
this.summaryContainer.add(scrollBar); this.summaryContainer.add(scrollBar);

View File

@ -22,7 +22,7 @@ export class EvolutionSceneHandler extends MessageUiHandler {
const ui = this.getUi(); const ui = this.getUi();
this.evolutionContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.evolutionContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
const messageBg = globalScene.add.sprite(0, 0, "bg", globalScene.windowType).setOrigin(0, 1).setVisible(false); const messageBg = globalScene.add.sprite(0, 0, "bg", globalScene.windowType).setOrigin(0, 1).setVisible(false);

View File

@ -105,15 +105,13 @@ export class FightUiHandler extends UiHandler implements InfoToggle {
]); ]);
// prepare move overlay // prepare move overlay
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({ this.moveInfoOverlay = new MoveInfoOverlay({
delayVisibility: true, delayVisibility: true,
scale: overlayScale,
onSide: true, onSide: true,
right: true, right: true,
x: 0, x: 0,
y: -MoveInfoOverlay.getHeight(overlayScale, true), y: -MoveInfoOverlay.getHeight(true),
width: globalScene.game.canvas.width / 6 + 4, width: globalScene.scaledCanvas.width + 4,
hideEffectBox: true, hideEffectBox: true,
hideBg: true, hideBg: true,
}); });

View File

@ -62,7 +62,7 @@ export class FilterText extends Phaser.GameObjects.Container {
this.dialogueMessageBox = addWindow( this.dialogueMessageBox = addWindow(
-this.textPadding, -this.textPadding,
0, 0,
globalScene.game.canvas.width / 6 + this.textPadding * 2, globalScene.scaledCanvas.width + this.textPadding * 2,
49, 49,
false, false,
false, false,

View File

@ -49,7 +49,7 @@ export class LoginFormUiHandler extends FormModalUiHandler {
private buildExternalPartyContainer() { private buildExternalPartyContainer() {
this.externalPartyContainer = globalScene.add.container(0, 0); this.externalPartyContainer = globalScene.add.container(0, 0);
this.externalPartyContainer.setInteractive( this.externalPartyContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 12, globalScene.game.canvas.height / 12), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width / 2, globalScene.scaledCanvas.height / 2),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
this.externalPartyTitle = addTextObject(0, 4, "", TextStyle.SETTINGS_LABEL); this.externalPartyTitle = addTextObject(0, 4, "", TextStyle.SETTINGS_LABEL);

View File

@ -96,10 +96,10 @@ export class MenuUiHandler extends MessageUiHandler {
ui.bgmBar = this.bgmBar; ui.bgmBar = this.bgmBar;
this.menuContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.menuContainer = globalScene.add.container(1, -globalScene.scaledCanvas.height + 1);
this.menuContainer.setName("menu"); this.menuContainer.setName("menu");
this.menuContainer.setInteractive( this.menuContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
@ -146,10 +146,10 @@ export class MenuUiHandler extends MessageUiHandler {
this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale; this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale;
this.menuBg = addWindow( this.menuBg = addWindow(
globalScene.game.canvas.width / 6 - (this.optionSelectText.displayWidth + 25), globalScene.scaledCanvas.width - (this.optionSelectText.displayWidth + 25),
0, 0,
this.optionSelectText.displayWidth + 19 + 24 * this.scale, this.optionSelectText.displayWidth + 19 + 24 * this.scale,
globalScene.game.canvas.height / 6 - 2, globalScene.scaledCanvas.height - 2,
); );
this.menuBg.setOrigin(0, 0); this.menuBg.setOrigin(0, 0);
@ -174,7 +174,7 @@ export class MenuUiHandler extends MessageUiHandler {
this.dialogueMessageBox = addWindow( this.dialogueMessageBox = addWindow(
-this.textPadding, -this.textPadding,
0, 0,
globalScene.game.canvas.width / 6 + this.textPadding * 2, globalScene.scaledCanvas.width + this.textPadding * 2,
49, 49,
false, false,
false, false,

View File

@ -46,7 +46,7 @@ export abstract class ModalUiHandler extends UiHandler {
this.modalContainer = globalScene.add.container(0, 0); this.modalContainer = globalScene.add.container(0, 0);
this.modalContainer.setInteractive( this.modalContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
@ -105,8 +105,8 @@ export abstract class ModalUiHandler extends UiHandler {
const overlay = globalScene.add.rectangle( const overlay = globalScene.add.rectangle(
(this.getWidth() + marginLeft + marginRight) / 2, (this.getWidth() + marginLeft + marginRight) / 2,
(this.getHeight() + marginTop + marginBottom) / 2, (this.getHeight() + marginTop + marginBottom) / 2,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0, 0,
); );
overlay.setOrigin(0.5, 0.5); overlay.setOrigin(0.5, 0.5);
@ -159,8 +159,8 @@ export abstract class ModalUiHandler extends UiHandler {
const width = this.getWidth(config); const width = this.getWidth(config);
const height = this.getHeight(config); const height = this.getHeight(config);
this.modalContainer.setPosition( this.modalContainer.setPosition(
(globalScene.game.canvas.width / 6 - (width + (marginRight - marginLeft))) / 2, (globalScene.scaledCanvas.width - (width + (marginRight - marginLeft))) / 2,
(-globalScene.game.canvas.height / 6 - (height + (marginBottom - marginTop))) / 2, (-globalScene.scaledCanvas.height - (height + (marginBottom - marginTop))) / 2,
); );
this.modalBg.setSize(width, height); this.modalBg.setSize(width, height);

View File

@ -86,10 +86,7 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
transferButtonText.setOrigin(1, 0); transferButtonText.setOrigin(1, 0);
this.transferButtonContainer.add(transferButtonText); this.transferButtonContainer.add(transferButtonText);
this.checkButtonContainer = globalScene.add.container( this.checkButtonContainer = globalScene.add.container(globalScene.scaledCanvas.width - 1, OPTION_BUTTON_YPOSITION);
globalScene.game.canvas.width / 6 - 1,
OPTION_BUTTON_YPOSITION,
);
this.checkButtonContainer.setName("use-btn"); this.checkButtonContainer.setName("use-btn");
this.checkButtonContainer.setVisible(false); this.checkButtonContainer.setVisible(false);
ui.add(this.checkButtonContainer); ui.add(this.checkButtonContainer);
@ -129,8 +126,8 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
this.lockRarityButtonContainer.add(this.lockRarityButtonText); this.lockRarityButtonContainer.add(this.lockRarityButtonText);
this.continueButtonContainer = globalScene.add.container( this.continueButtonContainer = globalScene.add.container(
globalScene.game.canvas.width / 12, globalScene.scaledCanvas.width / 2,
-(globalScene.game.canvas.height / 12), -(globalScene.scaledCanvas.height / 2),
); );
this.continueButtonContainer.setVisible(false); this.continueButtonContainer.setVisible(false);
ui.add(this.continueButtonContainer); ui.add(this.continueButtonContainer);
@ -146,15 +143,13 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
this.continueButtonContainer.add(continueButtonText); this.continueButtonContainer.add(continueButtonText);
// prepare move overlay // prepare move overlay
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({ this.moveInfoOverlay = new MoveInfoOverlay({
delayVisibility: true, delayVisibility: true,
scale: overlayScale,
onSide: true, onSide: true,
right: true, right: true,
x: 1, x: 1,
y: -MoveInfoOverlay.getHeight(overlayScale, true) - 1, y: -MoveInfoOverlay.getHeight(true) - 1,
width: globalScene.game.canvas.width / 6 - 2, width: globalScene.scaledCanvas.width - 2,
}); });
ui.add(this.moveInfoOverlay); ui.add(this.moveInfoOverlay);
// register the overlay to receive toggle events // register the overlay to receive toggle events
@ -219,10 +214,10 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET; shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET;
for (let m = 0; m < typeOptions.length; m++) { for (let m = 0; m < typeOptions.length; m++) {
const sliceWidth = globalScene.game.canvas.width / 6 / (typeOptions.length + 2); const sliceWidth = globalScene.scaledCanvas.width / (typeOptions.length + 2);
const option = new ModifierOption( const option = new ModifierOption(
sliceWidth * (m + 1) + sliceWidth * 0.5, sliceWidth * (m + 1) + sliceWidth * 0.5,
-globalScene.game.canvas.height / 12 + optionsYOffset, -globalScene.scaledCanvas.height / 2 + optionsYOffset,
typeOptions[m], typeOptions[m],
); );
option.setScale(0.5); option.setScale(0.5);
@ -243,10 +238,10 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
row ? SHOP_OPTIONS_ROW_LIMIT : 0, row ? SHOP_OPTIONS_ROW_LIMIT : 0,
row ? undefined : SHOP_OPTIONS_ROW_LIMIT, row ? undefined : SHOP_OPTIONS_ROW_LIMIT,
); );
const sliceWidth = globalScene.game.canvas.width / 6 / (rowOptions.length + 2); const sliceWidth = globalScene.scaledCanvas.width / (rowOptions.length + 2);
const option = new ModifierOption( const option = new ModifierOption(
sliceWidth * (col + 1) + sliceWidth * 0.5, sliceWidth * (col + 1) + sliceWidth * 0.5,
-globalScene.game.canvas.height / 12 - globalScene.game.canvas.height / 32 - (42 - (28 * row - 1)), -globalScene.scaledCanvas.height / 2 - globalScene.game.canvas.height / 32 - (42 - (28 * row - 1)),
shopTypeOptions[m], shopTypeOptions[m],
); );
option.setScale(0.375); option.setScale(0.375);
@ -558,27 +553,27 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
// Continue button when no shop items // Continue button when no shop items
this.cursorObj.setScale(1.25); this.cursorObj.setScale(1.25);
this.cursorObj.setPosition( this.cursorObj.setPosition(
globalScene.game.canvas.width / 18 + 23, globalScene.scaledCanvas.width / 3 + 23,
-globalScene.game.canvas.height / 12 - -globalScene.scaledCanvas.height / 2 -
(this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2), (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2),
); );
ui.showText(i18next.t("modifierSelectUiHandler:continueNextWaveDescription")); ui.showText(i18next.t("modifierSelectUiHandler:continueNextWaveDescription"));
return ret; return ret;
} }
const sliceWidth = globalScene.game.canvas.width / 6 / (options.length + 2); const sliceWidth = globalScene.scaledCanvas.width / (options.length + 2);
if (this.rowCursor < 2) { if (this.rowCursor < 2) {
// Cursor on free items // Cursor on free items
this.cursorObj.setPosition( this.cursorObj.setPosition(
sliceWidth * (cursor + 1) + sliceWidth * 0.5 - 20, sliceWidth * (cursor + 1) + sliceWidth * 0.5 - 20,
-globalScene.game.canvas.height / 12 - -globalScene.scaledCanvas.height / 2 -
(this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2), (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2),
); );
} else { } else {
// Cursor on paying items // Cursor on paying items
this.cursorObj.setPosition( this.cursorObj.setPosition(
sliceWidth * (cursor + 1) + sliceWidth * 0.5 - 16, sliceWidth * (cursor + 1) + sliceWidth * 0.5 - 16,
-globalScene.game.canvas.height / 12 - -globalScene.scaledCanvas.height / 2 -
globalScene.game.canvas.height / 32 - globalScene.game.canvas.height / 32 -
(-14 + 28 * (this.rowCursor - (this.shopOptionsRows.length - 1))), (-14 + 28 * (this.rowCursor - (this.shopOptionsRows.length - 1))),
); );

View File

@ -10,17 +10,24 @@ import { fixedInt, getLocalizedSpriteKey } from "#utils/common";
import i18next from "i18next"; import i18next from "i18next";
export interface MoveInfoOverlaySettings { export interface MoveInfoOverlaySettings {
delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. /**
scale?: number; // scale the box? A scale of 0.5 is recommended * If true, showing the overlay will only set it to active and populate the fields
top?: boolean; // should the effect box be on top? * and the handler using this field has to manually call `setVisible` later.
right?: boolean; // should the effect box be on the right? */
onSide?: boolean; // should the effect be on the side? ignores top argument if true delayVisibility?: boolean;
//location and width of the component; unaffected by scaling /** Whether the effect box should be on top */
top?: boolean;
/** Whether the effect box should be on the right */
right?: boolean;
/** Whether the effect box should be on the side. Overrides the `top` param if `true`. */
onSide?: boolean;
/** `x` position of the component, unaffected by scaling */
x?: number; x?: number;
/** `y` position of the component, unaffected by scaling */
y?: number; y?: number;
/** Default is always half the screen, regardless of scale */ /** Width of the component, unaffected by scaling. Defaults to half the screen width. */
width?: number; width?: number;
/** Determines whether to display the small secondary box */ /** Whether to display the small secondary box */
hideEffectBox?: boolean; hideEffectBox?: boolean;
hideBg?: boolean; hideBg?: boolean;
} }
@ -54,12 +61,11 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
options.top = false; options.top = false;
} }
super(globalScene, options?.x, options?.y); super(globalScene, options?.x, options?.y);
const scale = options?.scale || 1; // set up the scale this.setScale(1);
this.setScale(scale);
this.options = options || {}; this.options = options || {};
// prepare the description box // prepare the description box
const width = (options?.width || MoveInfoOverlay.getWidth(scale)) / scale; // divide by scale as we always want this to be half a window wide const width = options?.width || MoveInfoOverlay.getWidth(); // we always want this to be half a window wide
this.descBg = addWindow( this.descBg = addWindow(
options?.onSide && !options?.right ? EFF_WIDTH : 0, options?.onSide && !options?.right ? EFF_WIDTH : 0,
options?.top ? EFF_HEIGHT : 0, options?.top ? EFF_HEIGHT : 0,
@ -88,19 +94,19 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
y: options?.y || 0, y: options?.y || 0,
}; };
if (maskPointOrigin.x < 0) { if (maskPointOrigin.x < 0) {
maskPointOrigin.x += globalScene.game.canvas.width / GLOBAL_SCALE; maskPointOrigin.x += globalScene.scaledCanvas.width;
} }
if (maskPointOrigin.y < 0) { if (maskPointOrigin.y < 0) {
maskPointOrigin.y += globalScene.game.canvas.height / GLOBAL_SCALE; maskPointOrigin.y += globalScene.scaledCanvas.height;
} }
const moveDescriptionTextMaskRect = globalScene.make.graphics(); const moveDescriptionTextMaskRect = globalScene.make.graphics();
moveDescriptionTextMaskRect.fillStyle(0xff0000); moveDescriptionTextMaskRect.fillStyle(0xff0000);
moveDescriptionTextMaskRect.fillRect( moveDescriptionTextMaskRect.fillRect(
maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER) * scale, maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER),
maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2) * scale, maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2),
width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2) * scale, width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2),
(DESC_HEIGHT - (BORDER - 2) * 2) * scale, DESC_HEIGHT - (BORDER - 2) * 2,
); );
moveDescriptionTextMaskRect.setScale(6); moveDescriptionTextMaskRect.setScale(6);
const moveDescriptionTextMask = this.createGeometryMask(moveDescriptionTextMaskRect); const moveDescriptionTextMask = this.createGeometryMask(moveDescriptionTextMaskRect);
@ -233,12 +239,12 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
} }
// width of this element // width of this element
static getWidth(_scale: number): number { static getWidth(): number {
return globalScene.game.canvas.width / GLOBAL_SCALE / 2; return globalScene.scaledCanvas.width / 2;
} }
// height of this element // height of this element
static getHeight(scale: number, onSide?: boolean): number { static getHeight(onSide?: boolean): number {
return (onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : EFF_HEIGHT + DESC_HEIGHT) * scale; return onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : EFF_HEIGHT + DESC_HEIGHT;
} }
} }

View File

@ -471,7 +471,7 @@ export class MysteryEncounterUiHandler extends UiHandler {
// View Party Button // View Party Button
const viewPartyText = addBBCodeTextObject( const viewPartyText = addBBCodeTextObject(
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
-24, -24,
getBBCodeFrag(i18next.t("mysteryEncounterMessages:view_party_button"), TextStyle.PARTY), getBBCodeFrag(i18next.t("mysteryEncounterMessages:view_party_button"), TextStyle.PARTY),
TextStyle.PARTY, TextStyle.PARTY,

View File

@ -14,7 +14,7 @@ export class PartyExpBar extends Phaser.GameObjects.Container {
public shown: boolean; public shown: boolean;
constructor() { constructor() {
super(globalScene, globalScene.game.canvas.width / 6, -(globalScene.game.canvas.height / 6) + 15); super(globalScene, globalScene.scaledCanvas.width, -globalScene.scaledCanvas.height + 15);
} }
setup(): void { setup(): void {
@ -66,7 +66,7 @@ export class PartyExpBar extends Phaser.GameObjects.Container {
this.tween = globalScene.tweens.add({ this.tween = globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6 - (this.bg.width - 5), x: globalScene.scaledCanvas.width - (this.bg.width - 5),
duration: 500 / Math.pow(2, globalScene.expGainsSpeed), duration: 500 / Math.pow(2, globalScene.expGainsSpeed),
ease: "Sine.easeOut", ease: "Sine.easeOut",
onComplete: () => { onComplete: () => {
@ -92,7 +92,7 @@ export class PartyExpBar extends Phaser.GameObjects.Container {
this.tween = globalScene.tweens.add({ this.tween = globalScene.tweens.add({
targets: this, targets: this,
x: globalScene.game.canvas.width / 6, x: globalScene.scaledCanvas.width,
duration: 500, duration: 500,
ease: "Sine.easeIn", ease: "Sine.easeIn",
onComplete: () => { onComplete: () => {

View File

@ -311,7 +311,7 @@ export class PartyUiHandler extends MessageUiHandler {
this.partyCancelButton = partyCancelButton; this.partyCancelButton = partyCancelButton;
this.optionsContainer = globalScene.add.container(globalScene.game.canvas.width / 6 - 1, -1); this.optionsContainer = globalScene.add.container(globalScene.scaledCanvas.width - 1, -1);
partyContainer.add(this.optionsContainer); partyContainer.add(this.optionsContainer);
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHandler();
@ -323,14 +323,12 @@ export class PartyUiHandler extends MessageUiHandler {
this.partyDiscardModeButton = partyDiscardModeButton; this.partyDiscardModeButton = partyDiscardModeButton;
// prepare move overlay. in case it appears to be too big, set the overlayScale to .5 // prepare move overlay
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({ this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale,
top: true, top: true,
x: 1, x: 1,
y: -MoveInfoOverlay.getHeight(overlayScale) - 1, y: -MoveInfoOverlay.getHeight() - 1,
width: globalScene.game.canvas.width / 12 - 30, width: globalScene.scaledCanvas.width / 2 - 30,
}); });
ui.add(this.moveInfoOverlay); ui.add(this.moveInfoOverlay);

View File

@ -10,7 +10,7 @@ export class PokeballTray extends Phaser.GameObjects.Container {
public shown: boolean; public shown: boolean;
constructor(player: boolean) { constructor(player: boolean) {
super(globalScene, player ? globalScene.game.canvas.width / 6 : 0, player ? -72 : -144); super(globalScene, player ? globalScene.scaledCanvas.width : 0, player ? -72 : -144);
this.player = player; this.player = player;
} }
@ -36,7 +36,7 @@ export class PokeballTray extends Phaser.GameObjects.Container {
.map((_, i) => .map((_, i) =>
globalScene.add.sprite( globalScene.add.sprite(
(this.player ? -83 : 76) + (this.player ? -83 : 76) +
(globalScene.game.canvas.width / 6) * (this.player ? -1 : 1) + globalScene.scaledCanvas.width * (this.player ? -1 : 1) +
10 * i * (this.player ? 1 : -1), 10 * i * (this.player ? 1 : -1),
-8, -8,
"pb_tray_ball", "pb_tray_ball",
@ -67,7 +67,7 @@ export class PokeballTray extends Phaser.GameObjects.Container {
this.bg.alpha = 1; this.bg.alpha = 1;
this.balls.forEach((ball, b) => { this.balls.forEach((ball, b) => {
ball.x += (globalScene.game.canvas.width / 6 + 104) * (this.player ? 1 : -1); ball.x += (globalScene.scaledCanvas.width + 104) * (this.player ? 1 : -1);
let ballFrame = "ball"; let ballFrame = "ball";
if (b >= party.length) { if (b >= party.length) {
ballFrame = "empty"; ballFrame = "empty";
@ -115,7 +115,7 @@ export class PokeballTray extends Phaser.GameObjects.Container {
this.balls.forEach((ball, b) => { this.balls.forEach((ball, b) => {
globalScene.tweens.add({ globalScene.tweens.add({
targets: ball, targets: ball,
x: `${this.player ? "-" : "+"}=${globalScene.game.canvas.width / 6}`, x: `${this.player ? "-" : "+"}=${globalScene.scaledCanvas.width}`,
duration: 250, duration: 250,
delay: b * 100, delay: b * 100,
ease: "Sine.easeIn", ease: "Sine.easeIn",

View File

@ -7,7 +7,6 @@ import { fixedInt } from "#utils/common";
export interface PokedexInfoOverlaySettings { export interface PokedexInfoOverlaySettings {
delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later.
scale?: number; // scale the box? A scale of 0.5 is recommended
//location and width of the component; unaffected by scaling //location and width of the component; unaffected by scaling
x?: number; x?: number;
y?: number; y?: number;
@ -36,17 +35,15 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
private maskPointOriginX: number; private maskPointOriginX: number;
private maskPointOriginY: number; private maskPointOriginY: number;
public scale: number;
public width: number; public width: number;
constructor(options?: PokedexInfoOverlaySettings) { constructor(options?: PokedexInfoOverlaySettings) {
super(globalScene, options?.x, options?.y); super(globalScene, options?.x, options?.y);
this.scale = options?.scale || 1; // set up the scale this.setScale(1);
this.setScale(this.scale);
this.options = options || {}; this.options = options || {};
// prepare the description box // prepare the description box
this.width = (options?.width || PokedexInfoOverlay.getWidth(this.scale)) / this.scale; // divide by scale as we always want this to be half a window wide this.width = options?.width || PokedexInfoOverlay.getWidth(); // we always want this to be half a window wide
this.descBg = addWindow(0, 0, this.width, DESC_HEIGHT); this.descBg = addWindow(0, 0, this.width, DESC_HEIGHT);
this.descBg.setOrigin(0, 0); this.descBg.setOrigin(0, 0);
this.add(this.descBg); this.add(this.descBg);
@ -61,19 +58,19 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
this.maskPointOriginY = options?.y || 0; this.maskPointOriginY = options?.y || 0;
if (this.maskPointOriginX < 0) { if (this.maskPointOriginX < 0) {
this.maskPointOriginX += globalScene.game.canvas.width / GLOBAL_SCALE; this.maskPointOriginX += globalScene.scaledCanvas.width;
} }
if (this.maskPointOriginY < 0) { if (this.maskPointOriginY < 0) {
this.maskPointOriginY += globalScene.game.canvas.height / GLOBAL_SCALE; this.maskPointOriginY += globalScene.scaledCanvas.height;
} }
this.textMaskRect = globalScene.make.graphics(); this.textMaskRect = globalScene.make.graphics();
this.textMaskRect.fillStyle(0xff0000); this.textMaskRect.fillStyle(0xff0000);
this.textMaskRect.fillRect( this.textMaskRect.fillRect(
this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginX + BORDER,
this.maskPointOriginY + (BORDER - 2) * this.scale, this.maskPointOriginY + (BORDER - 2),
this.width - BORDER * 2 * this.scale, this.width - BORDER * 2,
(DESC_HEIGHT - (BORDER - 2) * 2) * this.scale, DESC_HEIGHT - (BORDER - 2) * 2,
); );
this.textMaskRect.setScale(6); this.textMaskRect.setScale(6);
const textMask = this.createGeometryMask(this.textMaskRect); const textMask = this.createGeometryMask(this.textMaskRect);
@ -111,10 +108,10 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
this.textMaskRect.clear(); this.textMaskRect.clear();
this.textMaskRect.fillStyle(0xff0000); this.textMaskRect.fillStyle(0xff0000);
this.textMaskRect.fillRect( this.textMaskRect.fillRect(
this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginX + BORDER,
this.maskPointOriginY + (BORDER - 2) * this.scale + (48 - newHeight), this.maskPointOriginY + (BORDER - 2) + (48 - newHeight),
this.width - BORDER * 2 * this.scale, this.width - BORDER * 2,
(newHeight - (BORDER - 2) * 2) * this.scale, newHeight - (BORDER - 2) * 2,
); );
const updatedMask = this.createGeometryMask(this.textMaskRect); const updatedMask = this.createGeometryMask(this.textMaskRect);
this.desc.setMask(updatedMask); this.desc.setMask(updatedMask);
@ -167,12 +164,12 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
} }
// width of this element // width of this element
static getWidth(_scale: number): number { static getWidth(): number {
return globalScene.game.canvas.width / GLOBAL_SCALE / 2; return globalScene.scaledCanvas.width / 2;
} }
// height of this element // height of this element
static getHeight(scale: number, _onSide?: boolean): number { static getHeight(): number {
return DESC_HEIGHT * scale; return DESC_HEIGHT;
} }
} }

View File

@ -299,15 +299,15 @@ export class PokedexPageUiHandler extends MessageUiHandler {
const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en"; const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en";
const textSettings = languageSettings[langSettingKey]; const textSettings = languageSettings[langSettingKey];
this.starterSelectContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.starterSelectContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
ui.add(this.starterSelectContainer); ui.add(this.starterSelectContainer);
const bgColor = globalScene.add.rectangle( const bgColor = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0x006860, 0x006860,
); );
bgColor.setOrigin(0, 0); bgColor.setOrigin(0, 0);
@ -602,7 +602,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.filterInstructionsContainer.setVisible(true); this.filterInstructionsContainer.setVisible(true);
this.starterSelectContainer.add(this.filterInstructionsContainer); this.starterSelectContainer.add(this.filterInstructionsContainer);
this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6); this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.scaledCanvas.height);
this.starterSelectMessageBoxContainer.setVisible(false); this.starterSelectMessageBoxContainer.setVisible(false);
this.starterSelectContainer.add(this.starterSelectMessageBoxContainer); this.starterSelectContainer.add(this.starterSelectMessageBoxContainer);
@ -629,7 +629,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.menuContainer = globalScene.add.container(-130, 0); this.menuContainer = globalScene.add.container(-130, 0);
this.menuContainer.setName("menu"); this.menuContainer.setName("menu");
this.menuContainer.setInteractive( this.menuContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
@ -659,10 +659,10 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale; this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale;
this.menuBg = addWindow( this.menuBg = addWindow(
globalScene.game.canvas.width / 6 - 83, globalScene.scaledCanvas.width - 83,
0, 0,
this.optionSelectText.displayWidth + 19 + 24 * this.scale, this.optionSelectText.displayWidth + 19 + 24 * this.scale,
globalScene.game.canvas.height / 6 - 2, globalScene.scaledCanvas.height - 2,
); );
this.menuBg.setOrigin(0, 0); this.menuBg.setOrigin(0, 0);
@ -682,19 +682,16 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.menuContainer.bringToTop(this.baseStatsOverlay); this.menuContainer.bringToTop(this.baseStatsOverlay);
// add the info overlay last to be the top most ui element and prevent the IVs from overlaying this // add the info overlay last to be the top most ui element and prevent the IVs from overlaying this
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({ this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale,
top: true, top: true,
x: 1, x: 1,
y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29, y: globalScene.scaledCanvas.height - MoveInfoOverlay.getHeight() - 29,
}); });
this.starterSelectContainer.add(this.moveInfoOverlay); this.starterSelectContainer.add(this.moveInfoOverlay);
this.infoOverlay = new PokedexInfoOverlay({ this.infoOverlay = new PokedexInfoOverlay({
scale: overlayScale,
x: 1, x: 1,
y: globalScene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight(overlayScale) - 29, y: globalScene.scaledCanvas.height - PokedexInfoOverlay.getHeight() - 29,
}); });
this.starterSelectContainer.add(this.infoOverlay); this.starterSelectContainer.add(this.infoOverlay);
@ -1103,7 +1100,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.starterSelectMessageBoxContainer.setY(0); this.starterSelectMessageBoxContainer.setY(0);
this.message.setY(4); this.message.setY(4);
} else { } else {
this.starterSelectMessageBoxContainer.setY(globalScene.game.canvas.height / 6); this.starterSelectMessageBoxContainer.setY(globalScene.scaledCanvas.height);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.message.setY(singleLine ? -22 : -37); this.message.setY(singleLine ? -22 : -37);
} }

View File

@ -245,15 +245,15 @@ export class PokedexUiHandler extends MessageUiHandler {
const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en"; const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en";
const textSettings = languageSettings[langSettingKey]; const textSettings = languageSettings[langSettingKey];
this.starterSelectContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.starterSelectContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
ui.add(this.starterSelectContainer); ui.add(this.starterSelectContainer);
const bgColor = globalScene.add.rectangle( const bgColor = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0x006860, 0x006860,
); );
bgColor.setOrigin(0, 0); bgColor.setOrigin(0, 0);
@ -544,7 +544,7 @@ export class PokedexUiHandler extends MessageUiHandler {
this.type2Icon.setOrigin(0, 0); this.type2Icon.setOrigin(0, 0);
this.starterSelectContainer.add(this.type2Icon); this.starterSelectContainer.add(this.type2Icon);
this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6); this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.scaledCanvas.height);
this.starterSelectMessageBoxContainer.setVisible(false); this.starterSelectMessageBoxContainer.setVisible(false);
this.starterSelectContainer.add(this.starterSelectMessageBoxContainer); this.starterSelectContainer.add(this.starterSelectMessageBoxContainer);
@ -784,7 +784,7 @@ export class PokedexUiHandler extends MessageUiHandler {
this.starterSelectMessageBoxContainer.setY(0); this.starterSelectMessageBoxContainer.setY(0);
this.message.setY(4); this.message.setY(4);
} else { } else {
this.starterSelectMessageBoxContainer.setY(globalScene.game.canvas.height / 6); this.starterSelectMessageBoxContainer.setY(globalScene.scaledCanvas.height);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.message.setY(singleLine ? -22 : -37); this.message.setY(singleLine ? -22 : -37);
} }

View File

@ -54,14 +54,14 @@ export class RunHistoryUiHandler extends MessageUiHandler {
const loadSessionBg = globalScene.add.rectangle( const loadSessionBg = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
-globalScene.game.canvas.height / 6, -globalScene.scaledCanvas.height,
0x006860, 0x006860,
); );
loadSessionBg.setOrigin(0, 0); loadSessionBg.setOrigin(0, 0);
this.runSelectContainer.add(loadSessionBg); this.runSelectContainer.add(loadSessionBg);
this.runContainerInitialY = -globalScene.game.canvas.height / 6 + 8; this.runContainerInitialY = -globalScene.scaledCanvas.height + 8;
this.runsContainer = globalScene.add.container(8, this.runContainerInitialY); this.runsContainer = globalScene.add.container(8, this.runContainerInitialY);
this.runSelectContainer.add(this.runsContainer); this.runSelectContainer.add(this.runsContainer);

View File

@ -74,7 +74,7 @@ export class RunInfoUiHandler extends UiHandler {
} }
override async setup() { override async setup() {
this.runContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.runContainer = globalScene.add.container(1, -globalScene.scaledCanvas.height + 1);
// The import of the modifiersModule is loaded here to sidestep async/await issues. // The import of the modifiersModule is loaded here to sidestep async/await issues.
this.modifiersModule = Modifier; this.modifiersModule = Modifier;
this.runContainer.setVisible(false); this.runContainer.setVisible(false);
@ -120,7 +120,7 @@ export class RunInfoUiHandler extends UiHandler {
// Creates Header and adds to this.runContainer // Creates Header and adds to this.runContainer
this.addHeader(); this.addHeader();
this.statsBgWidth = (globalScene.game.canvas.width / 6 - 2) / 3; this.statsBgWidth = (globalScene.scaledCanvas.width - 2) / 3;
// Creates Run Result Container // Creates Run Result Container
this.runResultContainer = globalScene.add.container(0, 24); this.runResultContainer = globalScene.add.container(0, 24);
@ -147,7 +147,7 @@ export class RunInfoUiHandler extends UiHandler {
this.showParty(true); this.showParty(true);
this.runContainer.setInteractive( this.runContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
this.getUi().bringToTop(this.runContainer); this.getUi().bringToTop(this.runContainer);
@ -174,7 +174,7 @@ export class RunInfoUiHandler extends UiHandler {
* It does not check if the run has any PokemonHeldItemModifiers though. * It does not check if the run has any PokemonHeldItemModifiers though.
*/ */
private addHeader() { private addHeader() {
const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6 - 2, 24); const headerBg = addWindow(0, 0, globalScene.scaledCanvas.width - 2, 24);
headerBg.setOrigin(0, 0); headerBg.setOrigin(0, 0);
this.runContainer.add(headerBg); this.runContainer.add(headerBg);
if (this.runInfo.modifiers.length !== 0) { if (this.runInfo.modifiers.length !== 0) {
@ -723,7 +723,7 @@ export class RunInfoUiHandler extends UiHandler {
private parsePartyInfo(): void { private parsePartyInfo(): void {
const party = this.runInfo.party; const party = this.runInfo.party;
const currentLanguage = i18next.resolvedLanguage ?? "en"; const currentLanguage = i18next.resolvedLanguage ?? "en";
const windowHeight = (globalScene.game.canvas.height / 6 - 23) / 6; const windowHeight = (globalScene.scaledCanvas.height - 23) / 6;
party.forEach((p: PokemonData, i: number) => { party.forEach((p: PokemonData, i: number) => {
const pokemonInfoWindow = new RoundRectangle(globalScene, 0, 14, this.statsBgWidth * 2 + 10, windowHeight - 2, 3); const pokemonInfoWindow = new RoundRectangle(globalScene, 0, 14, this.statsBgWidth * 2 + 10, windowHeight - 2, 3);
@ -971,8 +971,8 @@ export class RunInfoUiHandler extends UiHandler {
endCard.setOrigin(0); endCard.setOrigin(0);
endCard.setScale(0.5); endCard.setScale(0.5);
const text = addTextObject( const text = addTextObject(
globalScene.game.canvas.width / 12, globalScene.scaledCanvas.width / 2,
globalScene.game.canvas.height / 6 - 16, globalScene.scaledCanvas.height - 16,
i18next.t("battle:congratulations"), i18next.t("battle:congratulations"),
TextStyle.SUMMARY, TextStyle.SUMMARY,
{ fontSize: "128px" }, { fontSize: "128px" },

View File

@ -54,14 +54,14 @@ export class SaveSlotSelectUiHandler extends MessageUiHandler {
const loadSessionBg = globalScene.add.rectangle( const loadSessionBg = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
-globalScene.game.canvas.height / 6, -globalScene.scaledCanvas.height,
0x006860, 0x006860,
); );
loadSessionBg.setOrigin(0, 0); loadSessionBg.setOrigin(0, 0);
this.saveSlotSelectContainer.add(loadSessionBg); this.saveSlotSelectContainer.add(loadSessionBg);
this.sessionSlotsContainerInitialY = -globalScene.game.canvas.height / 6 + 8; this.sessionSlotsContainerInitialY = -globalScene.scaledCanvas.height + 8;
this.sessionSlotsContainer = globalScene.add.container(8, this.sessionSlotsContainerInitialY); this.sessionSlotsContainer = globalScene.add.container(8, this.sessionSlotsContainerInitialY);
this.saveSlotSelectContainer.add(this.sessionSlotsContainer); this.saveSlotSelectContainer.add(this.sessionSlotsContainer);

View File

@ -8,7 +8,7 @@ export class SavingIconHandler extends Phaser.GameObjects.Container {
private shown: boolean; private shown: boolean;
constructor() { constructor() {
super(globalScene, globalScene.game.canvas.width / 6 - 4, globalScene.game.canvas.height / 6 - 4); super(globalScene, globalScene.scaledCanvas.width - 4, globalScene.scaledCanvas.height - 4);
} }
setup(): void { setup(): void {

View File

@ -73,8 +73,8 @@ export abstract class AbstractBindingUiHandler extends UiHandler {
// Setup backgrounds and text objects for UI. // Setup backgrounds and text objects for UI.
this.titleBg = addWindow( this.titleBg = addWindow(
globalScene.game.canvas.width / 6 - this.getWindowWidth(), globalScene.scaledCanvas.width - this.getWindowWidth(),
-(globalScene.game.canvas.height / 6) + 28 + 21, -globalScene.scaledCanvas.height + 28 + 21,
this.getWindowWidth(), this.getWindowWidth(),
24, 24,
); );
@ -82,8 +82,8 @@ export abstract class AbstractBindingUiHandler extends UiHandler {
this.optionSelectContainer.add(this.titleBg); this.optionSelectContainer.add(this.titleBg);
this.actionBg = addWindow( this.actionBg = addWindow(
globalScene.game.canvas.width / 6 - this.getWindowWidth(), globalScene.scaledCanvas.width - this.getWindowWidth(),
-(globalScene.game.canvas.height / 6) + this.getWindowHeight() + 28 + 21 + 21, -globalScene.scaledCanvas.height + this.getWindowHeight() + 28 + 21 + 21,
this.getWindowWidth(), this.getWindowWidth(),
24, 24,
); );
@ -102,8 +102,8 @@ export abstract class AbstractBindingUiHandler extends UiHandler {
this.optionSelectContainer.add(this.timerText); this.optionSelectContainer.add(this.timerText);
this.optionSelectBg = addWindow( this.optionSelectBg = addWindow(
globalScene.game.canvas.width / 6 - this.getWindowWidth(), globalScene.scaledCanvas.width - this.getWindowWidth(),
-(globalScene.game.canvas.height / 6) + this.getWindowHeight() + 28, -globalScene.scaledCanvas.height + this.getWindowHeight() + 28,
this.getWindowWidth(), this.getWindowWidth(),
this.getWindowHeight(), this.getWindowHeight(),
); );

View File

@ -96,11 +96,11 @@ export abstract class AbstractControlSettingsUiHandler extends UiHandler {
const ui = this.getUi(); const ui = this.getUi();
this.navigationIcons = {}; this.navigationIcons = {};
this.settingsContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.settingsContainer = globalScene.add.container(1, -globalScene.scaledCanvas.height + 1);
this.settingsContainer.setName(`settings-${this.titleSelected}`); this.settingsContainer.setName(`settings-${this.titleSelected}`);
this.settingsContainer.setInteractive( this.settingsContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
@ -109,15 +109,15 @@ export abstract class AbstractControlSettingsUiHandler extends UiHandler {
this.optionsBg = addWindow( this.optionsBg = addWindow(
0, 0,
this.navigationContainer.height, this.navigationContainer.height,
globalScene.game.canvas.width / 6 - 2, globalScene.scaledCanvas.width - 2,
globalScene.game.canvas.height / 6 - 16 - this.navigationContainer.height - 2, globalScene.scaledCanvas.height - 16 - this.navigationContainer.height - 2,
); );
this.optionsBg.setOrigin(0, 0); this.optionsBg.setOrigin(0, 0);
this.actionsBg = addWindow( this.actionsBg = addWindow(
0, 0,
globalScene.game.canvas.height / 6 - this.navigationContainer.height, globalScene.scaledCanvas.height - this.navigationContainer.height,
globalScene.game.canvas.width / 6 - 2, globalScene.scaledCanvas.width - 2,
22, 22,
); );
this.actionsBg.setOrigin(0, 0); this.actionsBg.setOrigin(0, 0);
@ -597,7 +597,7 @@ export abstract class AbstractControlSettingsUiHandler extends UiHandler {
// Check if the cursor object exists, if not, create it. // Check if the cursor object exists, if not, create it.
if (!this.cursorObj) { if (!this.cursorObj) {
const cursorWidth = globalScene.game.canvas.width / 6 - (this.scrollBar.visible ? 16 : 10); const cursorWidth = globalScene.scaledCanvas.width - (this.scrollBar.visible ? 16 : 10);
this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, cursorWidth, 16, 1, 1, 1, 1); this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, cursorWidth, 16, 1, 1, 1, 1);
this.cursorObj.setOrigin(0, 0); // Set the origin to the top-left corner. this.cursorObj.setOrigin(0, 0); // Set the origin to the top-left corner.
this.optionsContainer.add(this.cursorObj); // Add the cursor to the options container. this.optionsContainer.add(this.cursorObj); // Add the cursor to the options container.

View File

@ -56,10 +56,10 @@ export class AbstractSettingsUiHandler extends MessageUiHandler {
setup() { setup() {
const ui = this.getUi(); const ui = this.getUi();
this.settingsContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.settingsContainer = globalScene.add.container(1, -globalScene.scaledCanvas.height + 1);
this.settingsContainer.setName(`settings-${this.title}`); this.settingsContainer.setName(`settings-${this.title}`);
this.settingsContainer.setInteractive( this.settingsContainer.setInteractive(
new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6 - 20), new Phaser.Geom.Rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height - 20),
Phaser.Geom.Rectangle.Contains, Phaser.Geom.Rectangle.Contains,
); );
@ -70,16 +70,16 @@ export class AbstractSettingsUiHandler extends MessageUiHandler {
this.optionsBg = addWindow( this.optionsBg = addWindow(
0, 0,
this.navigationContainer.height, this.navigationContainer.height,
globalScene.game.canvas.width / 6 - 2, globalScene.scaledCanvas.width - 2,
globalScene.game.canvas.height / 6 - 16 - this.navigationContainer.height - 2, globalScene.scaledCanvas.height - 16 - this.navigationContainer.height - 2,
); );
this.optionsBg.setName("window-options-bg"); this.optionsBg.setName("window-options-bg");
this.optionsBg.setOrigin(0, 0); this.optionsBg.setOrigin(0, 0);
const actionsBg = addWindow( const actionsBg = addWindow(
0, 0,
globalScene.game.canvas.height / 6 - this.navigationContainer.height, globalScene.scaledCanvas.height - this.navigationContainer.height,
globalScene.game.canvas.width / 6 - 2, globalScene.scaledCanvas.width - 2,
22, 22,
); );
actionsBg.setOrigin(0, 0); actionsBg.setOrigin(0, 0);
@ -375,7 +375,7 @@ export class AbstractSettingsUiHandler extends MessageUiHandler {
const ret = super.setCursor(cursor); const ret = super.setCursor(cursor);
if (!this.cursorObj) { if (!this.cursorObj) {
const cursorWidth = globalScene.game.canvas.width / 6 - (this.scrollBar.visible ? 16 : 10); const cursorWidth = globalScene.scaledCanvas.width - (this.scrollBar.visible ? 16 : 10);
this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, cursorWidth, 16, 1, 1, 1, 1); this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, cursorWidth, 16, 1, 1, 1, 1);
this.cursorObj.setOrigin(0, 0); this.cursorObj.setOrigin(0, 0);
this.optionsContainer.add(this.cursorObj); this.optionsContainer.add(this.cursorObj);

View File

@ -124,7 +124,7 @@ export class NavigationMenu extends Phaser.GameObjects.Container {
*/ */
setup() { setup() {
const navigationManager = NavigationManager.getInstance(); const navigationManager = NavigationManager.getInstance();
const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6 - 2, 24); const headerBg = addWindow(0, 0, globalScene.scaledCanvas.width - 2, 24);
headerBg.setOrigin(0, 0); headerBg.setOrigin(0, 0);
this.add(headerBg); this.add(headerBg);
this.width = headerBg.width; this.width = headerBg.width;

View File

@ -408,15 +408,15 @@ export class StarterSelectUiHandler extends MessageUiHandler {
const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en"; const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en";
const textSettings = languageSettings[langSettingKey]; const textSettings = languageSettings[langSettingKey];
this.starterSelectContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.starterSelectContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
ui.add(this.starterSelectContainer); ui.add(this.starterSelectContainer);
const bgColor = globalScene.add.rectangle( const bgColor = globalScene.add.rectangle(
0, 0,
0, 0,
globalScene.game.canvas.width / 6, globalScene.scaledCanvas.width,
globalScene.game.canvas.height / 6, globalScene.scaledCanvas.height,
0x006860, 0x006860,
); );
bgColor.setOrigin(0, 0); bgColor.setOrigin(0, 0);
@ -1164,7 +1164,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
this.filterInstructionsContainer.setVisible(true); this.filterInstructionsContainer.setVisible(true);
this.starterSelectContainer.add(this.filterInstructionsContainer); this.starterSelectContainer.add(this.filterInstructionsContainer);
this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6); this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.scaledCanvas.height);
this.starterSelectMessageBoxContainer.setVisible(false); this.starterSelectMessageBoxContainer.setVisible(false);
this.starterSelectContainer.add(this.starterSelectMessageBoxContainer); this.starterSelectContainer.add(this.starterSelectMessageBoxContainer);
@ -1188,12 +1188,10 @@ export class StarterSelectUiHandler extends MessageUiHandler {
this.starterSelectContainer.add(this.statsContainer); this.starterSelectContainer.add(this.statsContainer);
// add the info overlay last to be the top most ui element and prevent the IVs from overlaying this // add the info overlay last to be the top most ui element and prevent the IVs from overlaying this
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({ this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale,
top: true, top: true,
x: 1, x: 1,
y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29, y: globalScene.scaledCanvas.height - MoveInfoOverlay.getHeight() - 29,
}); });
this.starterSelectContainer.add(this.moveInfoOverlay); this.starterSelectContainer.add(this.moveInfoOverlay);
@ -1394,7 +1392,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
this.starterSelectMessageBoxContainer.setY(0); this.starterSelectMessageBoxContainer.setY(0);
this.message.setY(4); this.message.setY(4);
} else { } else {
this.starterSelectMessageBoxContainer.setY(globalScene.game.canvas.height / 6); this.starterSelectMessageBoxContainer.setY(globalScene.scaledCanvas.height);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.message.setY(singleLine ? -22 : -37); this.message.setY(singleLine ? -22 : -37);
} }

View File

@ -36,12 +36,12 @@ export class TitleUiHandler extends OptionSelectUiHandler {
const ui = this.getUi(); const ui = this.getUi();
this.titleContainer = globalScene.add.container(0, -(globalScene.game.canvas.height / 6)); this.titleContainer = globalScene.add.container(0, -globalScene.scaledCanvas.height);
this.titleContainer.setName("title"); this.titleContainer.setName("title");
this.titleContainer.setAlpha(0); this.titleContainer.setAlpha(0);
ui.add(this.titleContainer); ui.add(this.titleContainer);
const logo = globalScene.add.image(globalScene.game.canvas.width / 6 / 2, 8, "logo"); const logo = globalScene.add.image(globalScene.scaledCanvas.width / 2, 8, "logo");
logo.setOrigin(0.5, 0); logo.setOrigin(0.5, 0);
this.titleContainer.add(logo); this.titleContainer.add(logo);
@ -53,7 +53,7 @@ export class TitleUiHandler extends OptionSelectUiHandler {
this.playerCountLabel = addTextObject( this.playerCountLabel = addTextObject(
// Actual y position will be determined after the title menu has been populated with options // Actual y position will be determined after the title menu has been populated with options
globalScene.game.canvas.width / 6 - 2, globalScene.scaledCanvas.width - 2,
0, 0,
`? ${i18next.t("menu:playersOnline")}`, `? ${i18next.t("menu:playersOnline")}`,
TextStyle.MESSAGE, TextStyle.MESSAGE,
@ -131,7 +131,7 @@ export class TitleUiHandler extends OptionSelectUiHandler {
if (ret) { if (ret) {
// Moving player count to top of the menu // Moving player count to top of the menu
this.playerCountLabel.setY(globalScene.game.canvas.height / 6 - 13 - this.getWindowHeight()); this.playerCountLabel.setY(globalScene.scaledCanvas.height - 13 - this.getWindowHeight());
this.splashMessage = randItem(getSplashMessages()); this.splashMessage = randItem(getSplashMessages());
this.splashMessageText.setText( this.splashMessageText.setText(

View File

@ -121,7 +121,7 @@ export class UI extends Phaser.GameObjects.Container {
private overlayActive: boolean; private overlayActive: boolean;
constructor() { constructor() {
super(globalScene, 0, globalScene.game.canvas.height / 6); super(globalScene, 0, globalScene.scaledCanvas.height);
this.mode = UiMode.MESSAGE; this.mode = UiMode.MESSAGE;
this.modeChain = []; this.modeChain = [];
@ -180,13 +180,7 @@ export class UI extends Phaser.GameObjects.Container {
for (const handler of this.handlers) { for (const handler of this.handlers) {
handler.setup(); handler.setup();
} }
this.overlay = globalScene.add.rectangle( this.overlay = globalScene.add.rectangle(0, 0, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height, 0);
0,
0,
globalScene.game.canvas.width / 6,
globalScene.game.canvas.height / 6,
0,
);
this.overlay.setName("rect-ui-overlay"); this.overlay.setName("rect-ui-overlay");
this.overlay.setOrigin(0, 0); this.overlay.setOrigin(0, 0);
globalScene.uiContainer.add(this.overlay); globalScene.uiContainer.add(this.overlay);
@ -437,15 +431,15 @@ export class UI extends Phaser.GameObjects.Container {
if (isTouch) { if (isTouch) {
// If we are in the top left quadrant on mobile, move the tooltip to the top right corner // If we are in the top left quadrant on mobile, move the tooltip to the top right corner
if (pointerX <= globalScene.game.canvas.width / 2 && pointerY <= globalScene.game.canvas.height / 2) { if (pointerX <= globalScene.game.canvas.width / 2 && pointerY <= globalScene.game.canvas.height / 2) {
x = globalScene.game.canvas.width / 6 - tooltipWidth - padding; x = globalScene.scaledCanvas.width - tooltipWidth - padding;
} }
} else { } else {
// If the tooltip would go offscreen on the right, or is close to it, move to the left of the cursor // If the tooltip would go offscreen on the right, or is close to it, move to the left of the cursor
if (x + tooltipWidth + padding > globalScene.game.canvas.width / 6) { if (x + tooltipWidth + padding > globalScene.scaledCanvas.width) {
x = Math.max(padding, pointerX / 6 - tooltipWidth - padding); x = Math.max(padding, pointerX / 6 - tooltipWidth - padding);
} }
// If the tooltip would go offscreen at the bottom, or is close to it, move above the cursor // If the tooltip would go offscreen at the bottom, or is close to it, move above the cursor
if (y + tooltipHeight + padding > globalScene.game.canvas.height / 6) { if (y + tooltipHeight + padding > globalScene.scaledCanvas.height) {
y = Math.max(padding, pointerY / 6 - tooltipHeight - padding); y = Math.max(padding, pointerY / 6 - tooltipHeight - padding);
} }
} }

View File

@ -5,7 +5,7 @@ import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Baneful Bunker", () => { describe("Moves - Baneful Bunker", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -26,55 +26,51 @@ describe("Moves - Baneful Bunker", () => {
game.override game.override
.battleStyle("single") .battleStyle("single")
.moveset(MoveId.SLASH) .moveset([MoveId.SLASH, MoveId.FLASH_CANNON])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.TOXAPEX)
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.enemyMoveset(MoveId.BANEFUL_BUNKER) .enemyMoveset(MoveId.BANEFUL_BUNKER)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and poison attackers that make contact", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); function expectProtected() {
const enemyPokemon = game.field.getEnemyPokemon(); expect(game.scene.getEnemyPokemon()?.hp).toBe(game.scene.getEnemyPokemon()?.getMaxHp());
expect(game.scene.getPlayerPokemon()?.status?.effect).toBe(StatusEffect.POISON);
}
it("should protect the user and poison attackers that make contact", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
game.move.select(MoveId.SLASH); game.move.select(MoveId.SLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); expectProtected();
}); });
test("should protect the user and poison attackers that make contact, regardless of accuracy checks", async () => {
it("should ignore accuracy checks", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon();
game.move.select(MoveId.SLASH); game.move.select(MoveId.SLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase"); // baneful bunker
await game.phaseInterceptor.to("MoveEffectPhase");
await game.move.forceMiss(); await game.move.forceMiss();
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); expectProtected();
}); });
test("should not poison attackers that don't make contact", async () => { it("should block non-contact moves without poisoning attackers", async () => {
game.override.moveset(MoveId.FLASH_CANNON);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const toxapex = game.field.getEnemyPokemon();
game.move.select(MoveId.FLASH_CANNON); game.move.select(MoveId.FLASH_CANNON);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("MoveEffectPhase");
await game.move.forceMiss();
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeFalsy(); expect(toxapex.hp).toBe(toxapex.getMaxHp());
expect(charizard.status?.effect).toBeUndefined();
}); });
}); });

View File

@ -1,12 +1,14 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { ArenaTagSide } from "#enums/arena-tag-side";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerIndex } from "#enums/battler-index";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { BerryPhase } from "#phases/berry-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Crafty Shield", () => { describe("Moves - Crafty Shield", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,68 +29,100 @@ describe("Moves - Crafty Shield", () => {
game.override game.override
.battleStyle("double") .battleStyle("double")
.moveset([MoveId.CRAFTY_SHIELD, MoveId.SPLASH, MoveId.SWORDS_DANCE]) .enemySpecies(SpeciesId.DUSKNOIR)
.enemySpecies(SpeciesId.SNORLAX) .enemyMoveset(MoveId.GROWL)
.enemyMoveset([MoveId.GROWL])
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and allies from status moves", async () => { it("should protect the user and allies from status moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.GROWL);
await game.move.forceEnemyMove(MoveId.GROWL);
game.move.select(MoveId.CRAFTY_SHIELD); await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.getStatStage(Stat.ATK)).toBe(0);
expect(blastoise.getStatStage(Stat.ATK)).toBe(0);
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
}); });
test("should not protect the user and allies from attack moves", async () => { it("should not protect the user and allies from attack moves", async () => {
game.override.enemyMoveset([MoveId.TACKLE]); game.override.enemyMoveset(MoveId.TACKLE);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.CRAFTY_SHIELD); game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, 1); game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.isFullHp()).toBe(false);
expect(blastoise.isFullHp()).toBe(false);
expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy();
}); });
test("should protect the user and allies from moves that ignore other protection", async () => { it("should not block entry hazards and field-targeted moves", async () => {
game.override.enemySpecies(SpeciesId.DUSCLOPS).enemyMoveset([MoveId.CURSE]); game.override.enemyMoveset([MoveId.PERISH_SONG, MoveId.TOXIC_SPIKES]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.CRAFTY_SHIELD); game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, 1); game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.PERISH_SONG);
await game.move.forceEnemyMove(MoveId.TOXIC_SPIKES);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(BerryPhase, false); expect(game.scene.arena.getTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER)).toBeDefined();
expect(charizard.getTag(BattlerTagType.PERISH_SONG)).toBeDefined();
leadPokemon.forEach(p => expect(p.getTag(BattlerTagType.CURSED)).toBeUndefined()); expect(blastoise.getTag(BattlerTagType.PERISH_SONG)).toBeDefined();
}); });
test("should not block allies' self-targeted moves", async () => { it("should protect the user and allies from moves that ignore other protection", async () => {
game.override.moveset(MoveId.CURSE);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.CRAFTY_SHIELD); game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.select(MoveId.SWORDS_DANCE, 1); game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.CURSE, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.CURSE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to(BerryPhase, false); await game.toEndOfTurn();
expect(leadPokemon[0].getStatStage(Stat.ATK)).toBe(0); expect(charizard.getTag(BattlerTagType.CURSED)).toBeUndefined();
expect(leadPokemon[1].getStatStage(Stat.ATK)).toBe(2); expect(blastoise.getTag(BattlerTagType.CURSED)).toBeUndefined();
const [dusknoir1, dusknoir2] = game.scene.getEnemyField();
expect(dusknoir1).toHaveFullHp();
expect(dusknoir2).toHaveFullHp();
});
it("should not block allies' self or ally-targeted moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const [charizard, blastoise] = game.scene.getPlayerField();
game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.use(MoveId.SWORDS_DANCE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
expect(blastoise.getStatStage(Stat.ATK)).toBe(2);
game.move.use(MoveId.HOWL, BattlerIndex.PLAYER);
game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
expect(charizard.getStatStage(Stat.ATK)).toBe(1);
expect(blastoise.getStatStage(Stat.ATK)).toBe(3);
}); });
}); });

View File

@ -1,9 +1,10 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { HitResult } from "#enums/hit-result";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Endure", () => { describe("Moves - Endure", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -22,7 +23,7 @@ describe("Moves - Endure", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.moveset([MoveId.THUNDER, MoveId.BULLET_SEED, MoveId.TOXIC, MoveId.SHEER_COLD]) .moveset([MoveId.THUNDER, MoveId.BULLET_SEED, MoveId.SHEER_COLD])
.ability(AbilityId.SKILL_LINK) .ability(AbilityId.SKILL_LINK)
.startingLevel(100) .startingLevel(100)
.battleStyle("single") .battleStyle("single")
@ -32,7 +33,7 @@ describe("Moves - Endure", () => {
.enemyMoveset(MoveId.ENDURE); .enemyMoveset(MoveId.ENDURE);
}); });
it("should let the pokemon survive with 1 HP", async () => { it("should let the pokemon survive with 1 HP from attacks", async () => {
await game.classicMode.startBattle([SpeciesId.ARCEUS]); await game.classicMode.startBattle([SpeciesId.ARCEUS]);
game.move.select(MoveId.THUNDER); game.move.select(MoveId.THUNDER);
@ -41,7 +42,7 @@ describe("Moves - Endure", () => {
expect(game.field.getEnemyPokemon().hp).toBe(1); expect(game.field.getEnemyPokemon().hp).toBe(1);
}); });
it("should let the pokemon survive with 1 HP when hit with a multihit move", async () => { it("should let the pokemon survive with 1 HP from multi-strike moves", async () => {
await game.classicMode.startBattle([SpeciesId.ARCEUS]); await game.classicMode.startBattle([SpeciesId.ARCEUS]);
game.move.select(MoveId.BULLET_SEED); game.move.select(MoveId.BULLET_SEED);
@ -57,30 +58,27 @@ describe("Moves - Endure", () => {
game.move.select(MoveId.SHEER_COLD); game.move.select(MoveId.SHEER_COLD);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemy.isFainted()).toBeFalsy(); expect(enemy.hp).toBe(1);
}); });
// comprehensive indirect damage test copied from Reviver Seed test // comprehensive indirect damage test copied from Reviver Seed test
it.each([ it.each([
{ moveType: "Damaging Move Chip Damage", move: MoveId.SALT_CURE }, { moveType: "Damaging Move Chip", move: MoveId.SALT_CURE },
{ moveType: "Chip Damage", move: MoveId.LEECH_SEED }, { moveType: "Status Move Chip", move: MoveId.LEECH_SEED },
{ moveType: "Trapping Chip Damage", move: MoveId.WHIRLPOOL }, { moveType: "Partial Trapping move", move: MoveId.WHIRLPOOL },
{ moveType: "Status Effect Damage", move: MoveId.TOXIC }, { moveType: "Status Effect", move: MoveId.TOXIC },
{ moveType: "Weather", move: MoveId.SANDSTORM }, { moveType: "Weather", move: MoveId.SANDSTORM },
])("should not prevent fainting from $moveType", async ({ move }) => { ])("should not prevent fainting from $moveType Damage", async ({ move }) => {
game.override game.override.moveset(move).enemyLevel(100);
.enemyLevel(1)
.startingLevel(100)
.enemySpecies(SpeciesId.MAGIKARP)
.moveset(move)
.enemyMoveset(MoveId.ENDURE);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]); await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]);
const enemy = game.field.getEnemyPokemon(); const enemy = game.field.getEnemyPokemon();
enemy.damageAndUpdate(enemy.hp - 1); enemy.hp = 2;
// force attack to do 1 dmg (for salt cure)
vi.spyOn(enemy, "getAttackDamage").mockReturnValue({ cancelled: false, result: HitResult.EFFECTIVE, damage: 1 });
game.move.select(move); game.move.select(move);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemy.isFainted()).toBeTruthy(); expect(enemy.isFainted()).toBe(true);
}); });
}); });

View File

@ -1,15 +1,14 @@
import { ArenaTrapTag } from "#data/arena-tag";
import { allMoves } from "#data/data-lists"; import { allMoves } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { ArenaTagSide } from "#enums/arena-tag-side";
import { BattlerIndex } from "#enums/battler-index"; import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result"; import { MoveResult } from "#enums/move-result";
import { MoveUseMode } from "#enums/move-use-mode";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Protect", () => { describe("Moves - Protect", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,90 +26,210 @@ describe("Moves - Protect", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.battleStyle("single") .battleStyle("single")
.moveset([MoveId.PROTECT]) .moveset([MoveId.PROTECT, MoveId.SPIKY_SHIELD, MoveId.ENDURE, MoveId.SPLASH])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.enemyMoveset([MoveId.TACKLE]) .enemyMoveset(MoveId.LUMINA_CRASH)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user from attacks", async () => { it("should protect the user from attacks and their secondary effects", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(charizard.getStatStage(Stat.SPDEF)).toBe(0);
expect(charizard);
}); });
test("should prevent secondary effects from the opponent's attack", async () => { it.each<{ numTurns: number; chance: number }>([
game.override.enemyMoveset([MoveId.CEASELESS_EDGE]); { numTurns: 1, chance: 3 },
vi.spyOn(allMoves[MoveId.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); { numTurns: 2, chance: 9 },
{ numTurns: 3, chance: 27 },
{ numTurns: 4, chance: 81 },
])("should have a 1/$chance success rate after $numTurns successful uses", async ({ numTurns, chance }) => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.scene.getPlayerPokemon()!;
// mock RNG roll to suceed unless exactly the desired chance is hit
vi.spyOn(charizard, "randBattleSeedInt").mockImplementation(range => (range !== chance ? 0 : 1));
const conditionSpy = vi.spyOn(allMoves[MoveId.PROTECT]["conditions"][0], "apply");
// click protect many times
for (let x = 0; x < numTurns; x++) {
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.hp).toBe(charizard.getMaxHp());
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(conditionSpy).toHaveLastReturnedWith(true);
}
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.toNextTurn();
await game.phaseInterceptor.to("BerryPhase", false); expect(charizard.hp).toBeLessThan(charizard.getMaxHp());
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(conditionSpy).toHaveLastReturnedWith(false);
expect(game.scene.arena.getTagOnSide(ArenaTrapTag, ArenaTagSide.ENEMY)).toBeUndefined();
}); });
test("should protect the user from status moves", async () => { it("should share fail chance with all move variants", async () => {
game.override.enemyMoveset([MoveId.CHARM]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
charizard.summonData.moveHistory = [
{ move: MoveId.ENDURE, result: MoveResult.SUCCESS, targets: [BattlerIndex.PLAYER], useMode: MoveUseMode.NORMAL },
{
move: MoveId.SPIKY_SHIELD,
result: MoveResult.SUCCESS,
targets: [BattlerIndex.PLAYER],
useMode: MoveUseMode.NORMAL,
},
];
// force protect to fail on anything >=2 uses (1/9 chance)
vi.spyOn(charizard, "randBattleSeedInt").mockImplementation(range => (range >= 9 ? 1 : 0));
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.toNextTurn();
await game.phaseInterceptor.to("BerryPhase", false); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0);
}); });
test("should stop subsequent hits of a multi-hit move", async () => { it("should reset fail chance on move failure", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.scene.getPlayerPokemon()!;
// force protect to always fail if RNG roll attempt is made
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should reset fail chance on using another move", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.scene.getPlayerPokemon()!;
// force protect to always fail if RNG roll attempt is made
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPLASH);
await game.toNextTurn();
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should reset fail chance on starting a new wave", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.field.getPlayerPokemon();
// force protect to always fail if RNG roll attempt is made
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.PROTECT);
// Wait until move end phase to kill opponent to ensure protect doesn't fail due to going last
await game.phaseInterceptor.to("MoveEndPhase");
await game.doKillOpponents();
await game.toNextWave();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should not be blocked by Psychic Terrain", async () => {
game.override.ability(AbilityId.PSYCHIC_SURGE);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.scene.getPlayerPokemon()!;
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should stop subsequent hits of multi-hit moves", async () => {
game.override.enemyMoveset([MoveId.TACHYON_CUTTER]); game.override.enemyMoveset([MoveId.TACHYON_CUTTER]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(enemyPokemon.turnData.hitCount).toBe(1); expect(enemyPokemon.turnData.hitCount).toBe(1);
}); });
test("should fail if the user is the last to move in the turn", async () => { it("should fail if the user moves last in the turn", async () => {
game.override.enemyMoveset([MoveId.PROTECT]); game.override.enemyMoveset(MoveId.PROTECT);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(leadPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
it("should not block Protection-bypassing moves or Future Sight", async () => {
game.override.enemyMoveset([MoveId.FUTURE_SIGHT, MoveId.MIGHTY_CLEAVE, MoveId.SPORE]);
await game.classicMode.startBattle([SpeciesId.AGGRON]);
const aggron = game.scene.getPlayerPokemon()!;
vi.spyOn(aggron, "randBattleSeedInt").mockReturnValue(0);
// Turn 1: setup future sight
game.move.select(MoveId.PROTECT);
await game.move.forceEnemyMove(MoveId.FUTURE_SIGHT);
await game.toNextTurn();
// Turn 2: mighty cleave
game.move.select(MoveId.PROTECT);
await game.move.forceEnemyMove(MoveId.MIGHTY_CLEAVE);
await game.toNextTurn();
expect(aggron.hp).toBeLessThan(aggron.getMaxHp());
aggron.hp = aggron.getMaxHp();
// turn 3: Future Sight hits
game.move.select(MoveId.PROTECT);
await game.move.forceEnemyMove(MoveId.SPORE);
await game.toNextTurn();
expect(aggron.hp).toBeLessThan(aggron.getMaxHp());
expect(aggron.status?.effect).toBeUndefined(); // check that protect actually worked
});
// TODO: Add test
it.todo("should not reset counter when throwing balls");
}); });

View File

@ -3,10 +3,9 @@ import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result"; import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Quick Guard", () => { describe("Moves - Quick Guard", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,74 +26,72 @@ describe("Moves - Quick Guard", () => {
game.override game.override
.battleStyle("double") .battleStyle("double")
.moveset([MoveId.QUICK_GUARD, MoveId.SPLASH, MoveId.FOLLOW_ME]) .moveset([MoveId.QUICK_GUARD, MoveId.SPLASH, MoveId.SPIKY_SHIELD])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
.enemyMoveset([MoveId.QUICK_ATTACK]) .enemyMoveset(MoveId.QUICK_ATTACK)
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.BALL_FETCH)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and allies from priority moves", async () => { it("should protect the user and allies from priority moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const playerPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.QUICK_GUARD);
game.move.select(MoveId.SPLASH, 1);
game.move.select(MoveId.QUICK_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.QUICK_ATTACK, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.QUICK_ATTACK, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(blastoise.hp).toBe(blastoise.getMaxHp());
}); });
test("should protect the user and allies from Prankster-boosted moves", async () => { it.each<{ name: string; move: MoveId; ability: AbilityId }>([
game.override.enemyAbility(AbilityId.PRANKSTER).enemyMoveset([MoveId.GROWL]); { name: "Prankster", move: MoveId.SPORE, ability: AbilityId.PRANKSTER },
{ name: "Gale Wings", move: MoveId.BRAVE_BIRD, ability: AbilityId.GALE_WINGS },
])("should protect the user and allies from $name-boosted moves", async ({ move, ability }) => {
game.override.enemyMoveset(move).enemyAbility(ability);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const playerPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.QUICK_GUARD);
game.move.select(MoveId.SPLASH, 1);
game.move.select(MoveId.QUICK_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(move, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(move, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(blastoise.hp).toBe(blastoise.getMaxHp());
expect(charizard.status?.effect).toBeUndefined();
expect(blastoise.status?.effect).toBeUndefined();
}); });
test("should stop subsequent hits of a multi-hit priority move", async () => { it("should increment (but not respect) other protection moves' fail counters", async () => {
game.override.enemyMoveset([MoveId.WATER_SHURIKEN]); game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const playerPokemon = game.scene.getPlayerField();
const enemyPokemon = game.scene.getEnemyField();
game.move.select(MoveId.QUICK_GUARD);
game.move.select(MoveId.FOLLOW_ME, 1);
await game.phaseInterceptor.to("BerryPhase", false);
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
enemyPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1));
});
test("should fail if the user is the last to move in the turn", async () => {
game.override.battleStyle("single").enemyMoveset([MoveId.QUICK_GUARD]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const playerPokemon = game.field.getPlayerPokemon(); const charizard = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.field.getEnemyPokemon(); // force protect to fail on anything >0 uses
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.QUICK_GUARD); game.move.select(MoveId.QUICK_GUARD);
await game.toNextTurn();
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
await game.phaseInterceptor.to("BerryPhase", false); game.move.select(MoveId.QUICK_GUARD);
await game.toNextTurn();
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); // ignored fail chance
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
}); });

View File

@ -1,11 +1,12 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { BerryPhase } from "#phases/berry-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Wide Guard", () => { describe("Moves - Wide Guard", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -26,71 +27,84 @@ describe("Moves - Wide Guard", () => {
game.override game.override
.battleStyle("double") .battleStyle("double")
.moveset([MoveId.WIDE_GUARD, MoveId.SPLASH, MoveId.SURF]) .moveset([MoveId.WIDE_GUARD, MoveId.SPLASH, MoveId.SURF, MoveId.SPIKY_SHIELD])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
.enemyMoveset(MoveId.SWIFT) .enemyMoveset([MoveId.SWIFT, MoveId.GROWL, MoveId.TACKLE])
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and allies from multi-target attack moves", async () => { it("should protect the user and allies from multi-target attack and status moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const [charizard, blastoise] = game.scene.getPlayerField();
const leadPokemon = game.scene.getPlayerField(); game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.SWIFT);
await game.move.forceEnemyMove(MoveId.GROWL);
await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.WIDE_GUARD); expect(charizard.hp).toBe(charizard.getMaxHp());
game.move.select(MoveId.SPLASH, 1); expect(blastoise.hp).toBe(blastoise.getMaxHp());
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
await game.phaseInterceptor.to(BerryPhase, false); expect(blastoise.getStatStage(Stat.ATK)).toBe(0);
leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
}); });
test("should protect the user and allies from multi-target status moves", async () => { it("should not protect the user and allies from single-target moves", async () => {
game.override.enemyMoveset([MoveId.GROWL]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.WIDE_GUARD); expect(charizard.hp).toBeLessThan(charizard.getMaxHp());
game.move.select(MoveId.SPLASH, 1); expect(blastoise.hp).toBeLessThan(blastoise.getMaxHp());
await game.phaseInterceptor.to(BerryPhase, false);
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
}); });
test("should not protect the user and allies from single-target moves", async () => { it("should protect the user from its ally's multi-target move", async () => {
game.override.enemyMoveset([MoveId.TACKLE]); game.override.enemyMoveset(MoveId.SPLASH);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const charizard = game.scene.getPlayerPokemon()!;
const [snorlax1, snorlax2] = game.scene.getEnemyField();
game.move.select(MoveId.WIDE_GUARD); game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, 1); game.move.select(MoveId.SURF, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(snorlax1.hp).toBeLessThan(snorlax1.getMaxHp());
expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); expect(snorlax2.hp).toBeLessThan(snorlax2.getMaxHp());
}); });
test("should protect the user from its ally's multi-target move", async () => { it("should increment (but not respect) other protection moves' fail counters", async () => {
game.override.enemyMoveset([MoveId.SPLASH]); game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); const charizard = game.scene.getPlayerPokemon()!;
// force protect to fail on anything other than a guaranteed success
const leadPokemon = game.scene.getPlayerField(); vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(MoveId.WIDE_GUARD); game.move.select(MoveId.WIDE_GUARD);
game.move.select(MoveId.SURF, 1); await game.toNextTurn();
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp()); // ignored fail chance
enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); game.move.select(MoveId.WIDE_GUARD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
// ignored fail chance
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
}); });