Predetermine overflow line breaks

This commit is contained in:
Flashfyre 2024-04-06 23:03:20 -04:00
parent af3d9cb34c
commit 70a4d54ec9
3 changed files with 19 additions and 3 deletions

View File

@ -504,8 +504,8 @@ export const trainerTypeDialogue = {
$@c{smile_eclosed}It's like I can barely remember the memories we cherished together.
$@c{smile_ehalf}Were they even real? They seem so far away now
$@c{angry_mopen}You need to keep pushing, because if you don't, it will never end. You're the only one who can do this.
$I don't know what all this means… but I feel it's true.
$If you can't defeat me here and now, you won't stand a chance.`
$@c{smile_ehalf}I don't know what all this means… but I feel it's true.
$@c{neutral}If you can't defeat me here and now, you won't stand a chance.`
],
victory: [
`@c{smile_ehalf}I… I think I fulfilled my purpose…

View File

@ -752,6 +752,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.isTerastallized() ? 2 : 1;
const types = this.getTypes(true, true);
let multiplier = getTypeDamageMultiplier(moveType, types[0]) * (types.length > 1 ? getTypeDamageMultiplier(moveType, types[1]) : 1) as TypeDamageMultiplier;
// Handle strong winds lowering effectiveness of types super effective against pure flying
if (this.scene.arena.weather?.weatherType === WeatherType.STRONG_WINDS && !this.scene.arena.weather.isEffectSuppressed(this.scene) && multiplier >= 2 && this.isOfType(Type.FLYING) && getTypeDamageMultiplier(moveType, Type.FLYING) === 2)
multiplier /= 2;
return multiplier;

View File

@ -45,8 +45,23 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
soundMap.set(actionMatch.index, actionMatch[2]);
break;
}
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
// Predetermine overflow line breaks to avoid words breaking while displaying
const textWords = text.split(' ');
let lastLineCount = 1;
let newText = textWords[0];
for (let w = 1; w < textWords.length; w++) {
const nextWordText = `${newText} ${textWords[w]}`;
const lineCount = this.message.runWordWrap(nextWordText).split(/\n/g).length;
if (lineCount > lastLineCount) {
lastLineCount = lineCount;
newText = `${newText}\n${textWords[w]}`;
} else
newText = nextWordText;
}
text = newText;
}
if (this.textTimer) {
this.textTimer.remove();