Fix visual bug with boss segments

pull/16/head
Flashfyre 2024-03-01 11:35:13 -05:00
parent 0dc53bfeb8
commit ed1f82b476
1 changed files with 21 additions and 21 deletions

View File

@ -2345,35 +2345,35 @@ export class EnemyPokemon extends Pokemon {
let bossSegmentIndex = this.bossSegmentIndex; let bossSegmentIndex = this.bossSegmentIndex;
if (this.isBoss()) { if (this.isBoss() && !ignoreSegments) {
if (!ignoreSegments) { const segmentSize = this.getMaxHp() / this.bossSegments;
const segmentSize = this.getMaxHp() / this.bossSegments; for (let s = this.bossSegmentIndex; s > 0; s--) {
for (let s = this.bossSegmentIndex; s > 0; s--) { const hpThreshold = segmentSize * s;
const hpThreshold = segmentSize * s; const roundedHpThreshold = Math.round(hpThreshold);
const roundedHpThreshold = Math.round(hpThreshold); if (this.hp >= roundedHpThreshold) {
if (this.hp >= roundedHpThreshold) { if (this.hp - damage <= roundedHpThreshold) {
if (this.hp - damage <= roundedHpThreshold) { const hpRemainder = this.hp - roundedHpThreshold;
const hpRemainder = this.hp - roundedHpThreshold; let segmentsBypassed = 0;
let segmentsBypassed = 0; while (segmentsBypassed < this.bossSegmentIndex && this.canBypassBossSegments(segmentsBypassed + 1) && (damage - hpRemainder) >= Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))) {
while (segmentsBypassed < this.bossSegmentIndex && this.canBypassBossSegments(segmentsBypassed + 1) && (damage - hpRemainder) >= Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))) { segmentsBypassed++;
segmentsBypassed++; //console.log('damage', damage, 'segment', segmentsBypassed + 1, 'segment size', segmentSize, 'damage needed', Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1)));
//console.log('damage', damage, 'segment', segmentsBypassed + 1, 'segment size', segmentSize, 'damage needed', Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1)));
}
damage = hpRemainder + Math.round(segmentSize * segmentsBypassed);
bossSegmentIndex = s - segmentsBypassed;
} }
break;
damage = hpRemainder + Math.round(segmentSize * segmentsBypassed);
bossSegmentIndex = s - segmentsBypassed;
} }
break;
} }
} }
this.battleInfo.updateBossSegments(this);
} }
const ret = super.damage(damage, ignoreSegments, preventEndure); const ret = super.damage(damage, ignoreSegments, preventEndure);
if (this.isBoss() && bossSegmentIndex < this.bossSegmentIndex) if (this.isBoss()) {
this.handleBossSegmentCleared(bossSegmentIndex); if (bossSegmentIndex < this.bossSegmentIndex)
this.handleBossSegmentCleared(bossSegmentIndex);
this.battleInfo.updateBossSegments(this);
}
return ret; return ret;
} }