[Bug] Fixing Baton Pass passing (#2058)

* skip yawn and infatuation for baton pass, and some docs along the way

* update yawn condition readability
This commit is contained in:
DustinLin 2024-06-12 07:19:50 -07:00 committed by GitHub
parent c71d794d97
commit e5d9cfd10f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -695,6 +695,10 @@ export default class BattleScene extends SceneBase {
return this.getPlayerField().find(p => p.isActive());
}
/**
* Returns an array of PlayerPokemon of length 1 or 2 depending on if double battles or not
* @returns array of {@linkcode PlayerPokemon}
*/
getPlayerField(): PlayerPokemon[] {
const party = this.getParty();
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
@ -708,6 +712,10 @@ export default class BattleScene extends SceneBase {
return this.getEnemyField().find(p => p.isActive());
}
/**
* Returns an array of EnemyPokemon of length 1 or 2 depending on if double battles or not
* @returns array of {@linkcode EnemyPokemon}
*/
getEnemyField(): EnemyPokemon[] {
const party = this.getEnemyParty();
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));

View File

@ -2167,12 +2167,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
tags.filter(t => t.sourceId === sourceId).forEach(t => t.sourceId = newSourceId);
}
/**
* Transferring stat changes and Tags
* @param source {@linkcode Pokemon} the pokemon whose stats/Tags are to be passed on from, ie: the Pokemon using Baton Pass
*/
transferSummon(source: Pokemon): void {
const battleStats = Utils.getEnumValues(BattleStat);
for (const stat of battleStats) {
this.summonData.battleStats[stat] = source.summonData.battleStats[stat];
}
for (const tag of source.summonData.tags) {
// bypass yawn, and infatuation as those can not be passed via Baton Pass
if (tag.sourceMove === Moves.YAWN || tag.tagType === BattlerTagType.INFATUATED) {
continue;
}
this.summonData.tags.push(tag);
}
if (this instanceof PlayerPokemon && source.summonData.battleStats.find(bs => bs === 6)) {