Add rare candy modifier
This commit is contained in:
parent
2c71550b35
commit
a1b857fbc6
Binary file not shown.
|
@ -102,8 +102,11 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||
}
|
||||
|
||||
updateInfo(pokemon: Pokemon, callback?: Function) {
|
||||
if (!this.scene)
|
||||
if (!this.scene) {
|
||||
if (callback)
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
const updatePokemonHp = () => {
|
||||
const duration = Utils.clampInt(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000);
|
||||
|
@ -158,7 +161,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||
const relLevelExp = getLevelRelExp(this.lastLevel + 1, battler.species.growthRate);
|
||||
const levelExp = levelUp ? relLevelExp : battler.levelExp;
|
||||
let ratio = levelExp / relLevelExp;
|
||||
let duration = ((levelExp - this.lastLevelExp) / relLevelExp) * 1650;
|
||||
let duration = this.visible ? ((levelExp - this.lastLevelExp) / relLevelExp) * 1650 : 0;
|
||||
if (duration)
|
||||
this.scene.sound.play('exp');
|
||||
this.scene.tweens.add({
|
||||
targets: this.expBar,
|
||||
|
@ -179,6 +183,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||
}
|
||||
},
|
||||
onComplete: () => {
|
||||
if (duration)
|
||||
this.scene.sound.stopByKey('exp');
|
||||
if (ratio === 1) {
|
||||
this.lastLevelExp = 0;
|
||||
|
|
|
@ -9,7 +9,7 @@ import { ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, getModifie
|
|||
import PartyUiHandler from "./ui/party-ui-handler";
|
||||
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball";
|
||||
import { pokemonLevelMoves } from "./pokemon-level-moves";
|
||||
import { MoveAnim, loadMoveAnimAssets } from "./battle-anims";
|
||||
import { MoveAnim, initAnim, loadMoveAnimAssets } from "./battle-anims";
|
||||
import { StatusEffect } from "./status-effect";
|
||||
|
||||
export class BattlePhase {
|
||||
|
@ -776,11 +776,13 @@ export class LearnMovePhase extends PartyMemberPokemonPhase {
|
|||
|
||||
if (pokemon.moveset.length < 4) {
|
||||
pokemon.moveset.push(new PokemonMove(this.moveId, 0, 0));
|
||||
loadMoveAnimAssets(this.scene, [ this.moveId ])
|
||||
initAnim(this.moveId).then(() => {
|
||||
loadMoveAnimAssets(this.scene, [ this.moveId ], true)
|
||||
.then(() => {
|
||||
this.scene.sound.play('level_up_fanfare');
|
||||
this.scene.ui.showText(`${pokemon.name} learned\n${Utils.toPokemonUpperCase(move.name)}!`, null, () => this.end(), null, true);
|
||||
});
|
||||
});
|
||||
} else
|
||||
this.end();
|
||||
}
|
||||
|
@ -965,16 +967,14 @@ export class SelectModifierPhase extends BattlePhase {
|
|||
this.scene.ui.setModeWithoutClear(Mode.PARTY, false, (slotIndex: integer) => {
|
||||
if (slotIndex < 6) {
|
||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT);
|
||||
this.scene.addModifier(types[cursor].newModifier(this.scene.getParty()[slotIndex]));
|
||||
this.scene.addModifier(types[cursor].newModifier(this.scene.getParty()[slotIndex])).then(() => super.end());
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
super.end();
|
||||
} else
|
||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT);
|
||||
}, pokemonModifierType.selectFilter);
|
||||
} else {
|
||||
this.scene.addModifier(types[cursor].newModifier())
|
||||
this.scene.addModifier(types[cursor].newModifier()).then(() => super.end());
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
super.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -410,7 +410,8 @@ export default class BattleScene extends Phaser.Scene {
|
|||
this.phaseQueue.push(new CommandPhase(this));
|
||||
}
|
||||
|
||||
addModifier(modifier: Modifier): void {
|
||||
addModifier(modifier: Modifier): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
if (modifier.add(this.modifierBar, this.modifiers))
|
||||
this.sound.play('restore');
|
||||
|
||||
|
@ -418,9 +419,12 @@ export default class BattleScene extends Phaser.Scene {
|
|||
const args = [ this ];
|
||||
if (modifier.shouldApply(args))
|
||||
modifier.apply(args);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
let pokemonToUpdate = 0;
|
||||
|
||||
if (modifier instanceof PokemonModifier) {
|
||||
for (let p in this.party) {
|
||||
const pokemon = this.party[p];
|
||||
|
@ -431,10 +435,19 @@ export default class BattleScene extends Phaser.Scene {
|
|||
modifier.apply(args);
|
||||
}
|
||||
|
||||
pokemonToUpdate++;
|
||||
|
||||
pokemon.calculateStats();
|
||||
pokemon.updateInfo();
|
||||
pokemon.updateInfo(() => {
|
||||
if (!(--pokemonToUpdate))
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!pokemonToUpdate)
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
getModifier(modifierType: { new(...args: any[]): Modifier }): Modifier {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { LevelUpPhase } from "./battle-phase";
|
||||
import BattleScene from "./battle-scene";
|
||||
import { getLevelTotalExp } from "./exp";
|
||||
import { getPokeballName, PokeballType } from "./pokeball";
|
||||
import Pokemon, { PlayerPokemon } from "./pokemon";
|
||||
import { Stat, getStatName } from "./pokemon-stat";
|
||||
|
@ -240,6 +242,24 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier {
|
|||
}
|
||||
}
|
||||
|
||||
export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier {
|
||||
constructor(type: ModifierType, pokemonId: integer) {
|
||||
super(type, pokemonId);
|
||||
}
|
||||
|
||||
apply(args: any[]): boolean {
|
||||
const pokemon = args[0] as PlayerPokemon;
|
||||
pokemon.level++;
|
||||
pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate);
|
||||
pokemon.levelExp = 0;
|
||||
|
||||
const scene = pokemon.scene as BattleScene;
|
||||
scene.unshiftPhase(new LevelUpPhase(scene, scene.getParty().indexOf(pokemon), pokemon.level));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExpBoosterModifier extends Modifier {
|
||||
private boostMultiplier: integer;
|
||||
|
||||
|
@ -376,22 +396,34 @@ export abstract class PokemonModifierType extends ModifierType {
|
|||
export class PokemonHpRestoreModifierType extends PokemonModifierType {
|
||||
protected restorePercent: integer;
|
||||
|
||||
constructor(name: string, restorePercent: integer, newModifierFunc?: Function, iconImage?: string) {
|
||||
constructor(name: string, restorePercent: integer, newModifierFunc?: Function, selectFilter?: Function, iconImage?: string) {
|
||||
super(name, `Restore ${restorePercent} HP or ${restorePercent}% HP for one POKéMON, whichever is higher`,
|
||||
newModifierFunc || ((_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePercent, false)),
|
||||
(pokemon: PlayerPokemon) => {
|
||||
if (pokemon.hp >= pokemon.getMaxHp())
|
||||
selectFilter || ((pokemon: PlayerPokemon) => {
|
||||
if (!pokemon.hp || pokemon.hp >= pokemon.getMaxHp())
|
||||
return PartyUiHandler.NoEffectMessage;
|
||||
return null;
|
||||
}, iconImage);
|
||||
}), iconImage);
|
||||
|
||||
this.restorePercent = restorePercent;
|
||||
}
|
||||
}
|
||||
|
||||
export class PokemonLevelIncrementModifierType extends PokemonModifierType {
|
||||
constructor(name: string, iconImage?: string) {
|
||||
super(name, `Increase a POKéMON\'s level by 1`, (type, args) => new PokemonLevelIncrementModifier(type, (args[0] as PlayerPokemon).id),
|
||||
(_pokemon: PlayerPokemon) => null, iconImage);
|
||||
}
|
||||
}
|
||||
|
||||
export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
|
||||
constructor(name: string, restorePercent: integer, iconImage?: string) {
|
||||
super(name, restorePercent, (_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePercent, true), iconImage);
|
||||
super(name, restorePercent, (_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePercent, true),
|
||||
((pokemon: PlayerPokemon) => {
|
||||
if (pokemon.hp)
|
||||
return PartyUiHandler.NoEffectMessage;
|
||||
return null;
|
||||
}), iconImage);
|
||||
|
||||
this.description = `Revive one POKéMON and restore ${restorePercent}% HP`;
|
||||
this.selectFilter = (pokemon: PlayerPokemon) => {
|
||||
|
@ -471,6 +503,7 @@ const modifierPool = {
|
|||
const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.6).length;
|
||||
return thresholdPartyMemberCount;
|
||||
}),
|
||||
new PokemonLevelIncrementModifierType('RARE CANDY'),
|
||||
new PokemonBaseStatBoosterModifierType('HP-UP', Stat.HP),
|
||||
new PokemonBaseStatBoosterModifierType('PROTEIN', Stat.ATK),
|
||||
new PokemonBaseStatBoosterModifierType('IRON', Stat.DEF),
|
||||
|
|
Loading…
Reference in New Issue