Skip to content

Commit

Permalink
Remove Comments, Adjust Code
Browse files Browse the repository at this point in the history
  • Loading branch information
xsn34kzx committed Jul 9, 2024
1 parent 2236452 commit 92cef84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
8 changes: 2 additions & 6 deletions src/modifier/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1907,24 +1907,20 @@ export function getPlayerModifierTypeOptions(count: integer, party: PlayerPokemo
}
}

// Override rolled options if any override entries are present
// Replace rolled options if any override entries are present
for (let i = 0; i < Overrides.ITEM_REWARD_OVERRIDE.length; i++) {
if (options.length >= i) {
break;
}
const override = Overrides.ITEM_REWARD_OVERRIDE[i];
// If the item does not exist in modifierTypes, skip it
if (modifierTypes.hasOwnProperty(override.name)) {
// Retrieve the item entry from modifierTypes
if (override.name in modifierTypes) {
const modifierFunc = modifierTypes[override.name];
let modifierType = modifierFunc();

// Generate modifier type if necessary
if (modifierType instanceof ModifierTypeGenerator) {
modifierType = modifierType.generateType(party, (override.type !== null) ? [override.type] : null);
}

// Replace the corresponding original option
options[i].type = modifierType.withIdFromFunc(modifierFunc);
}
}
Expand Down
27 changes: 9 additions & 18 deletions src/modifier/modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2655,27 +2655,24 @@ export class EnemyFusionChanceModifier extends EnemyPersistentModifier {
* - The player
* - The enemy
* @param scene current {@linkcode BattleScene}
* @param isPlayer {@linkcode boolean} for whether the the player or enemy is being overridden
* @param isPlayer {@linkcode boolean} for whether the the player (`true`) or enemy (`false`) is being overridden
*/
export function overrideModifiers(scene: BattleScene, isPlayer: boolean = true): void {
const modifiersOverride = isPlayer ? Overrides.STARTING_MODIFIER_OVERRIDE : Overrides.OPP_MODIFIER_OVERRIDE;
if (!modifiersOverride || modifiersOverride.length === 0 || !scene) {
return;
} // If no override is provided, do nothing
}

// If it's the opponent, clear all of their current modifiers to avoid stacking
if (!isPlayer) {
scene.clearEnemyModifiers();
}

// Loop through all the override items given
modifiersOverride.forEach(item => {
// If the item does not exist in modifierTypes, skip it
if (modifierTypes.hasOwnProperty(item.name)) {
// Retrieve the item entry from modifierTypes
if (item.name in modifierTypes) {
const modifierFunc = modifierTypes[item.name];
const modifier = modifierFunc().withIdFromFunc(modifierFunc).newModifier() as PersistentModifier;
modifier.stackCount = item.count || 1; // Set quantity
modifier.stackCount = item.count || 1;

if (isPlayer) {
scene.addModifier(modifier, true, false, false, true);
Expand All @@ -2692,34 +2689,28 @@ export function overrideModifiers(scene: BattleScene, isPlayer: boolean = true):
* - An enemy {@linkcode Pokemon} being spawned in
* @param scene current {@linkcode BattleScene}
* @param pokemon {@linkcode Pokemon} whose held items are being overridden
* @param isPlayer {@linkcode boolean} for whether the {@linkcode pokemon} is the player's or an enemy
* @param isPlayer {@linkcode boolean} for whether the {@linkcode pokemon} is the player's (`true`) or an enemy (`false`)
*/
export function overrideHeldItems(scene: BattleScene, pokemon: Pokemon, isPlayer: boolean = true): void {
const heldItemsOverride = isPlayer ? Overrides.STARTING_HELD_ITEMS_OVERRIDE : Overrides.OPP_HELD_ITEMS_OVERRIDE;
if (!heldItemsOverride || heldItemsOverride.length === 0 || !scene) {
return;
} // If no override is provided, do nothing
}

// Loop through all the override items given
heldItemsOverride.forEach(item => {
// If the item does not exist in modifierTypes, skip it
if (modifierTypes.hasOwnProperty(item.name)) {
// Retrieve the item entry from modifierTypes
if (item.name in modifierTypes) {
const modifierFunc = modifierTypes[item.name];
let modifierType = modifierFunc();
const qty = item.count || 1;

// Generate modifier type if necessary
if (modifierType instanceof ModifierTypes.ModifierTypeGenerator) {
modifierType = modifierType.generateType(null, (item.type !== null) ? [item.type] : null);
}

// Create the held item
const heldItemModifier = modifierType.withIdFromFunc(modifierFunc).newModifier(pokemon) as PokemonHeldItemModifier;
heldItemModifier.pokemonId = pokemon.id; // Assign the created item to the pokemon
heldItemModifier.stackCount = qty; // Set quantity
heldItemModifier.pokemonId = pokemon.id;
heldItemModifier.stackCount = qty;

// Give it to the appropriate Pokemon
if (isPlayer) {
scene.addModifier(heldItemModifier, true, false, false, true);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export const SINGLE_BATTLE_OVERRIDE: boolean = false;
export const STARTING_WAVE_OVERRIDE: integer = 0;
export const STARTING_BIOME_OVERRIDE: Biome = Biome.TOWN;
export const ARENA_TINT_OVERRIDE: TimeOfDay = null;
// Multiplies XP gained by this value including 0. Set to null to ignore the override
export const NEVER_CRIT_OVERRIDE: boolean = false;
/** Multiplies XP gained by this value including 0. Set to null to ignore the override */
export const XP_MULTIPLIER_OVERRIDE: number = null;
export const NEVER_CRIT_OVERRIDE: boolean = false;
// default 1000
export const STARTING_MONEY_OVERRIDE: integer = 0;
export const FREE_CANDY_UPGRADE_OVERRIDE: boolean = false;
Expand Down

0 comments on commit 92cef84

Please sign in to comment.