Fix infinite EXP bug
This commit is contained in:
parent
e5fe0c6e3a
commit
1a9c492a79
|
@ -2157,61 +2157,64 @@ export class VictoryPhase extends PokemonPhase {
|
||||||
const multipleParticipantExpBonusModifier = this.scene.findModifier(m => m instanceof MultipleParticipantExpBonusModifier) as MultipleParticipantExpBonusModifier;
|
const multipleParticipantExpBonusModifier = this.scene.findModifier(m => m instanceof MultipleParticipantExpBonusModifier) as MultipleParticipantExpBonusModifier;
|
||||||
const expPartyMembers = party.filter(p => p.hp && p.level < this.scene.getMaxExpLevel());
|
const expPartyMembers = party.filter(p => p.hp && p.level < this.scene.getMaxExpLevel());
|
||||||
const partyMemberExp = [];
|
const partyMemberExp = [];
|
||||||
let expValue = this.getPokemon().getExpValue();
|
|
||||||
if (this.scene.currentBattle.battleType === BattleType.TRAINER)
|
if (participantIds.size) {
|
||||||
expValue = Math.floor(expValue * 1.5);
|
let expValue = this.getPokemon().getExpValue();
|
||||||
for (let partyMember of expPartyMembers) {
|
if (this.scene.currentBattle.battleType === BattleType.TRAINER)
|
||||||
const pId = partyMember.id;
|
expValue = Math.floor(expValue * 1.5);
|
||||||
const participated = participantIds.has(pId);
|
for (let partyMember of expPartyMembers) {
|
||||||
if (participated)
|
const pId = partyMember.id;
|
||||||
partyMember.winCount++;
|
const participated = participantIds.has(pId);
|
||||||
else if (!expShareModifier) {
|
if (participated)
|
||||||
partyMemberExp.push(0);
|
partyMember.winCount++;
|
||||||
continue;
|
else if (!expShareModifier) {
|
||||||
|
partyMemberExp.push(0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let expMultiplier = 0;
|
||||||
|
if (participated) {
|
||||||
|
expMultiplier += (1 / participantIds.size);
|
||||||
|
if (participantIds.size > 1 && multipleParticipantExpBonusModifier)
|
||||||
|
expMultiplier += multipleParticipantExpBonusModifier.getStackCount() * 0.2;
|
||||||
|
} else if (expShareModifier)
|
||||||
|
expMultiplier += (expShareModifier.getStackCount() * 0.2) / participantIds.size;
|
||||||
|
if (partyMember.pokerus)
|
||||||
|
expMultiplier *= 1.5;
|
||||||
|
const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier);
|
||||||
|
this.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, pokemonExp);
|
||||||
|
partyMemberExp.push(Math.floor(pokemonExp.value));
|
||||||
}
|
}
|
||||||
let expMultiplier = 0;
|
|
||||||
if (participated) {
|
|
||||||
expMultiplier += (1 / participantIds.size);
|
|
||||||
if (participantIds.size > 1 && multipleParticipantExpBonusModifier)
|
|
||||||
expMultiplier += multipleParticipantExpBonusModifier.getStackCount() * 0.2;
|
|
||||||
} else if (expShareModifier)
|
|
||||||
expMultiplier += (expShareModifier.getStackCount() * 0.2) / participantIds.size;
|
|
||||||
if (partyMember.pokerus)
|
|
||||||
expMultiplier *= 1.5;
|
|
||||||
const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier);
|
|
||||||
this.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, pokemonExp);
|
|
||||||
partyMemberExp.push(Math.floor(pokemonExp.value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expBalanceModifier) {
|
if (expBalanceModifier) {
|
||||||
let totalLevel = 0;
|
let totalLevel = 0;
|
||||||
let totalExp = 0;
|
let totalExp = 0;
|
||||||
expPartyMembers.forEach((expPartyMember, epm) => {
|
expPartyMembers.forEach((expPartyMember, epm) => {
|
||||||
totalExp += partyMemberExp[epm];
|
totalExp += partyMemberExp[epm];
|
||||||
totalLevel += expPartyMember.level;
|
totalLevel += expPartyMember.level;
|
||||||
});
|
});
|
||||||
|
|
||||||
const medianLevel = Math.floor(totalLevel / expPartyMembers.length);
|
const medianLevel = Math.floor(totalLevel / expPartyMembers.length);
|
||||||
|
|
||||||
const recipientExpPartyMemberIndexes = [];
|
const recipientExpPartyMemberIndexes = [];
|
||||||
expPartyMembers.forEach((expPartyMember, epm) => {
|
expPartyMembers.forEach((expPartyMember, epm) => {
|
||||||
if (expPartyMember.level <= medianLevel)
|
if (expPartyMember.level <= medianLevel)
|
||||||
recipientExpPartyMemberIndexes.push(epm);
|
recipientExpPartyMemberIndexes.push(epm);
|
||||||
});
|
});
|
||||||
|
|
||||||
const splitExp = Math.floor(totalExp / recipientExpPartyMemberIndexes.length);
|
const splitExp = Math.floor(totalExp / recipientExpPartyMemberIndexes.length);
|
||||||
|
|
||||||
expPartyMembers.forEach((_partyMember, pm) => {
|
expPartyMembers.forEach((_partyMember, pm) => {
|
||||||
partyMemberExp[pm] = recipientExpPartyMemberIndexes.indexOf(pm) > -1 ? splitExp : 0;
|
partyMemberExp[pm] = recipientExpPartyMemberIndexes.indexOf(pm) > -1 ? splitExp : 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let pm = 0; pm < expPartyMembers.length; pm++) {
|
for (let pm = 0; pm < expPartyMembers.length; pm++) {
|
||||||
const exp = partyMemberExp[pm];
|
const exp = partyMemberExp[pm];
|
||||||
|
|
||||||
if (exp) {
|
if (exp) {
|
||||||
const partyMemberIndex = party.indexOf(expPartyMembers[pm]);
|
const partyMemberIndex = party.indexOf(expPartyMembers[pm]);
|
||||||
this.scene.unshiftPhase(expPartyMembers[pm].isOnField() ? new ExpPhase(this.scene, partyMemberIndex, exp) : new ShowPartyExpBarPhase(this.scene, partyMemberIndex, exp));
|
this.scene.unshiftPhase(expPartyMembers[pm].isOnField() ? new ExpPhase(this.scene, partyMemberIndex, exp) : new ShowPartyExpBarPhase(this.scene, partyMemberIndex, exp));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue