Compare commits

..

3 Commits

Author SHA1 Message Date
Greenlamp2
622885767d
Enforce Consistent Spacing with ESLint's space-before-blocks and keyword-spacing Rules (#1308)
* added rule no-trailing-spaces

* added rule space-before-block

* added rule keyword spacing
2024-05-23 19:19:20 -05:00
Greenlamp2
e2be6ba002
added rule no-trailing-spaces (#1307) 2024-05-23 18:45:04 -05:00
Franck TROUILLEZ
68e94845ab
Add BattleInfo to TargetSelectUiHandler to move when target selected (#1255)
This change allows to move the box containing the battle info of the ennemy pokemons during double battle when the user has to choose a target. In addition to the pokemon opacity constantly changing, the battle info will also move up and down to indicate which Pokemon is targeted.

It exposes the BattleInfo object from the Pokemon object through an accessor method.
2024-05-23 18:28:53 -04:00
117 changed files with 891 additions and 840 deletions

View File

@ -22,7 +22,13 @@
"@typescript-eslint/no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
"@typescript-eslint/brace-style": ["error", "1tbs"]
"@typescript-eslint/brace-style": ["error", "1tbs"],
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
"skipBlankLines": false, // Enforces the rule even on blank lines
"ignoreComments": false // Enforces the rule on lines containing comments
}],
"space-before-blocks": ["error", "always"], // Enforces a space before blocks
"keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords
}
}
]

View File

@ -2765,6 +2765,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.battleInfo?.destroy();
super.destroy();
}
getBattleInfo(): BattleInfo {
return this.battleInfo;
}
}
export default interface Pokemon {

View File

@ -12,6 +12,8 @@ import { BattleStat } from "#app/data/battle-stat";
const battleStatOrder = [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.ACC, BattleStat.EVA, BattleStat.SPD ];
export default class BattleInfo extends Phaser.GameObjects.Container {
private baseY: number;
private player: boolean;
private mini: boolean;
private boss: boolean;
@ -57,6 +59,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
constructor(scene: Phaser.Scene, x: number, y: number, player: boolean) {
super(scene, x, y);
this.baseY = y;
this.player = player;
this.mini = !player;
this.boss = false;
@ -417,6 +420,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.x += 10 * (offset === this.player ? 1 : -1);
this.y += 27 * (offset ? 1 : -1);
this.baseY = this.y;
}
updateInfo(pokemon: Pokemon, instant?: boolean): Promise<void> {
@ -655,6 +659,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
this.statNumbers[i].setFrame(battleStats[s].toString());
});
}
getBaseY(): number {
return this.baseY;
}
resetY(): void {
this.y = this.baseY;
}
}
export class PlayerBattleInfo extends BattleInfo {

View File

@ -16,6 +16,7 @@ export default class TargetSelectUiHandler extends UiHandler {
private targets: BattlerIndex[];
private targetFlashTween: Phaser.Tweens.Tween;
private targetBattleInfoMoveTween: Phaser.Tweens.Tween;
constructor(scene: BattleScene) {
super(scene, Mode.TARGET_SELECT);
@ -116,6 +117,25 @@ export default class TargetSelectUiHandler extends UiHandler {
}
});
if (this.targetBattleInfoMoveTween) {
this.targetBattleInfoMoveTween.stop();
const lastTarget = this.scene.getField()[lastCursor];
if (lastTarget) {
lastTarget.getBattleInfo().resetY();
}
}
const targetBattleInfo = target.getBattleInfo();
this.targetBattleInfoMoveTween = this.scene.tweens.add({
targets: [ targetBattleInfo ],
y: { start: targetBattleInfo.getBaseY(), to: targetBattleInfo.getBaseY() + 1 },
loop: -1,
duration: Utils.fixedInt(250),
ease: "Linear",
yoyo: true
});
return ret;
}
@ -128,6 +148,15 @@ export default class TargetSelectUiHandler extends UiHandler {
if (target) {
target.setAlpha(1);
}
const targetBattleInfo = target.getBattleInfo();
if (this.targetBattleInfoMoveTween) {
this.targetBattleInfoMoveTween.stop();
this.targetBattleInfoMoveTween = null;
}
if (targetBattleInfo) {
targetBattleInfo.resetY();
}
}
clear() {