Repurpose Oval Charm for multiple participant EXP bonus

This commit is contained in:
Flashfyre 2023-04-28 16:35:03 -04:00
parent a2ecb4089d
commit 140e759486
9 changed files with 1643 additions and 1603 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

View File

@ -5,7 +5,7 @@ import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, HitsTagAttr, Mis
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 "./data/pokemon-stat"; import { Stat } from "./data/pokemon-stat";
import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, HealingBoosterModifier, HeldItemTransferModifier, HitHealModifier, MapModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, TempBattleStatBoosterModifier, TurnHealModifier } from "./modifier/modifier"; import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, HealingBoosterModifier, HeldItemTransferModifier, HitHealModifier, MapModifier, MultipleParticipantExpBonusModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, TempBattleStatBoosterModifier, TurnHealModifier } from "./modifier/modifier";
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler"; import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball"; import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball";
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims"; import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
@ -1484,6 +1484,7 @@ export class VictoryPhase extends PokemonPhase {
const party = this.scene.getParty(); const party = this.scene.getParty();
const expShareModifier = this.scene.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier; const expShareModifier = this.scene.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier;
const expBalanceModifier = this.scene.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier; const expBalanceModifier = this.scene.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier;
const multipleParticipantExpBonusModifier = this.scene.findModifier(m => m instanceof MultipleParticipantExpBonusModifier) as MultipleParticipantExpBonusModifier;
const expValue = this.scene.getEnemyPokemon().getExpValue(); const expValue = this.scene.getEnemyPokemon().getExpValue();
const expPartyMembers = party.filter(p => p.hp && p.level < 100); const expPartyMembers = party.filter(p => p.hp && p.level < 100);
const partyMemberExp = []; const partyMemberExp = [];
@ -1499,8 +1500,10 @@ export class VictoryPhase extends PokemonPhase {
let expMultiplier = 0; let expMultiplier = 0;
if (participated) if (participated)
expMultiplier += (1 / participantIds.size); expMultiplier += (1 / participantIds.size);
if (participantIds.size > 1 && multipleParticipantExpBonusModifier)
expMultiplier += (multipleParticipantExpBonusModifier.getStackCount() * 0.1);
if (expShareModifier) if (expShareModifier)
expMultiplier += expShareModifier.stackCount * 0.1; expMultiplier += expShareModifier.getStackCount() * 0.1;
const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier); const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier);
this.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, pokemonExp); this.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, pokemonExp);
partyMemberExp.push(Math.floor(pokemonExp.value)); partyMemberExp.push(Math.floor(pokemonExp.value));

View File

