QOL - Settings to choose party Exp display at the end of fight (#488)

* added settings to manage how to display party experience at the end of fight

* added back stats changes support when setting is on but ignored when on skip

* removed a useless parameter

* added new level in the text

* only Lv. UP if level is greated than 200

* cleanup

* added some comment

* TSDoc comment block

* EXP_Party -> EXP_Party_Display, Only Up -> Level Up Notification

* better duration for the level up notification

* typo

Co-authored-by: Samuel H <flashfireex@gmail.com>

---------

Co-authored-by: Samuel H <flashfireex@gmail.com>
pull/502/merge
Greenlamp2 2024-05-10 15:54:14 +02:00 committed by GitHub
parent 22a73642df
commit b32b802ab4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 55 additions and 9 deletions

View File

@ -101,6 +101,19 @@ export default class BattleScene extends SceneBase {
public experimentalSprites: boolean = false; public experimentalSprites: boolean = false;
public moveAnimations: boolean = true; public moveAnimations: boolean = true;
public expGainsSpeed: integer = 0; public expGainsSpeed: integer = 0;
/**
* Defines the experience gain display mode.
*
* @remarks
* The `expParty` can have several modes:
* - `0` - Default: The normal experience gain display, nothing changed.
* - `1` - Level Up Notification: Displays the level up in the small frame instead of a message.
* - `2` - Skip: No level up frame nor message.
*
* Modes `1` and `2` are still compatible with stats display, level up, new move, etc.
* @default 0 - Uses the default normal experience gain display.
*/
public expParty: integer = 0;
public hpBarSpeed: integer = 0; public hpBarSpeed: integer = 0;
public fusionPaletteSwaps: boolean = true; public fusionPaletteSwaps: boolean = true;
public enableTouchControls: boolean = false; public enableTouchControls: boolean = false;

View File

@ -3745,11 +3745,20 @@ export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase {
this.scene.unshiftPhase(new HidePartyExpBarPhase(this.scene)); this.scene.unshiftPhase(new HidePartyExpBarPhase(this.scene));
pokemon.updateInfo(); pokemon.updateInfo();
if (this.scene.expGainsSpeed < 3) { if (this.scene.expParty === 2) { // 2 - Skip - no level up frame nor message
this.scene.partyExpBar.showPokemonExp(pokemon, exp.value).then(() => {
if (newLevel > lastLevel)
this.end(); this.end();
else } else if (this.scene.expParty === 1) { // 1 - Only level up - we display the level up in the small frame instead of a message
if (newLevel > lastLevel) { // this means if we level up
// instead of displaying the exp gain in the small frame, we display the new level
// we use the same method for mode 0 & 1, by giving a parameter saying to display the exp or the level
this.scene.partyExpBar.showPokemonExp(pokemon, exp.value, this.scene.expParty === 1, newLevel).then(() => {
setTimeout(() => this.end(), 800 / Math.pow(2, this.scene.expGainsSpeed/2));
});
} else {
this.end();
}
} else if (this.scene.expGainsSpeed < 3) {
this.scene.partyExpBar.showPokemonExp(pokemon, exp.value, this.scene.expParty === 1, newLevel).then(() => {
setTimeout(() => this.end(), 500 / Math.pow(2, this.scene.expGainsSpeed)); setTimeout(() => this.end(), 500 / Math.pow(2, this.scene.expGainsSpeed));
}); });
} else { } else {
@ -3780,6 +3789,7 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
this.lastLevel = lastLevel; this.lastLevel = lastLevel;
this.level = level; this.level = level;
this.scene = scene;
} }
start() { start() {
@ -3794,8 +3804,15 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
const prevStats = pokemon.stats.slice(0); const prevStats = pokemon.stats.slice(0);
pokemon.calculateStats(); pokemon.calculateStats();
pokemon.updateInfo(); pokemon.updateInfo();
if (this.scene.expParty === 0) { // 0 - default - the normal exp gain display, nothing changed
this.scene.playSound('level_up_fanfare'); this.scene.playSound('level_up_fanfare');
this.scene.ui.showText(i18next.t('battle:levelUp', { pokemonName: this.getPokemon().name, level: this.level }), null, () => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()), null, true); this.scene.ui.showText(i18next.t('battle:levelUp', { pokemonName: this.getPokemon().name, level: this.level }), null, () => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()), null, true);
} else if (this.scene.expParty === 2) { // 2 - Skip - no level up frame nor message
this.end();
} else { // 1 - Only level up - we display the level up in the small frame instead of a message
// we still want to display the stats if activated
this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end());
}
if (this.level <= 100) { if (this.level <= 100) {
const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1); const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1);
for (let lm of levelMoves) for (let lm of levelMoves)

View File

@ -21,6 +21,7 @@ export enum Setting {
Move_Animations = "MOVE_ANIMATIONS", Move_Animations = "MOVE_ANIMATIONS",
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS", Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
EXP_Gains_Speed = "EXP_GAINS_SPEED", EXP_Gains_Speed = "EXP_GAINS_SPEED",
EXP_Party_Display = "EXP_PARTY_DISPLAY",
HP_Bar_Speed = "HP_BAR_SPEED", HP_Bar_Speed = "HP_BAR_SPEED",
Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS", Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS",
Player_Gender = "PLAYER_GENDER", Player_Gender = "PLAYER_GENDER",
@ -53,6 +54,7 @@ export const settingOptions: SettingOptions = {
[Setting.Move_Animations]: [ 'Off', 'On' ], [Setting.Move_Animations]: [ 'Off', 'On' ],
[Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ], [Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ],
[Setting.EXP_Gains_Speed]: [ 'Normal', 'Fast', 'Faster', 'Skip' ], [Setting.EXP_Gains_Speed]: [ 'Normal', 'Fast', 'Faster', 'Skip' ],
[Setting.EXP_Party_Display]: [ 'Normal', 'Level Up Notification', 'Skip' ],
[Setting.HP_Bar_Speed]: [ 'Normal', 'Fast', 'Faster', 'Instant' ], [Setting.HP_Bar_Speed]: [ 'Normal', 'Fast', 'Faster', 'Instant' ],
[Setting.Fusion_Palette_Swaps]: [ 'Off', 'On' ], [Setting.Fusion_Palette_Swaps]: [ 'Off', 'On' ],
[Setting.Player_Gender]: [ 'Boy', 'Girl' ], [Setting.Player_Gender]: [ 'Boy', 'Girl' ],
@ -77,6 +79,7 @@ export const settingDefaults: SettingDefaults = {
[Setting.Move_Animations]: 1, [Setting.Move_Animations]: 1,
[Setting.Show_Stats_on_Level_Up]: 1, [Setting.Show_Stats_on_Level_Up]: 1,
[Setting.EXP_Gains_Speed]: 0, [Setting.EXP_Gains_Speed]: 0,
[Setting.EXP_Party_Display]: 0,
[Setting.HP_Bar_Speed]: 0, [Setting.HP_Bar_Speed]: 0,
[Setting.Fusion_Palette_Swaps]: 1, [Setting.Fusion_Palette_Swaps]: 1,
[Setting.Player_Gender]: 0, [Setting.Player_Gender]: 0,
@ -134,6 +137,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
case Setting.EXP_Gains_Speed: case Setting.EXP_Gains_Speed:
scene.expGainsSpeed = value; scene.expGainsSpeed = value;
break; break;
case Setting.EXP_Party_Display:
scene.expParty = value;
break;
case Setting.HP_Bar_Speed: case Setting.HP_Bar_Speed:
scene.hpBarSpeed = value; scene.hpBarSpeed = value;
break; break;

View File

@ -29,7 +29,7 @@ export default class PartyExpBar extends Phaser.GameObjects.Container {
this.shown = false; this.shown = false;
} }
showPokemonExp(pokemon: Pokemon, expValue: integer): Promise<void> { showPokemonExp(pokemon: Pokemon, expValue: integer, showOnlyLevelUp: boolean, newLevel: number): Promise<void> {
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
if (this.shown) if (this.shown)
return resolve(); return resolve();
@ -39,7 +39,17 @@ export default class PartyExpBar extends Phaser.GameObjects.Container {
this.add(this.pokemonIcon); this.add(this.pokemonIcon);
// if we want to only display the level in the small frame
if (showOnlyLevelUp) {
if (newLevel > 200) { // if the level is greater than 200, we only display Lv. UP
this.expText.setText('Lv. UP');
} else { // otherwise we display Lv. Up and the new level
this.expText.setText(`Lv. UP: ${newLevel.toString()}`);
}
} else {
// if we want to display the exp
this.expText.setText(`+${expValue.toString()}`); this.expText.setText(`+${expValue.toString()}`);
}
this.bg.width = this.expText.displayWidth + 28; this.bg.width = this.expText.displayWidth + 28;