Add Pokeball modifier when modifier stack is full
parent
92e3a6f537
commit
6135243641
|
@ -405,6 +405,11 @@ export class CheckSwitchPhase extends BattlePhase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.scene.getParty().slice(1).filter(p => p.hp).length) {
|
||||||
|
super.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.scene.getPlayerPokemon().getTag(BattleTagType.FRENZY)) {
|
if (this.scene.getPlayerPokemon().getTag(BattleTagType.FRENZY)) {
|
||||||
super.end();
|
super.end();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Phaser from 'phaser';
|
import Phaser from 'phaser';
|
||||||
import { Biome } from './biome';
|
import { Biome } from './biome';
|
||||||
import UI from './ui/ui';
|
import UI from './ui/ui';
|
||||||
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, SelectStarterPhase } from './battle-phases';
|
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, SelectStarterPhase, MessagePhase } from './battle-phases';
|
||||||
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';
|
||||||
|
@ -18,6 +18,7 @@ import { GameData } from './game-data';
|
||||||
import StarterSelectUiHandler from './ui/starter-select-ui-handler';
|
import StarterSelectUiHandler from './ui/starter-select-ui-handler';
|
||||||
import { TextStyle, addTextObject } from './text';
|
import { TextStyle, addTextObject } from './text';
|
||||||
import { Moves } from './move';
|
import { Moves } from './move';
|
||||||
|
import { getDefaultModifierTypeForTier } from './modifier-type';
|
||||||
|
|
||||||
const enableAuto = true;
|
const enableAuto = true;
|
||||||
export const startingLevel = 5;
|
export const startingLevel = 5;
|
||||||
|
@ -592,15 +593,23 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
|
|
||||||
addModifier(modifier: Modifier, virtual?: boolean): Promise<void> {
|
addModifier(modifier: Modifier, virtual?: boolean): Promise<void> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
const soundName = modifier.type.soundName;
|
||||||
if (modifier instanceof PersistentModifier) {
|
if (modifier instanceof PersistentModifier) {
|
||||||
if ((modifier as PersistentModifier).add(this.modifiers, !!virtual) && !virtual && !this.sound.get('restore'))
|
if ((modifier as PersistentModifier).add(this.modifiers, !!virtual)) {
|
||||||
this.sound.play('restore');
|
if (!virtual && !this.sound.get(soundName))
|
||||||
|
this.sound.play(soundName);
|
||||||
|
} if (!virtual) {
|
||||||
|
const defaultModifierType = getDefaultModifierTypeForTier(modifier.type.tier);
|
||||||
|
this.addModifier(defaultModifierType.newModifier()).then(() => resolve());
|
||||||
|
this.unshiftPhase(new MessagePhase(this, `The stack for this item is full.\n You will receive ${defaultModifierType.name} instead.`, null, true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!virtual)
|
if (!virtual)
|
||||||
this.updateModifiers().then(() => resolve());
|
this.updateModifiers().then(() => resolve());
|
||||||
} else if (modifier instanceof ConsumableModifier) {
|
} else if (modifier instanceof ConsumableModifier) {
|
||||||
if (!this.sound.get('restore'))
|
if (!this.sound.get(soundName))
|
||||||
this.sound.play('restore');
|
this.sound.play(soundName);
|
||||||
|
|
||||||
if (modifier instanceof ConsumablePokemonModifier) {
|
if (modifier instanceof ConsumablePokemonModifier) {
|
||||||
for (let p in this.party) {
|
for (let p in this.party) {
|
||||||
|
|
|
@ -27,14 +27,16 @@ export class ModifierType {
|
||||||
public description: string;
|
public description: string;
|
||||||
public iconImage: string;
|
public iconImage: string;
|
||||||
public group: string;
|
public group: string;
|
||||||
|
public soundName: string;
|
||||||
public tier: ModifierTier;
|
public tier: ModifierTier;
|
||||||
private newModifierFunc: NewModifierFunc;
|
private newModifierFunc: NewModifierFunc;
|
||||||
|
|
||||||
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, iconImage?: string, group?: string,) {
|
constructor(name: string, description: string, newModifierFunc: NewModifierFunc, iconImage?: string, group?: string, soundName?: 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();
|
||||||
this.group = group || '';
|
this.group = group || '';
|
||||||
|
this.soundName = soundName || 'restore';
|
||||||
this.newModifierFunc = newModifierFunc;
|
this.newModifierFunc = newModifierFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +51,8 @@ export class ModifierType {
|
||||||
|
|
||||||
class AddPokeballModifierType extends ModifierType {
|
class AddPokeballModifierType extends ModifierType {
|
||||||
constructor(pokeballType: PokeballType, count: integer, iconImage?: string) {
|
constructor(pokeballType: PokeballType, count: integer, iconImage?: string) {
|
||||||
super(`${count}x ${getPokeballName(pokeballType)}`, `Receive ${getPokeballName(pokeballType)} x${count}`, (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), iconImage, 'pb');
|
super(`${count}x ${getPokeballName(pokeballType)}`, `Receive ${getPokeballName(pokeballType)} x${count}`,
|
||||||
|
(_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), iconImage, 'pb', 'pb_bounce_1');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,8 +550,8 @@ const modifierPool = {
|
||||||
new WeightedModifierType(new ModifierType('SHINY CHARM', 'Dramatically increases the chance of a wild POKéMON being shiny', (type, _args) => new Modifiers.ShinyRateBoosterModifier(type)), 2)
|
new WeightedModifierType(new ModifierType('SHINY CHARM', 'Dramatically increases the chance of a wild POKéMON being shiny', (type, _args) => new Modifiers.ShinyRateBoosterModifier(type)), 2)
|
||||||
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
|
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
|
||||||
[ModifierTier.LUXURY]: [
|
[ModifierTier.LUXURY]: [
|
||||||
new ExpBoosterModifierType('GOLDEN EXP CHARM', 100),
|
new ModifierType(`GOLDEN ${getPokeballName(PokeballType.POKEBALL)}`, 'Adds 1 extra item option at the end of every battle', (type, _args) => new Modifiers.ExtraModifierModifier(type), 'pb_gold', null, 'pb_bounce_1'),
|
||||||
new ModifierType(`GOLDEN ${getPokeballName(PokeballType.POKEBALL)}`, 'Adds 1 extra item option at the end of every battle', (type, _args) => new Modifiers.ExtraModifierModifier(type), 'pb_gold')
|
new ExpBoosterModifierType('GOLDEN EXP CHARM', 100)
|
||||||
].map(m => { m.setTier(ModifierTier.LUXURY); return m; }),
|
].map(m => { m.setTier(ModifierTier.LUXURY); return m; }),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -582,7 +585,7 @@ export function regenerateModifierPoolThresholds(party: PlayerPokemon[]) {
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getModifierTypeOptionsForWave(waveIndex: integer, count: integer, party: PlayerPokemon[], maxedTypes: ModifierType[]): ModifierTypeOption[] {
|
export function getModifierTypeOptionsForWave(waveIndex: integer, count: integer, party: PlayerPokemon[]): ModifierTypeOption[] {
|
||||||
if (waveIndex % 10 === 0)
|
if (waveIndex % 10 === 0)
|
||||||
return modifierPool[ModifierTier.LUXURY].map(m => new ModifierTypeOption(m, false));
|
return modifierPool[ModifierTier.LUXURY].map(m => new ModifierTypeOption(m, false));
|
||||||
const options: ModifierTypeOption[] = [];
|
const options: ModifierTypeOption[] = [];
|
||||||
|
@ -631,6 +634,13 @@ function getNewModifierTypeOption(party: PlayerPokemon[], tier?: ModifierTier, u
|
||||||
return new ModifierTypeOption(modifierType as ModifierType, upgrade);
|
return new ModifierTypeOption(modifierType as ModifierType, upgrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDefaultModifierTypeForTier(tier: ModifierTier): ModifierType {
|
||||||
|
let modifierType: ModifierType | WeightedModifierType = modifierPool[tier][0];
|
||||||
|
if (modifierType instanceof WeightedModifierType)
|
||||||
|
modifierType = (modifierType as WeightedModifierType).modifierType;
|
||||||
|
return modifierType;
|
||||||
|
}
|
||||||
|
|
||||||
export class ModifierTypeOption {
|
export class ModifierTypeOption {
|
||||||
public type: ModifierType;
|
public type: ModifierType;
|
||||||
public upgraded: boolean;
|
public upgraded: boolean;
|
||||||
|
|
|
@ -72,10 +72,8 @@ export abstract class PersistentModifier extends Modifier {
|
||||||
|
|
||||||
add(modifiers: PersistentModifier[], virtual: boolean): boolean {
|
add(modifiers: PersistentModifier[], virtual: boolean): boolean {
|
||||||
for (let modifier of modifiers) {
|
for (let modifier of modifiers) {
|
||||||
if (this.match(modifier)) {
|
if (this.match(modifier))
|
||||||
modifier.incrementStack(virtual);
|
return modifier.incrementStack(virtual);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virtual) {
|
if (virtual) {
|
||||||
|
@ -88,13 +86,16 @@ export abstract class PersistentModifier extends Modifier {
|
||||||
|
|
||||||
abstract clone(): PersistentModifier;
|
abstract clone(): PersistentModifier;
|
||||||
|
|
||||||
incrementStack(virtual: boolean): void {
|
incrementStack(virtual: boolean): boolean {
|
||||||
if (this.getStackCount() < this.getMaxStackCount()) {
|
if (this.getStackCount() < this.getMaxStackCount()) {
|
||||||
if (!virtual)
|
if (!virtual)
|
||||||
this.stackCount++;
|
this.stackCount++;
|
||||||
else
|
else
|
||||||
this.virtualStackCount++;
|
this.virtualStackCount++;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStackCount(): integer {
|
getStackCount(): integer {
|
||||||
|
|
Loading…
Reference in New Issue