mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-13 11:52:18 +02:00
Update changeStat method to use summonData for Pokemon stats
This commit modifies the `changeStat` method in the `Pokemon` class to use the `summonData` object for updating Pokemon stats instead of directly modifying the `stats` object. This change ensures that the updated stats are correctly reflected in the `summonData` object, which is used for battle calculations and other related operations. Refactor the `getStat` method to check if `summonData` exists and return the corresponding stat value from `summonData.stats` if it does. Otherwise, return the stat value from the `stats` object. This change improves the accuracy of stat calculations during battles and ensures consistency between the `stats` and `summonData` objects.
This commit is contained in:
parent
5a8c0d81e9
commit
e6b26aa099
@ -1765,15 +1765,15 @@ export class PowerSplitAttr extends MoveEffectAttr {
|
|||||||
const infoUpdates = [];
|
const infoUpdates = [];
|
||||||
|
|
||||||
const attackValue = Math.floor((target.getStat(Stat.ATK) + user.getStat(Stat.ATK)) / 2);
|
const attackValue = Math.floor((target.getStat(Stat.ATK) + user.getStat(Stat.ATK)) / 2);
|
||||||
user.changeStat(Stat.ATK, attackValue);
|
user.changeSummonStat(Stat.ATK, attackValue);
|
||||||
infoUpdates.push(user.updateInfo());
|
infoUpdates.push(user.updateInfo());
|
||||||
target.changeStat(Stat.ATK, attackValue);
|
target.changeSummonStat(Stat.ATK, attackValue);
|
||||||
infoUpdates.push(target.updateInfo());
|
infoUpdates.push(target.updateInfo());
|
||||||
|
|
||||||
const specialAttackValue = Math.floor((target.getStat(Stat.SPATK) + user.getStat(Stat.SPATK)) / 2);
|
const specialAttackValue = Math.floor((target.getStat(Stat.SPATK) + user.getStat(Stat.SPATK)) / 2);
|
||||||
user.changeStat(Stat.SPATK, specialAttackValue);
|
user.changeSummonStat(Stat.SPATK, specialAttackValue);
|
||||||
infoUpdates.push(user.updateInfo());
|
infoUpdates.push(user.updateInfo());
|
||||||
target.changeStat(Stat.SPATK, specialAttackValue);
|
target.changeSummonStat(Stat.SPATK, specialAttackValue);
|
||||||
infoUpdates.push(target.updateInfo());
|
infoUpdates.push(target.updateInfo());
|
||||||
|
|
||||||
return Promise.all(infoUpdates).then(() => resolve(true));
|
return Promise.all(infoUpdates).then(() => resolve(true));
|
||||||
|
@ -543,7 +543,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStat(stat: Stat): integer {
|
getStat(stat: Stat): integer {
|
||||||
return this.stats[stat];
|
if (!this.summonData)
|
||||||
|
{
|
||||||
|
return this.stats[stat];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.summonData.stats[stat];
|
||||||
}
|
}
|
||||||
|
|
||||||
getBattleStat(stat: Stat, opponent?: Pokemon, move?: Move, isCritical: boolean = false): integer {
|
getBattleStat(stat: Stat, opponent?: Pokemon, move?: Move, isCritical: boolean = false): integer {
|
||||||
@ -1552,9 +1557,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return healAmount;
|
return healAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeStat(stat: Stat, value: integer) : void
|
changeSummonStat(stat: Stat, value: integer) : void
|
||||||
{
|
{
|
||||||
this.stats[stat] = value;
|
this.summonData.stats[stat] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
isBossImmune(): boolean {
|
isBossImmune(): boolean {
|
||||||
@ -1994,6 +1999,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
if (!this.battleData)
|
if (!this.battleData)
|
||||||
this.resetBattleData();
|
this.resetBattleData();
|
||||||
this.resetBattleSummonData();
|
this.resetBattleSummonData();
|
||||||
|
this.summonData.stats = this.stats;
|
||||||
if (this.summonDataPrimer) {
|
if (this.summonDataPrimer) {
|
||||||
for (let k of Object.keys(this.summonData)) {
|
for (let k of Object.keys(this.summonData)) {
|
||||||
if (this.summonDataPrimer[k])
|
if (this.summonDataPrimer[k])
|
||||||
|
@ -112,6 +112,7 @@ export default class PokemonData {
|
|||||||
this.summonData = new PokemonSummonData();
|
this.summonData = new PokemonSummonData();
|
||||||
if (!forHistory && source.summonData) {
|
if (!forHistory && source.summonData) {
|
||||||
this.summonData.battleStats = source.summonData.battleStats;
|
this.summonData.battleStats = source.summonData.battleStats;
|
||||||
|
this.summonData.stats = source.summonData.stats;
|
||||||
this.summonData.moveQueue = source.summonData.moveQueue;
|
this.summonData.moveQueue = source.summonData.moveQueue;
|
||||||
this.summonData.disabledMove = source.summonData.disabledMove;
|
this.summonData.disabledMove = source.summonData.disabledMove;
|
||||||
this.summonData.disabledTurns = source.summonData.disabledTurns;
|
this.summonData.disabledTurns = source.summonData.disabledTurns;
|
||||||
|
Loading…
Reference in New Issue
Block a user