Add EXP. Balance

pull/1/head
Flashfyre 2023-04-19 22:51:46 -04:00
parent fb52c4a6ed
commit 14c792506f
7 changed files with 1198 additions and 1116 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 441 B

View File

@ -5,7 +5,7 @@ import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveA
import { Mode } from './ui/ui';
import { Command } from "./ui/command-ui-handler";
import { Stat } from "./pokemon-stat";
import { ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HitHealModifier, PokemonExpBoosterModifier, TempBattleStatBoosterModifier } from "./modifier";
import { ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HitHealModifier, PokemonExpBoosterModifier, TempBattleStatBoosterModifier } from "./modifier";
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./pokeball";
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims";
@ -502,8 +502,13 @@ export class CommandPhase extends BattlePhase {
success = true;
} else if (cursor < playerPokemon.moveset.length) {
const move = playerPokemon.moveset[cursor];
if (move.isDisabled())
this.scene.ui.showText(`${move.getName()} is disabled!`);
if (move.isDisabled()) {
this.scene.ui.setMode(Mode.MESSAGE);
this.scene.ui.showText(`${move.getName()} is disabled!`, null, () => {
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.FIGHT);
}, null, true);
}
}
break;
@ -1292,24 +1297,56 @@ export class VictoryPhase extends PokemonPhase {
const participantIds = this.scene.currentBattle.playerParticipantIds;
const party = this.scene.getParty();
const expShareModifier = this.scene.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier;
const expBalanceModifier = this.scene.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier;
const expValue = this.scene.getEnemyPokemon().getExpValue();
for (let pm = 0; pm < party.length; pm++) {
const pokemon = party[pm];
if (!pokemon.hp)
continue;
const pId = pokemon.id;
const expPartyMembers = party.filter(p => p.hp && p.level < 100);
const partyMemberExp = [];
for (let partyMember of expPartyMembers) {
const pId = partyMember.id;
const participated = participantIds.has(pId);
if (!participated && !expShareModifier)
if (!participated && !expShareModifier) {
partyMemberExp.push(0);
continue;
if (pokemon.level < 100) {
let expMultiplier = 0;
if (participated)
expMultiplier += (1 / participantIds.size);
if (expShareModifier)
expMultiplier += expShareModifier.stackCount * 0.1;
const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier);
this.scene.applyModifiers(PokemonExpBoosterModifier, pokemon, pokemonExp);
this.scene.unshiftPhase(new ExpPhase(this.scene, pm, Math.floor(pokemonExp.value)));
}
let expMultiplier = 0;
if (participated)
expMultiplier += (1 / participantIds.size);
if (expShareModifier)
expMultiplier += expShareModifier.stackCount * 0.1;
const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier);
this.scene.applyModifiers(PokemonExpBoosterModifier, partyMember, pokemonExp);
partyMemberExp.push(Math.floor(pokemonExp.value));
}
if (expBalanceModifier) {
let totalLevel = 0;
let totalExp = 0;
expPartyMembers.forEach((expPartyMember, epm) => {
totalExp += partyMemberExp[epm];
totalLevel += expPartyMember.level;
});
const medianLevel = Math.floor(totalLevel / expPartyMembers.length);
const recipientExpPartyMemberIndexes = [];
expPartyMembers.forEach((expPartyMember, epm) => {
if (expPartyMember.level <= medianLevel)
recipientExpPartyMemberIndexes.push(epm);
});
const splitExp = Math.floor(totalExp / recipientExpPartyMemberIndexes.length);
expPartyMembers.forEach((_partyMember, pm) => {
partyMemberExp[pm] = recipientExpPartyMemberIndexes.indexOf(pm) > -1 ? splitExp : 0;
});
}
for (let pm = 0; pm < expPartyMembers.length; pm++) {
const exp = partyMemberExp[pm];
if (exp) {
const partyMemberIndex = party.indexOf(expPartyMembers[pm]);
this.scene.unshiftPhase(new ExpPhase(this.scene, partyMemberIndex, exp));
}
}

View File

@ -311,7 +311,8 @@ export class ExpBoosterModifierType extends ModifierType {
export class PokemonExpBoosterModifierType extends PokemonModifierType {
constructor(name: string, boostPercent: integer, iconImage?: string) {
super(name, `Increases the holder's gain of EXP. Points by ${boostPercent}%`, (_type, args) => new Modifiers.PokemonExpBoosterModifier(this, (args[0] as PlayerPokemon).id, boostPercent), iconImage);
super(name, `Increases the holder's gain of EXP. Points by ${boostPercent}%`, (_type, args) => new Modifiers.PokemonExpBoosterModifier(this, (args[0] as PlayerPokemon).id, boostPercent),
(_pokemon: PlayerPokemon) => null, iconImage);
}
}
@ -524,7 +525,6 @@ const modifierPool = {
return new TmModifierType(uniqueCompatibleTms[randTmIndex]);
}), 4),
new WeightedModifierType(new ModifierType('EXP. SHARE', 'All POKéMON in your party gain an additional 10% of a battle\'s EXP. Points', (type, _args) => new Modifiers.ExpShareModifier(type), 'exp_share'), 2),
new WeightedModifierType(new PokemonExpBoosterModifierType('LUCKY EGG', 50), 2),
new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => {
const randStat = Utils.randInt(6) as Stat;
return new PokemonBaseStatBoosterModifierType(getBaseStatBoosterItemName(randStat), randStat);
@ -538,7 +538,9 @@ const modifierPool = {
(type, _args) => new Modifiers.PartyShareModifier(type), 'oval_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'),
new WeightedModifierType(new PokemonModifierType('SHELL BELL', 'Heals 1/8 of a POKéMON\'s dealt damage', (type, args) => new Modifiers.HitHealModifier(type, (args[0] as PlayerPokemon).id)), 2),
new WeightedModifierType(new ExpBoosterModifierType('EXP CHARM', 25), 4)
new WeightedModifierType(new ExpBoosterModifierType('EXP CHARM', 25), 4),
new WeightedModifierType(new PokemonExpBoosterModifierType('LUCKY EGG', 50), 3),
new WeightedModifierType(new ModifierType('EXP. BALANCE', 'All EXP. Points received from battles is split among the lower leveled party members', (type, _args) => new Modifiers.ExpBalanceModifier(type), 'exp_balance'), 1)
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [
new AddPokeballModifierType(PokeballType.MASTER_BALL, 1, 'mb'),
@ -580,7 +582,7 @@ export function regenerateModifierPoolThresholds(party: PlayerPokemon[]) {
})));
}
export function getModifierTypeOptionsForWave(waveIndex: integer, count: integer, party: PlayerPokemon[]): ModifierTypeOption[] {
export function getModifierTypeOptionsForWave(waveIndex: integer, count: integer, party: PlayerPokemon[], maxedTypes: ModifierType[]): ModifierTypeOption[] {
if (waveIndex % 10 === 0)
return modifierPool[ModifierTier.LUXURY].map(m => new ModifierTypeOption(m, false));
const options: ModifierTypeOption[] = [];

View File

@ -677,6 +677,28 @@ export class ExpShareModifier extends PersistentModifier {
}
}
export class ExpBalanceModifier extends PersistentModifier {
constructor(type: ModifierType) {
super(type);
}
match(modifier: Modifier): boolean {
return modifier instanceof ExpBalanceModifier;
}
apply(_args: any[]): boolean {
return true;
}
clone(): ExpBalanceModifier {
return new ExpBalanceModifier(this.type);
}
getMaxStackCount(): integer {
return 1;
}
}
export class ShinyRateBoosterModifier extends PersistentModifier {
constructor(type: ModifierType) {
super(type);