[Bug] add playerfiled length check for score determination (#2583)

This commit is contained in:
flx-sta 2024-06-24 21:15:11 -07:00 committed by GitHub
parent bbc07e22bf
commit 3e5ef3e3fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -436,6 +436,8 @@ export default class Trainer extends Phaser.GameObjects.Container {
const partyMemberScores = nonFaintedLegalPartyMembers.map(p => {
const playerField = this.scene.getPlayerField().filter(p => p.isAllowedInBattle());
let score = 0;
if (playerField.length > 0) {
for (const playerPokemon of playerField) {
score += p.getMatchupScore(playerPokemon);
if (playerPokemon.species.legendary) {
@ -446,6 +448,8 @@ export default class Trainer extends Phaser.GameObjects.Container {
if (forSwitch && !p.isOnField()) {
this.scene.arena.findTagsOnSide(t => t instanceof ArenaTrapTag, ArenaTagSide.ENEMY).map(t => score *= (t as ArenaTrapTag).getMatchupScoreMultiplier(p));
}
}
return [party.indexOf(p), score];
}) as [integer, integer][];