mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-29 10:16:14 +00:00
Add ethers and elixirs
This commit is contained in:
parent
50ce6c0791
commit
690e284f4d
@ -5,9 +5,9 @@ import { allMoves, applyMoveAttrs, MissEffectAttr, MoveCategory, MoveHitEffectAt
|
|||||||
import { Mode } from './ui/ui';
|
import { Mode } from './ui/ui';
|
||||||
import { Command } from "./ui/command-ui-handler";
|
import { Command } from "./ui/command-ui-handler";
|
||||||
import { Stat } from "./pokemon-stat";
|
import { Stat } from "./pokemon-stat";
|
||||||
import { ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, getModifierTypesForWave, ModifierType, PokemonModifierType, regenerateModifierPoolThresholds } from "./modifier";
|
import { ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, getModifierTypesForWave, ModifierType, PokemonModifierType, PokemonMoveModifierType, regenerateModifierPoolThresholds } from "./modifier";
|
||||||
import PartyUiHandler, { PartyUiMode } from "./ui/party-ui-handler";
|
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
|
||||||
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball";
|
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./pokeball";
|
||||||
import { MoveAnim, initAnim, loadMoveAnimAssets } from "./battle-anims";
|
import { MoveAnim, initAnim, loadMoveAnimAssets } from "./battle-anims";
|
||||||
import { StatusEffect } from "./status-effect";
|
import { StatusEffect } from "./status-effect";
|
||||||
import { SummaryUiMode } from "./ui/summary-ui-handler";
|
import { SummaryUiMode } from "./ui/summary-ui-handler";
|
||||||
@ -803,7 +803,7 @@ export class SwitchPhase extends BattlePhase {
|
|||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, (slotIndex: integer) => {
|
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, (slotIndex: integer, _option: PartyOption) => {
|
||||||
if (slotIndex && slotIndex < 6)
|
if (slotIndex && slotIndex < 6)
|
||||||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, slotIndex, this.doReturn));
|
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, slotIndex, this.doReturn));
|
||||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
||||||
@ -1112,7 +1112,7 @@ export class AttemptCapturePhase extends BattlePhase {
|
|||||||
const promptRelease = () => {
|
const promptRelease = () => {
|
||||||
this.scene.ui.showText(`Your party is full.\nRelease a POKéMON to make room for ${pokemon.name}?`, null, () => {
|
this.scene.ui.showText(`Your party is full.\nRelease a POKéMON to make room for ${pokemon.name}?`, null, () => {
|
||||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
||||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, (slotIndex: integer) => {
|
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, (slotIndex: integer, _option: PartyOption) => {
|
||||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||||
if (slotIndex < 6)
|
if (slotIndex < 6)
|
||||||
addToParty();
|
addToParty();
|
||||||
@ -1168,15 +1168,20 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
const modifierType = types[cursor];
|
const modifierType = types[cursor];
|
||||||
if (modifierType instanceof PokemonModifierType) {
|
if (modifierType instanceof PokemonModifierType) {
|
||||||
const pokemonModifierType = modifierType as PokemonModifierType;
|
const pokemonModifierType = modifierType as PokemonModifierType;
|
||||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER, (slotIndex: integer) => {
|
const isMoveModifier = modifierType instanceof PokemonMoveModifierType;
|
||||||
|
this.scene.ui.setModeWithoutClear(Mode.PARTY, !isMoveModifier ? PartyUiMode.MODIFIER : PartyUiMode.MOVE_MODIFIER, (slotIndex: integer, option: PartyOption) => {
|
||||||
if (slotIndex < 6) {
|
if (slotIndex < 6) {
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT);
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT);
|
||||||
this.scene.addModifier(types[cursor].newModifier(party[slotIndex])).then(() => super.end());
|
const modifierType = types[cursor];
|
||||||
|
const modifier = !isMoveModifier
|
||||||
|
? modifierType.newModifier(party[slotIndex])
|
||||||
|
: modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1);
|
||||||
|
this.scene.addModifier(modifier).then(() => super.end());
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
} else
|
} else
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, modifierSelectCallback);
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, modifierSelectCallback);
|
||||||
}, pokemonModifierType.selectFilter);
|
}, pokemonModifierType.selectFilter, modifierType instanceof PokemonMoveModifierType ? (modifierType as PokemonMoveModifierType).moveSelectFilter : undefined);
|
||||||
} else {
|
} else {
|
||||||
this.scene.addModifier(types[cursor].newModifier()).then(() => super.end());
|
this.scene.addModifier(types[cursor].newModifier()).then(() => super.end());
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
|
@ -5,7 +5,7 @@ import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, SwitchBi
|
|||||||
import { PlayerPokemon, EnemyPokemon } from './pokemon';
|
import { PlayerPokemon, EnemyPokemon } from './pokemon';
|
||||||
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './pokemon-species';
|
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './pokemon-species';
|
||||||
import * as Utils from './utils';
|
import * as Utils from './utils';
|
||||||
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier } from './modifier';
|
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ConsumablePokemonMoveModifier } from './modifier';
|
||||||
import { PokeballType } from './pokeball';
|
import { PokeballType } from './pokeball';
|
||||||
import { Species } from './species';
|
import { Species } from './species';
|
||||||
import { initAutoPlay } from './auto-play';
|
import { initAutoPlay } from './auto-play';
|
||||||
@ -520,6 +520,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
this.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier);
|
this.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier);
|
||||||
args.push(hpRestoreMultiplier.value);
|
args.push(hpRestoreMultiplier.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modifier.shouldApply(args))
|
if (modifier.shouldApply(args))
|
||||||
modifier.apply(args);
|
modifier.apply(args);
|
||||||
}
|
}
|
||||||
|
131
src/modifier.ts
131
src/modifier.ts
@ -3,12 +3,12 @@ import BattleScene from "./battle-scene";
|
|||||||
import { getLevelTotalExp } from "./exp";
|
import { getLevelTotalExp } from "./exp";
|
||||||
import { allMoves, Moves } from "./move";
|
import { allMoves, Moves } from "./move";
|
||||||
import { getPokeballName, PokeballType } from "./pokeball";
|
import { getPokeballName, PokeballType } from "./pokeball";
|
||||||
import Pokemon, { PlayerPokemon } from "./pokemon";
|
import Pokemon, { PlayerPokemon, PokemonMove } from "./pokemon";
|
||||||
import { Stat, getStatName } from "./pokemon-stat";
|
import { Stat, getStatName } from "./pokemon-stat";
|
||||||
import { addTextObject, TextStyle } from "./text";
|
import { addTextObject, TextStyle } from "./text";
|
||||||
import { tmSpecies } from "./tms";
|
import { tmSpecies } from "./tms";
|
||||||
import { Type } from "./type";
|
import { Type } from "./type";
|
||||||
import PartyUiHandler from "./ui/party-ui-handler";
|
import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from "./ui/party-ui-handler";
|
||||||
import * as Utils from "./utils";
|
import * as Utils from "./utils";
|
||||||
|
|
||||||
export class ModifierBar extends Phaser.GameObjects.Container {
|
export class ModifierBar extends Phaser.GameObjects.Container {
|
||||||
@ -307,7 +307,36 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PokemonPpRestoreModifier extends ConsumablePokemonModifier {
|
export abstract class ConsumablePokemonMoveModifier extends ConsumablePokemonModifier {
|
||||||
|
public moveIndex: integer;
|
||||||
|
|
||||||
|
constructor(type: ModifierType, pokemonId: integer, moveIndex: integer) {
|
||||||
|
super(type, pokemonId);
|
||||||
|
|
||||||
|
this.moveIndex = moveIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PokemonPpRestoreModifier extends ConsumablePokemonMoveModifier {
|
||||||
|
private restorePoints: integer;
|
||||||
|
|
||||||
|
constructor(type: ModifierType, pokemonId: integer, moveIndex: integer, restorePoints: integer) {
|
||||||
|
super(type, pokemonId, moveIndex);
|
||||||
|
|
||||||
|
this.restorePoints = restorePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(args: any[]): boolean {
|
||||||
|
const pokemon = args[0] as Pokemon;
|
||||||
|
const move = pokemon.moveset[this.moveIndex];
|
||||||
|
console.log(move.ppUsed, this.restorePoints, this.restorePoints >= -1 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0);
|
||||||
|
move.ppUsed = this.restorePoints >= -1 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PokemonAllMovePpRestoreModifier extends ConsumablePokemonModifier {
|
||||||
private restorePoints: integer;
|
private restorePoints: integer;
|
||||||
|
|
||||||
constructor(type: ModifierType, pokemonId: integer, restorePoints: integer) {
|
constructor(type: ModifierType, pokemonId: integer, restorePoints: integer) {
|
||||||
@ -316,15 +345,10 @@ export class PokemonPpRestoreModifier extends ConsumablePokemonModifier {
|
|||||||
this.restorePoints = restorePoints;
|
this.restorePoints = restorePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldApply(args: any[]): boolean {
|
|
||||||
return super.shouldApply(args) && args.length > 1 && typeof(args[1]) === 'number';
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(args: any[]): boolean {
|
apply(args: any[]): boolean {
|
||||||
const pokemon = args[0] as Pokemon;
|
const pokemon = args[0] as Pokemon;
|
||||||
const moveIndex = args[1] as integer;
|
for (let move of pokemon.moveset)
|
||||||
const move = pokemon.moveset[moveIndex];
|
move.ppUsed = this.restorePoints >= -1 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0;
|
||||||
move.ppUsed = this.restorePoints >= 0 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -529,14 +553,16 @@ export enum ModifierTier {
|
|||||||
LUXURY
|
LUXURY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type NewModifierFunc = (type: ModifierType, args: any[]) => Modifier;
|
||||||
|
|
||||||
export class ModifierType {
|
export class ModifierType {
|
||||||
public name: string;
|
public name: string;
|
||||||
public description: string;
|
public description: string;
|
||||||
public iconImage: string;
|
public iconImage: string;
|
||||||
public tier: ModifierTier;
|
public tier: ModifierTier;
|
||||||
private newModifierFunc: Function;
|
private newModifierFunc: NewModifierFunc;
|
||||||
|
|
||||||
constructor(name: string, description: string, newModifierFunc: Function, iconImage?: string) {
|
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, iconImage?: string) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.iconImage = iconImage || name?.replace(/[ \-]/g, '_')?.toLowerCase();
|
this.iconImage = iconImage || name?.replace(/[ \-]/g, '_')?.toLowerCase();
|
||||||
@ -559,9 +585,9 @@ class AddPokeballModifierType extends ModifierType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export abstract class PokemonModifierType extends ModifierType {
|
export abstract class PokemonModifierType extends ModifierType {
|
||||||
public selectFilter: Function;
|
public selectFilter: PokemonSelectFilter;
|
||||||
|
|
||||||
constructor(name: string, description: string, newModifierFunc: Function, selectFilter?: Function, iconImage?: string) {
|
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string) {
|
||||||
super(name, description, newModifierFunc, iconImage);
|
super(name, description, newModifierFunc, iconImage);
|
||||||
|
|
||||||
this.selectFilter = selectFilter;
|
this.selectFilter = selectFilter;
|
||||||
@ -572,7 +598,7 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType {
|
|||||||
protected restorePoints: integer;
|
protected restorePoints: integer;
|
||||||
protected percent: boolean;
|
protected percent: boolean;
|
||||||
|
|
||||||
constructor(name: string, restorePoints: integer, percent?: boolean, newModifierFunc?: Function, selectFilter?: Function, iconImage?: string) {
|
constructor(name: string, restorePoints: integer, percent?: boolean, newModifierFunc?: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string) {
|
||||||
super(name, `Restore ${restorePoints}${percent ? '%' : ''} HP for one POKéMON`,
|
super(name, `Restore ${restorePoints}${percent ? '%' : ''} HP for one POKéMON`,
|
||||||
newModifierFunc || ((_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints, this.percent, false)),
|
newModifierFunc || ((_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints, this.percent, false)),
|
||||||
selectFilter || ((pokemon: PlayerPokemon) => {
|
selectFilter || ((pokemon: PlayerPokemon) => {
|
||||||
@ -604,19 +630,26 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PokemonLevelIncrementModifierType extends PokemonModifierType {
|
export abstract class PokemonMoveModifierType extends PokemonModifierType {
|
||||||
constructor(name: string, iconImage?: string) {
|
public moveSelectFilter: PokemonMoveSelectFilter;
|
||||||
super(name, `Increase a POKéMON\'s level by 1`, (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id),
|
|
||||||
(_pokemon: PlayerPokemon) => null, iconImage);
|
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, moveSelectFilter?: PokemonMoveSelectFilter, iconImage?: string) {
|
||||||
|
super(name, description, newModifierFunc, selectFilter, iconImage);
|
||||||
|
|
||||||
|
this.moveSelectFilter = moveSelectFilter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PokemonPpRestoreModifierType extends PokemonModifierType {
|
export class PokemonPpRestoreModifierType extends PokemonMoveModifierType {
|
||||||
protected restorePoints: integer;
|
protected restorePoints: integer;
|
||||||
|
|
||||||
constructor(name: string, restorePoints: integer, iconImage?: string) {
|
constructor(name: string, restorePoints: integer, iconImage?: string) {
|
||||||
super(name, `Restore ${restorePoints} PP for one POKéMON's move`, (_type, args) => new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints),
|
super(name, `Restore ${restorePoints > -1 ? restorePoints : 'all'} PP for one POKéMON move`, (_type, args) => new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, (args[1] as integer), this.restorePoints),
|
||||||
(pokemon: PlayerPokemon) => {
|
(_pokemon: PlayerPokemon) => {
|
||||||
|
return null;
|
||||||
|
}, (pokemonMove: PokemonMove) => {
|
||||||
|
if (!pokemonMove.ppUsed)
|
||||||
|
return PartyUiHandler.NoEffectMessage;
|
||||||
return null;
|
return null;
|
||||||
}, iconImage);
|
}, iconImage);
|
||||||
|
|
||||||
@ -624,6 +657,28 @@ export class PokemonPpRestoreModifierType extends PokemonModifierType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PokemonAllMovePpRestoreModifierType extends PokemonModifierType {
|
||||||
|
protected restorePoints: integer;
|
||||||
|
|
||||||
|
constructor(name: string, restorePoints: integer, iconImage?: string) {
|
||||||
|
super(name, `Restore ${restorePoints > -1 ? restorePoints : 'all'} PP for all of one POKéMON's moves`, (_type, args) => new PokemonAllMovePpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints),
|
||||||
|
(pokemon: PlayerPokemon) => {
|
||||||
|
if (!pokemon.moveset.filter(m => m.ppUsed).length)
|
||||||
|
return PartyUiHandler.NoEffectMessage;
|
||||||
|
return null;
|
||||||
|
}, iconImage);
|
||||||
|
|
||||||
|
this.restorePoints = this.restorePoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PokemonLevelIncrementModifierType extends PokemonModifierType {
|
||||||
|
constructor(name: string, iconImage?: string) {
|
||||||
|
super(name, `Increase a POKéMON\'s level by 1`, (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id),
|
||||||
|
(_pokemon: PlayerPokemon) => null, iconImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class PokemonBaseStatBoosterModifierType extends PokemonModifierType {
|
export class PokemonBaseStatBoosterModifierType extends PokemonModifierType {
|
||||||
private stat: Stat;
|
private stat: Stat;
|
||||||
|
|
||||||
@ -635,7 +690,7 @@ export class PokemonBaseStatBoosterModifierType extends PokemonModifierType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AllPokemonFullHpRestoreModifierType extends ModifierType {
|
class AllPokemonFullHpRestoreModifierType extends ModifierType {
|
||||||
constructor(name: string, description?: string, newModifierFunc?: Function, iconImage?: string) {
|
constructor(name: string, description?: string, newModifierFunc?: NewModifierFunc, iconImage?: string) {
|
||||||
super(name, description || `Restore 100% HP for all POKéMON`, newModifierFunc || ((_type, _args) => new PokemonHpRestoreModifier(this, -1, 100, false)), iconImage);
|
super(name, description || `Restore 100% HP for all POKéMON`, newModifierFunc || ((_type, _args) => new PokemonHpRestoreModifier(this, -1, 100, false)), iconImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,11 +755,19 @@ const modifierPool = {
|
|||||||
[ModifierTier.COMMON]: [
|
[ModifierTier.COMMON]: [
|
||||||
new WeightedModifierType(new AddPokeballModifierType(PokeballType.POKEBALL, 5, 'pb'), 2),
|
new WeightedModifierType(new AddPokeballModifierType(PokeballType.POKEBALL, 5, 'pb'), 2),
|
||||||
new WeightedModifierType(new PokemonHpRestoreModifierType('POTION', 20), (party: PlayerPokemon[]) => {
|
new WeightedModifierType(new PokemonHpRestoreModifierType('POTION', 20), (party: PlayerPokemon[]) => {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.9).length;
|
const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 10).length;
|
||||||
return thresholdPartyMemberCount;
|
return thresholdPartyMemberCount;
|
||||||
}),
|
}),
|
||||||
new WeightedModifierType(new PokemonHpRestoreModifierType('SUPER POTION', 50), (party: PlayerPokemon[]) => {
|
new WeightedModifierType(new PokemonHpRestoreModifierType('SUPER POTION', 50), (party: PlayerPokemon[]) => {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.75).length;
|
const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 25).length;
|
||||||
|
return Math.ceil(thresholdPartyMemberCount / 3);
|
||||||
|
}),
|
||||||
|
new WeightedModifierType(new PokemonPpRestoreModifierType('ETHER', 10), (party: PlayerPokemon[]) => {
|
||||||
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length;
|
||||||
|
return thresholdPartyMemberCount;
|
||||||
|
}),
|
||||||
|
new WeightedModifierType(new PokemonPpRestoreModifierType('MAX ETHER', 100), (party: PlayerPokemon[]) => {
|
||||||
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length;
|
||||||
return Math.ceil(thresholdPartyMemberCount / 3);
|
return Math.ceil(thresholdPartyMemberCount / 3);
|
||||||
})
|
})
|
||||||
].map(m => { m.setTier(ModifierTier.COMMON); return m; }),
|
].map(m => { m.setTier(ModifierTier.COMMON); return m; }),
|
||||||
@ -719,9 +782,21 @@ const modifierPool = {
|
|||||||
return faintedPartyMemberCount;
|
return faintedPartyMemberCount;
|
||||||
}),
|
}),
|
||||||
new WeightedModifierType(new PokemonHpRestoreModifierType('HYPER POTION', 200), (party: PlayerPokemon[]) => {
|
new WeightedModifierType(new PokemonHpRestoreModifierType('HYPER POTION', 200), (party: PlayerPokemon[]) => {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.6).length;
|
const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 100).length;
|
||||||
return thresholdPartyMemberCount;
|
return thresholdPartyMemberCount;
|
||||||
}),
|
}),
|
||||||
|
new WeightedModifierType(new PokemonHpRestoreModifierType('MAX POTION', 100, true), (party: PlayerPokemon[]) => {
|
||||||
|
const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 150).length;
|
||||||
|
return Math.ceil(thresholdPartyMemberCount / 3);
|
||||||
|
}),
|
||||||
|
new WeightedModifierType(new PokemonAllMovePpRestoreModifierType('ELIXIR', 10), (party: PlayerPokemon[]) => {
|
||||||
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length;
|
||||||
|
return thresholdPartyMemberCount;
|
||||||
|
}),
|
||||||
|
new WeightedModifierType(new PokemonAllMovePpRestoreModifierType('MAX ELIXIR', 100), (party: PlayerPokemon[]) => {
|
||||||
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length;
|
||||||
|
return Math.ceil(thresholdPartyMemberCount / 3);
|
||||||
|
}),
|
||||||
new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => {
|
new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => {
|
||||||
const partyMemberCompatibleTms = party.map(p => p.compatibleTms);
|
const partyMemberCompatibleTms = party.map(p => p.compatibleTms);
|
||||||
const uniqueCompatibleTms = partyMemberCompatibleTms.flat().filter((tm, i, array) => array.indexOf(tm) === i);
|
const uniqueCompatibleTms = partyMemberCompatibleTms.flat().filter((tm, i, array) => array.indexOf(tm) === i);
|
||||||
@ -738,10 +813,6 @@ const modifierPool = {
|
|||||||
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
|
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
|
||||||
[ModifierTier.ULTRA]: [
|
[ModifierTier.ULTRA]: [
|
||||||
new AddPokeballModifierType(PokeballType.ULTRA_BALL, 5, 'ub'),
|
new AddPokeballModifierType(PokeballType.ULTRA_BALL, 5, 'ub'),
|
||||||
new WeightedModifierType(new AllPokemonFullHpRestoreModifierType('MAX POTION'), (party: PlayerPokemon[]) => {
|
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.5).length;
|
|
||||||
return Math.ceil(thresholdPartyMemberCount / 3);
|
|
||||||
}),
|
|
||||||
new WeightedModifierType(new AllPokemonFullReviveModifierType('SACRED ASH'), (party: PlayerPokemon[]) => {
|
new WeightedModifierType(new AllPokemonFullReviveModifierType('SACRED ASH'), (party: PlayerPokemon[]) => {
|
||||||
return party.filter(p => !p.hp).length >= Math.ceil(party.length / 2) ? 1 : 0;
|
return party.filter(p => !p.hp).length >= Math.ceil(party.length / 2) ? 1 : 0;
|
||||||
}),
|
}),
|
||||||
|
@ -291,6 +291,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return this.stats[Stat.HP];
|
return this.stats[Stat.HP];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getInverseHp(): integer {
|
||||||
|
return this.getMaxHp() - this.hp;
|
||||||
|
}
|
||||||
|
|
||||||
getHpRatio(): number {
|
getHpRatio(): number {
|
||||||
return Math.floor((this.hp / this.getMaxHp()) * 100) / 100;
|
return Math.floor((this.hp / this.getMaxHp()) * 100) / 100;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { CommandPhase } from "../battle-phases";
|
import { CommandPhase } from "../battle-phases";
|
||||||
import BattleScene, { Button } from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { PlayerPokemon } from "../pokemon";
|
import { PlayerPokemon, PokemonMove } from "../pokemon";
|
||||||
import { addTextObject, TextStyle } from "../text";
|
import { addTextObject, TextStyle } from "../text";
|
||||||
import { Command } from "./command-ui-handler";
|
import { Command } from "./command-ui-handler";
|
||||||
import MessageUiHandler from "./message-ui-handler";
|
import MessageUiHandler from "./message-ui-handler";
|
||||||
@ -14,6 +14,7 @@ export enum PartyUiMode {
|
|||||||
FAINT_SWITCH,
|
FAINT_SWITCH,
|
||||||
POST_BATTLE_SWITCH,
|
POST_BATTLE_SWITCH,
|
||||||
MODIFIER,
|
MODIFIER,
|
||||||
|
MOVE_MODIFIER,
|
||||||
RELEASE
|
RELEASE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,9 +24,17 @@ export enum PartyOption {
|
|||||||
APPLY,
|
APPLY,
|
||||||
SUMMARY,
|
SUMMARY,
|
||||||
RELEASE,
|
RELEASE,
|
||||||
|
MOVE_1,
|
||||||
|
MOVE_2,
|
||||||
|
MOVE_3,
|
||||||
|
MOVE_4,
|
||||||
CANCEL
|
CANCEL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PartySelectCallback = (cursor: integer, option: PartyOption) => void;
|
||||||
|
export type PokemonSelectFilter = (pokemon: PlayerPokemon) => string;
|
||||||
|
export type PokemonMoveSelectFilter = (pokemonMove: PokemonMove) => string;
|
||||||
|
|
||||||
export default class PartyUiHandler extends MessageUiHandler {
|
export default class PartyUiHandler extends MessageUiHandler {
|
||||||
private partyUiMode: PartyUiMode;
|
private partyUiMode: PartyUiMode;
|
||||||
|
|
||||||
@ -42,8 +51,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
private options: integer[];
|
private options: integer[];
|
||||||
|
|
||||||
private lastCursor: integer = 0;
|
private lastCursor: integer = 0;
|
||||||
private selectCallback: Function;
|
private selectCallback: PartySelectCallback;
|
||||||
private selectFilter: Function;
|
private selectFilter: PokemonSelectFilter;
|
||||||
|
private moveSelectFilter: PokemonMoveSelectFilter;
|
||||||
|
|
||||||
private static FilterAll = (_pokemon: PlayerPokemon) => null;
|
private static FilterAll = (_pokemon: PlayerPokemon) => null;
|
||||||
|
|
||||||
@ -53,6 +63,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static FilterAllMoves = (_pokemonMove: PokemonMove) => null;
|
||||||
|
|
||||||
public static NoEffectMessage = 'It won\'t have any effect.';
|
public static NoEffectMessage = 'It won\'t have any effect.';
|
||||||
|
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
@ -122,8 +134,11 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
if (args.length > 1 && args[1] instanceof Function)
|
if (args.length > 1 && args[1] instanceof Function)
|
||||||
this.selectCallback = args[1];
|
this.selectCallback = args[1];
|
||||||
this.selectFilter = args.length > 2 && args[2] instanceof Function
|
this.selectFilter = args.length > 2 && args[2] instanceof Function
|
||||||
? args[2]
|
? args[2] as PokemonSelectFilter
|
||||||
: PartyUiHandler.FilterAll;
|
: PartyUiHandler.FilterAll;
|
||||||
|
this.moveSelectFilter = args.length > 3 && args[3] instanceof Function
|
||||||
|
? args[3] as PokemonMoveSelectFilter
|
||||||
|
: PartyUiHandler.FilterAllMoves;
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(button: Button) {
|
processInput(button: Button) {
|
||||||
@ -151,9 +166,11 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
const option = this.options[this.optionsCursor];
|
const option = this.options[this.optionsCursor];
|
||||||
const pokemon = this.scene.getParty()[this.cursor];
|
const pokemon = this.scene.getParty()[this.cursor];
|
||||||
if (option === PartyOption.SHIFT || option === PartyOption.SEND_OUT || option === PartyOption.APPLY
|
if ((option !== PartyOption.SUMMARY && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL)
|
||||||
|| (this.partyUiMode === PartyUiMode.RELEASE && option === PartyOption.RELEASE)) {
|
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
|
||||||
let filterResult: string = this.selectFilter(pokemon);
|
let filterResult: string = this.selectFilter(pokemon);
|
||||||
|
if (filterResult === null && this.partyUiMode === PartyUiMode.MOVE_MODIFIER)
|
||||||
|
filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]);
|
||||||
if (filterResult === null) {
|
if (filterResult === null) {
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
if (this.selectCallback) {
|
if (this.selectCallback) {
|
||||||
@ -162,11 +179,11 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
else {
|
else {
|
||||||
const selectCallback = this.selectCallback;
|
const selectCallback = this.selectCallback;
|
||||||
this.selectCallback = null;
|
this.selectCallback = null;
|
||||||
selectCallback(this.cursor);
|
selectCallback(this.cursor, option);
|
||||||
}
|
}
|
||||||
} else if (this.cursor)
|
} else if (this.cursor)
|
||||||
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor);
|
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor);
|
||||||
if (this.partyUiMode !== PartyUiMode.MODIFIER)
|
if (this.partyUiMode !== PartyUiMode.MODIFIER && this.partyUiMode !== PartyUiMode.MOVE_MODIFIER)
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -228,7 +245,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
if (this.selectCallback) {
|
if (this.selectCallback) {
|
||||||
const selectCallback = this.selectCallback;
|
const selectCallback = this.selectCallback;
|
||||||
this.selectCallback = null;
|
this.selectCallback = null;
|
||||||
selectCallback(6);
|
selectCallback(6, PartyOption.CANCEL);
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
} else {
|
} else {
|
||||||
ui.setMode(Mode.COMMAND);
|
ui.setMode(Mode.COMMAND);
|
||||||
@ -325,35 +342,56 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
optionsBottom.setOrigin(1, 1);
|
optionsBottom.setOrigin(1, 1);
|
||||||
this.optionsContainer.add(optionsBottom);
|
this.optionsContainer.add(optionsBottom);
|
||||||
|
|
||||||
switch (this.partyUiMode) {
|
const pokemon = this.scene.getParty()[this.cursor];
|
||||||
case PartyUiMode.SWITCH:
|
|
||||||
if (this.cursor)
|
if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER) {
|
||||||
this.options.push(PartyOption.SHIFT);
|
switch (this.partyUiMode) {
|
||||||
break;
|
case PartyUiMode.SWITCH:
|
||||||
case PartyUiMode.FAINT_SWITCH:
|
if (this.cursor)
|
||||||
case PartyUiMode.POST_BATTLE_SWITCH:
|
this.options.push(PartyOption.SHIFT);
|
||||||
if (this.cursor)
|
break;
|
||||||
this.options.push(PartyOption.SEND_OUT);
|
case PartyUiMode.FAINT_SWITCH:
|
||||||
break;
|
case PartyUiMode.POST_BATTLE_SWITCH:
|
||||||
case PartyUiMode.MODIFIER:
|
if (this.cursor)
|
||||||
this.options.push(PartyOption.APPLY);
|
this.options.push(PartyOption.SEND_OUT);
|
||||||
break;
|
break;
|
||||||
case PartyUiMode.RELEASE:
|
case PartyUiMode.MODIFIER:
|
||||||
|
this.options.push(PartyOption.APPLY);
|
||||||
|
break;
|
||||||
|
case PartyUiMode.RELEASE:
|
||||||
|
this.options.push(PartyOption.RELEASE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options.push(PartyOption.SUMMARY);
|
||||||
|
|
||||||
|
if (this.partyUiMode === PartyUiMode.SWITCH)
|
||||||
this.options.push(PartyOption.RELEASE);
|
this.options.push(PartyOption.RELEASE);
|
||||||
break;
|
} else {
|
||||||
|
for (let m = 0; m < pokemon.moveset.length; m++)
|
||||||
|
this.options.push(PartyOption.MOVE_1 + m);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.options.push(PartyOption.SUMMARY);
|
|
||||||
|
|
||||||
if (this.partyUiMode === PartyUiMode.SWITCH)
|
|
||||||
this.options.push(PartyOption.RELEASE);
|
|
||||||
|
|
||||||
this.options.push(PartyOption.CANCEL);
|
this.options.push(PartyOption.CANCEL);
|
||||||
|
|
||||||
for (let o = 0; o < this.options.length; o++) {
|
for (let o = 0; o < this.options.length; o++) {
|
||||||
|
const option = this.options[this.options.length - (o + 1)];
|
||||||
|
let optionName: string;
|
||||||
|
switch (option) {
|
||||||
|
case PartyOption.MOVE_1:
|
||||||
|
case PartyOption.MOVE_2:
|
||||||
|
case PartyOption.MOVE_3:
|
||||||
|
case PartyOption.MOVE_4:
|
||||||
|
optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
optionName = PartyOption[option].replace(/\_/g, ' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const yCoord = -6 - 16 * o;
|
const yCoord = -6 - 16 * o;
|
||||||
const optionBg = this.scene.add.image(0, yCoord, 'party_options_center');
|
const optionBg = this.scene.add.image(0, yCoord, 'party_options_center');
|
||||||
const optionText = addTextObject(this.scene, -79, yCoord - 16, PartyOption[this.options[this.options.length - (o + 1)]].replace(/\_/g, ' '), TextStyle.WINDOW);
|
const optionText = addTextObject(this.scene, -79, yCoord - 16, optionName, TextStyle.WINDOW);
|
||||||
|
|
||||||
optionBg.setOrigin(1, 1);
|
optionBg.setOrigin(1, 1);
|
||||||
optionText.setOrigin(0, 0);
|
optionText.setOrigin(0, 0);
|
||||||
@ -380,7 +418,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
if (this.partyUiMode === PartyUiMode.RELEASE) {
|
if (this.partyUiMode === PartyUiMode.RELEASE) {
|
||||||
const selectCallback = this.selectCallback;
|
const selectCallback = this.selectCallback;
|
||||||
this.selectCallback = null;
|
this.selectCallback = null;
|
||||||
selectCallback(this.cursor);
|
selectCallback(this.cursor, PartyOption.RELEASE);
|
||||||
} else
|
} else
|
||||||
this.message.setText(defaultMessage);
|
this.message.setText(defaultMessage);
|
||||||
}, null, true);
|
}, null, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user