mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-10 18:32:16 +02:00
added modifiers override for the player and the opponent
This commit is contained in:
parent
582330df33
commit
3703a92cd5
@ -17,7 +17,7 @@ import { TextStyle, addTextObject } from './ui/text';
|
||||
import { Moves } from "./data/enums/moves";
|
||||
import { allMoves } from "./data/move";
|
||||
import { initMoves } from './data/move';
|
||||
import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from './modifier/modifier-type';
|
||||
import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue, modifierTypes, getModifierType } from './modifier/modifier-type';
|
||||
import AbilityBar from './ui/ability-bar';
|
||||
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability';
|
||||
import { Abilities } from "./data/enums/abilities";
|
||||
@ -59,7 +59,7 @@ import { SceneBase } from './scene-base';
|
||||
import CandyBar from './ui/candy-bar';
|
||||
import { Variant, variantData } from './data/variant';
|
||||
import { Localizable } from './plugins/i18n';
|
||||
import { STARTING_WAVE_OVERRIDE, OPP_SPECIES_OVERRIDE, SEED_OVERRIDE, STARTING_BIOME_OVERRIDE } from './overrides';
|
||||
import { STARTING_WAVE_OVERRIDE, OPP_SPECIES_OVERRIDE, SEED_OVERRIDE, STARTING_BIOME_OVERRIDE, OPP_MODIFIER_OVERRIDE, OPP_MODIFIER_QTY_OVERRIDE } from './overrides';
|
||||
import {InputsController} from "./inputs-controller";
|
||||
import {UiInputs} from "./ui-inputs";
|
||||
|
||||
@ -1720,6 +1720,24 @@ export default class BattleScene extends SceneBase {
|
||||
});
|
||||
}
|
||||
|
||||
getEnemyModifiersOverride(): Array<string> {
|
||||
// if no override, do nothing
|
||||
if (!OPP_MODIFIER_OVERRIDE || OPP_MODIFIER_OVERRIDE.length === 0) return;
|
||||
const ret = [];
|
||||
// we loop through all the modifier name given in the override file
|
||||
for (const [index, modifierName] of OPP_MODIFIER_OVERRIDE.entries()) {
|
||||
// if the modifier does not exist, we skip it
|
||||
if (!modifierTypes.hasOwnProperty(modifierName)) continue;
|
||||
// We get how many modifiers, if none given, default to 1
|
||||
const qty = OPP_MODIFIER_QTY_OVERRIDE[index] || 1
|
||||
// for example, if qty is 2, we create an array of size 2 with the modifier on each slot
|
||||
for (const i of [...Array(qty).keys()]) {
|
||||
ret.push(modifierName);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
generateEnemyModifiers(): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
if (this.currentBattle.battleSpec === BattleSpec.FINAL_BOSS)
|
||||
@ -1739,6 +1757,17 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
|
||||
party.forEach((enemyPokemon: EnemyPokemon, i: integer) => {
|
||||
// we get the modifiers override for the opponent
|
||||
const modifiersOverride = this.getEnemyModifiersOverride();
|
||||
// if we have some modifiers override, apply them to the opponent
|
||||
if (modifiersOverride?.length) {
|
||||
// we delete all previous modifiers to avoid stack of override
|
||||
this.clearEnemyModifiers();
|
||||
for (const m of modifiersOverride) {
|
||||
this.addEnemyModifier(getModifierType(modifierTypes[m]).newModifier(enemyPokemon) as PersistentModifier, true, true);
|
||||
}
|
||||
this.updateModifiers(false).then(() => resolve());
|
||||
}
|
||||
const isBoss = enemyPokemon.isBoss() || (this.currentBattle.battleType === BattleType.TRAINER && this.currentBattle.trainer.config.isBoss);
|
||||
let upgradeChance = 32;
|
||||
if (isBoss)
|
||||
@ -1764,6 +1793,12 @@ export default class BattleScene extends SceneBase {
|
||||
});
|
||||
}
|
||||
|
||||
clearEnemyModifiers(): void {
|
||||
for (let m of this.enemyModifiers)
|
||||
this.enemyModifiers.splice(this.enemyModifiers.indexOf(m), 1);
|
||||
this.updateModifiers(false).then(() => this.updateUIPositions());
|
||||
}
|
||||
|
||||
clearEnemyHeldItemModifiers(): void {
|
||||
const modifiersToRemove = this.enemyModifiers.filter(m => m instanceof PokemonHeldItemModifier);
|
||||
for (let m of modifiersToRemove)
|
||||
|
@ -5,7 +5,9 @@ import { Species } from "./data/enums/species";
|
||||
import PokemonSpecies, { allSpecies } from "./data/pokemon-species";
|
||||
import { Arena } from "./field/arena";
|
||||
import * as Utils from "./utils";
|
||||
import { STARTING_BIOME_OVERRIDE, STARTING_LEVEL_OVERRIDE, STARTING_MONEY_OVERRIDE } from './overrides';
|
||||
import { STARTING_BIOME_OVERRIDE, STARTING_LEVEL_OVERRIDE, STARTING_MODIFIER_OVERRIDE, STARTING_MODIFIER_QTY_OVERRIDE, STARTING_MONEY_OVERRIDE } from './overrides';
|
||||
import { Modifier } from "./modifier/modifier";
|
||||
import { modifierTypes } from "./modifier/modifier-type";
|
||||
|
||||
export enum GameModes {
|
||||
CLASSIC,
|
||||
@ -60,6 +62,25 @@ export class GameMode implements GameModeConfig {
|
||||
return STARTING_MONEY_OVERRIDE || 1000;
|
||||
}
|
||||
|
||||
getModifierOverride(): Modifier[] {
|
||||
// if no override, do nothing
|
||||
if (!STARTING_MODIFIER_OVERRIDE || STARTING_MODIFIER_OVERRIDE.length === 0) return;
|
||||
const modifiers: Modifier[] = new Array();
|
||||
// we loop through all the modifier name given in the override file
|
||||
for (const [index, modifierName] of STARTING_MODIFIER_OVERRIDE.entries()) {
|
||||
// if the modifier does not exist, we skip it
|
||||
if (!modifierTypes.hasOwnProperty(modifierName)) continue;
|
||||
const modifierType = modifierTypes[modifierName]();
|
||||
// We get how many modifiers, if none given, default to 1
|
||||
const qty = STARTING_MODIFIER_QTY_OVERRIDE[index] || 1
|
||||
for (const i of [...Array(qty).keys()]) {
|
||||
// for example, if qty is 2, we create an array of size 2 with the modifier on each slot
|
||||
modifiers.push(modifierType.withIdFromFunc(modifierTypes[modifierName]).newModifier());
|
||||
}
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
getStartingBiome(scene: BattleScene): Biome {
|
||||
switch (this.modeId) {
|
||||
case GameModes.DAILY:
|
||||
|
@ -11,15 +11,19 @@ export const STARTING_LEVEL_OVERRIDE = 0;
|
||||
export const STARTING_WAVE_OVERRIDE = 0;
|
||||
export const STARTING_BIOME_OVERRIDE = Biome.TOWN;
|
||||
export const STARTING_MONEY_OVERRIDE = 0;
|
||||
export const STARTING_MODIFIER_OVERRIDE = []; // ['EXP_SHARE', 'GOLDEN_EXP_CHARM']
|
||||
export const STARTING_MODIFIER_QTY_OVERRIDE = []; // [5, 10];
|
||||
export const WEATHER_OVERRIDE = WeatherType.NONE;
|
||||
|
||||
export const ABILITY_OVERRIDE = Abilities.NONE;
|
||||
export const MOVE_OVERRIDE = Moves.NONE;
|
||||
export const MOVE_OVERRIDE_2 = Moves.NONE;
|
||||
export const OPP_SPECIES_OVERRIDE = 0;
|
||||
export const OPP_SPECIES_OVERRIDE = Species.TANDEMAUS;
|
||||
export const OPP_ABILITY_OVERRIDE = Abilities.NONE;
|
||||
export const OPP_MOVE_OVERRIDE = Moves.NONE;
|
||||
export const OPP_MOVE_OVERRIDE_2 = Moves.NONE;
|
||||
export const OPP_MODIFIER_OVERRIDE = []; // ['ENEMY_DAMAGE_REDUCTION', 'ENEMY_ATTACK_POISON_CHANCE']
|
||||
export const OPP_MODIFIER_QTY_OVERRIDE = []; // [1, 1];
|
||||
|
||||
export const OPP_SHINY_OVERRIDE = false;
|
||||
export const OPP_VARIANT_OVERRIDE = 0;
|
||||
|
@ -1702,6 +1702,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
const startRun = (gameMode: GameModes) => {
|
||||
this.scene.gameMode = gameModes[gameMode];
|
||||
this.scene.money = this.scene.gameMode.getStartingMoney();
|
||||
// we get the modifiers override
|
||||
const modifiersOverride = this.scene.gameMode.getModifierOverride();
|
||||
// if we have some modifiers override, apply them to the player
|
||||
if (modifiersOverride?.length) {
|
||||
for (const m of modifiersOverride) {
|
||||
this.scene.addModifier(m, true, false, false, true);
|
||||
}
|
||||
this.scene.updateModifiers(true, true);
|
||||
}
|
||||
ui.setMode(Mode.STARTER_SELECT);
|
||||
const thisObj = this;
|
||||
const originalStarterSelectCallback = this.starterSelectCallback;
|
||||
|
Loading…
Reference in New Issue
Block a user