@ -1,11 +1,11 @@
import Phaser from 'phaser'; import Phaser from 'phaser';
import { Biome } from './data/biome'; import { Biome } from './data/biome';
import UI from './ui/ui'; import UI from './ui/ui';
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, SelectStarterPhase, MessagePhase, CheckLoadPhase } from './battle-phases'; import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase } from './battle-phases';
import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon'; import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon';
import PokemonSpecies, { allSpecies, getPokemonSpecies, initSpecies } from './data/pokemon-species'; import PokemonSpecies, { allSpecies, getPokemonSpecies, initSpecies } from './data/pokemon-species';
import * as Utils from './utils'; import * as Utils from './utils';
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate } from './modifier/modifier'; import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate } from './modifier/modifier';
import { PokeballType } from './data/pokeball'; import { PokeballType } from './data/pokeball';
import { Species } from './data/species'; import { Species } from './data/species';
import { initAutoPlay } from './system/auto-play'; import { initAutoPlay } from './system/auto-play';
@ -838,9 +838,6 @@ export default class BattleScene extends Phaser.Scene {
(modifier as PersistentModifier).virtualStackCount = 0; (modifier as PersistentModifier).virtualStackCount = 0;
} }
if (player)
this.applyModifiers(PartyShareModifier, true, this, modifiers);
const modifiersClone = modifiers.slice(0); const modifiersClone = modifiers.slice(0);
for (let modifier of modifiersClone) { for (let modifier of modifiersClone) {
if (!modifier.getStackCount()) if (!modifier.getStackCount())

View File

@ -580,6 +580,9 @@ const modifierTypes = {
EXP_BALANCE: () => new ModifierType('EXP. BALANCE', 'All EXP. Points received from battles are split between the lower leveled party members', EXP_BALANCE: () => new ModifierType('EXP. BALANCE', 'All EXP. Points received from battles are split between the lower leveled party members',
(type, _args) => new Modifiers.ExpBalanceModifier(type), 'exp_balance'), (type, _args) => new Modifiers.ExpBalanceModifier(type), 'exp_balance'),
OVAL_CHARM: () => new ModifierType('OVAL CHARM', 'When multiple POKéMON participate in a battle, each gets an extra 10% of the total EXP',
(type, _args) => new Modifiers.MultipleParticipantExpBonusModifier(type), 'oval_charm'),
EXP_CHARM: () => new ExpBoosterModifierType('EXP CHARM', 25), EXP_CHARM: () => new ExpBoosterModifierType('EXP CHARM', 25),
GOLDEN_EXP_CHARM: () => new ExpBoosterModifierType('GOLDEN EXP CHARM', 100), GOLDEN_EXP_CHARM: () => new ExpBoosterModifierType('GOLDEN EXP CHARM', 100),
@ -588,10 +591,6 @@ const modifierTypes = {
HEALING_CHARM: () => new ModifierType('HEALING CHARM', 'Doubles the effectiveness of HP restoring moves and items (excludes revives)', HEALING_CHARM: () => new ModifierType('HEALING CHARM', 'Doubles the effectiveness of HP restoring moves and items (excludes revives)',
(type, _args) => new Modifiers.HealingBoosterModifier(type, 2), 'healing_charm'), (type, _args) => new Modifiers.HealingBoosterModifier(type, 2), 'healing_charm'),
OVAL_CHARM: () => new ModifierType('OVAL CHARM', 'For every X (no. of party members) items in a POKéMON\'s held item stack, give one to each other party member',
(type, _args) => new Modifiers.PartyShareModifier(type), 'oval_charm'),
CANDY_JAR: () => new ModifierType('CANDY JAR', 'Increases the number of levels added by RARE CANDY items by 1', (type, _args) => new Modifiers.LevelIncrementBoosterModifier(type)), CANDY_JAR: () => new ModifierType('CANDY JAR', 'Increases the number of levels added by RARE CANDY items by 1', (type, _args) => new Modifiers.LevelIncrementBoosterModifier(type)),
BERRY_POUCH: () => new ModifierType('BERRY POUCH', 'Adds a 25% chance that a used berry will not be consumed', BERRY_POUCH: () => new ModifierType('BERRY POUCH', 'Adds a 25% chance that a used berry will not be consumed',
@ -684,7 +683,6 @@ const modifierPool = {
new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, 12), new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, 12),
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5), new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5),
new WeightedModifierType(modifierTypes.CANDY_JAR, 3), new WeightedModifierType(modifierTypes.CANDY_JAR, 3),
//new WeightedModifierType(modifierTypes.OVAL_CHARM, 1),
new WeightedModifierType(modifierTypes.HEALING_CHARM, 1), new WeightedModifierType(modifierTypes.HEALING_CHARM, 1),
new WeightedModifierType(modifierTypes.FOCUS_BAND, 3), new WeightedModifierType(modifierTypes.FOCUS_BAND, 3),
new WeightedModifierType(modifierTypes.KINGS_ROCK, 2), new WeightedModifierType(modifierTypes.KINGS_ROCK, 2),
@ -692,8 +690,10 @@ const modifierPool = {
new WeightedModifierType(modifierTypes.SHELL_BELL, 2), new WeightedModifierType(modifierTypes.SHELL_BELL, 2),
new WeightedModifierType(modifierTypes.BERRY_POUCH, 3), new WeightedModifierType(modifierTypes.BERRY_POUCH, 3),
new WeightedModifierType(modifierTypes.EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 4 : 0), new WeightedModifierType(modifierTypes.EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 4 : 0),
new WeightedModifierType(modifierTypes.OVAL_CHARM, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 2 : 0),
new WeightedModifierType(modifierTypes.LUCKY_EGG, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 3 : 0), new WeightedModifierType(modifierTypes.LUCKY_EGG, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 3 : 0),
new WeightedModifierType(modifierTypes.EXP_BALANCE, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 1 : 0) new WeightedModifierType(modifierTypes.EXP_BALANCE,
(party: Pokemon[]) => party.filter(p => p.level < 100).length && !party[0].scene.findModifier(m => m instanceof Modifiers.ExpBalanceModifier) ? 1 : 0)
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }), ].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [ [ModifierTier.MASTER]: [
new WeightedModifierType(modifierTypes.MASTER_BALL, 3), new WeightedModifierType(modifierTypes.MASTER_BALL, 3),

View File

@ -780,48 +780,25 @@ export class EvolutionItemModifier extends ConsumablePokemonModifier {
} }
} }
export class PartyShareModifier extends PersistentModifier { export class MultipleParticipantExpBonusModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: integer) { constructor(type: ModifierType, stackCount?: integer) {
super(type, stackCount); super(type, stackCount);
} }
match(modifier: Modifier) { match(modifier: Modifier): boolean {
return modifier instanceof PartyShareModifier; return modifier instanceof MultipleParticipantExpBonusModifier;
} }
clone(): PartyShareModifier { apply(_args: any[]): boolean {
return new PartyShareModifier(this.type, this.stackCount);
}
shouldApply(args: any[]): boolean {
return super.shouldApply(args) && args.length === 2 && args[0] instanceof BattleScene && args[1] instanceof Array<Modifier>;
}
apply(args: any[]): boolean {
const scene = args[0] as BattleScene;
const modifiers = args[1] as Modifier[];
const party = scene.getParty();
for (let modifier of modifiers) {
if (modifier instanceof PokemonHeldItemModifier) {
const heldItemModifier = modifier as PokemonHeldItemModifier;
const extraStacks = Math.floor(modifier.stackCount / Math.max(party.length - (this.stackCount - 1), 1));
for (let s = 0; s < extraStacks; s++) {
for (let p of party) {
if (p.id === heldItemModifier.pokemonId)
continue;
const newHeldItemModifier = heldItemModifier.clone() as PokemonHeldItemModifier;
newHeldItemModifier.pokemonId = p.id;
scene.addModifier(newHeldItemModifier, false, true);
}
}
}
}
return true; return true;
} }
getMaxStackCount(): number { clone(): MultipleParticipantExpBonusModifier {
return 6; return new MultipleParticipantExpBonusModifier(this.type, this.stackCount);
}
getMaxStackCount(): integer {
return 5;
} }
} }