Fix fusion move learning bug and inaccurate HP in battle info
parent
3e9fdc2d0a
commit
3961550f62
|
@ -1558,6 +1558,7 @@ export default class BattleScene extends SceneBase {
|
|||
const soundName = modifier.type.soundName;
|
||||
this.validateAchvs(ModifierAchv, modifier);
|
||||
const modifiersToRemove: PersistentModifier[] = [];
|
||||
const modifierPromises: Promise<boolean>[] = [];
|
||||
if (modifier instanceof PersistentModifier) {
|
||||
if (modifier instanceof TerastallizeModifier)
|
||||
modifiersToRemove.push(...(this.findModifiers(m => m instanceof TerastallizeModifier && m.pokemonId === modifier.pokemonId)));
|
||||
|
@ -1596,11 +1597,14 @@ export default class BattleScene extends SceneBase {
|
|||
} else if (modifier instanceof FusePokemonModifier)
|
||||
args.push(this.getPokemonById(modifier.fusePokemonId) as PlayerPokemon);
|
||||
|
||||
if (modifier.shouldApply(args))
|
||||
modifier.apply(args);
|
||||
if (modifier.shouldApply(args)) {
|
||||
const result = modifier.apply(args);
|
||||
if (result instanceof Promise)
|
||||
modifierPromises.push(result);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.allSettled(this.party.map(p => p.updateInfo(instant))).then(() => resolve());
|
||||
return Promise.allSettled([this.party.map(p => p.updateInfo(instant)), ...modifierPromises]).then(() => resolve());
|
||||
} else {
|
||||
const args = [ this ];
|
||||
if (modifier.shouldApply(args))
|
||||
|
|
|
@ -601,8 +601,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
return this.getMaxHp() - this.hp;
|
||||
}
|
||||
|
||||
getHpRatio(): number {
|
||||
return Math.floor((this.hp / this.getMaxHp()) * 100) / 100;
|
||||
getHpRatio(precise: boolean = false): number {
|
||||
return precise
|
||||
? this.hp / this.getMaxHp()
|
||||
: ((this.hp / this.getMaxHp()) * 100) / 100;
|
||||
}
|
||||
|
||||
generateGender(): void {
|
||||
|
@ -2324,7 +2326,6 @@ export class PlayerPokemon extends Pokemon {
|
|||
let partyMemberIndex = this.scene.getParty().indexOf(this);
|
||||
if (partyMemberIndex > fusedPartyMemberIndex)
|
||||
partyMemberIndex--;
|
||||
pokemon.getMoveset(true).map(m => this.scene.unshiftPhase(new LearnMovePhase(this.scene, partyMemberIndex, m.getMove().id)));
|
||||
const fusedPartyMemberHeldModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& (m as PokemonHeldItemModifier).pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
|
||||
const transferModifiers: Promise<boolean>[] = [];
|
||||
|
@ -2334,6 +2335,8 @@ export class PlayerPokemon extends Pokemon {
|
|||
this.scene.updateModifiers(true, true).then(() => {
|
||||
this.scene.removePartyMemberModifiers(fusedPartyMemberIndex);
|
||||
this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0];
|
||||
const newPartyMemberIndex = this.scene.getParty().indexOf(this);
|
||||
pokemon.getMoveset(true).map(m => this.scene.unshiftPhase(new LearnMovePhase(this.scene, newPartyMemberIndex, m.getMove().id)));
|
||||
pokemon.destroy();
|
||||
this.updateFusionPalette();
|
||||
resolve();
|
||||
|
|
|
@ -109,7 +109,7 @@ export abstract class Modifier {
|
|||
return true;
|
||||
}
|
||||
|
||||
abstract apply(args: any[]): boolean;
|
||||
abstract apply(args: any[]): boolean | Promise<boolean>;
|
||||
}
|
||||
|
||||
export abstract class PersistentModifier extends Modifier {
|
||||
|
@ -1203,10 +1203,10 @@ export class FusePokemonModifier extends ConsumablePokemonModifier {
|
|||
return super.shouldApply(args) && args[1] instanceof PlayerPokemon && this.fusePokemonId === (args[1] as PlayerPokemon).id;
|
||||
}
|
||||
|
||||
apply(args: any[]): boolean {
|
||||
(args[0] as PlayerPokemon).fuse(args[1] as PlayerPokemon);
|
||||
|
||||
return true;
|
||||
apply(args: any[]): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
(args[0] as PlayerPokemon).fuse(args[1] as PlayerPokemon).then(() => resolve(true));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4102,16 +4102,22 @@ export class SelectModifierPhase extends BattlePhase {
|
|||
}
|
||||
|
||||
const applyModifier = (modifier: Modifier, playSound: boolean = false) => {
|
||||
this.scene.addModifier(modifier, false, playSound);
|
||||
const result = this.scene.addModifier(modifier, false, playSound);
|
||||
if (cost) {
|
||||
this.scene.money -= cost;
|
||||
this.scene.updateMoneyText();
|
||||
this.scene.playSound('buy');
|
||||
(this.scene.ui.getHandler() as ModifierSelectUiHandler).updateCostText();
|
||||
} else {
|
||||
this.scene.ui.clearText();
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
super.end();
|
||||
const doEnd = () => {
|
||||
this.scene.ui.clearText();
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
super.end();
|
||||
};
|
||||
if (result instanceof Promise)
|
||||
result.then(() => doEnd());
|
||||
else
|
||||
doEnd();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||
this.updateBossSegmentDividers(pokemon as EnemyPokemon);
|
||||
}
|
||||
|
||||
this.hpBar.setScale(pokemon.getHpRatio(), 1);
|
||||
this.hpBar.setScale(pokemon.getHpRatio(true), 1);
|
||||
this.lastHpFrame = this.hpBar.scaleX > 0.5 ? 'high' : this.hpBar.scaleX > 0.25 ? 'medium' : 'low';
|
||||
this.hpBar.setFrame(this.lastHpFrame);
|
||||
if (this.player)
|
||||
|
@ -356,7 +356,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||
this.scene.tweens.add({
|
||||
targets: this.hpBar,
|
||||
ease: 'Sine.easeOut',
|
||||
scaleX: pokemon.getHpRatio(),
|
||||
scaleX: pokemon.getHpRatio(true),
|
||||
duration: duration,
|
||||
onUpdate: () => {
|
||||
if (this.player && this.lastHp !== pokemon.hp) {
|
||||
|
|
Loading…
Reference in New Issue