Skip to content

Commit

Permalink
fix: Change manually repeating spaces to padStart/padEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiln committed Mar 5, 2024
1 parent 9976d3d commit e4b0c54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions slash/faction.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class Faction extends Command {
factionChars.push("**`=================" + "=".repeat(lvlMax + gpMax + gearMax) + "`**");

playerChars.forEach(c => {
const lvlStr = " ".repeat(lvlMax - c.level.toString().length) + c.level;
const gpStr = " ".repeat(gpMax - c.gp.length) + c.gp;
const gearStr = " ".repeat(gearMax - c.gear.toString().length) + c.gear;
const lvlStr = c.level.toString().padStart(lvlMax - c.level.toString().length);
const gpStr = c.gp.toString().padStart(gpMax - c.gp.length);
const gearStr = c.gear.toString().padStart(gearMax - c.gear.toString().length);
const zetas = "z".repeat(c.skills.filter(s => (s.isZeta && s.tier === s.tiers) || (s.isOmicron && s.tier >= s.tiers-1)).length);
factionChars.push(`**\`[ ${c.rarity} | ${lvlStr} | ${gpStr} | ${gearStr} ]\` ${zetas}${c.nameKey}**`);
});
Expand Down
4 changes: 2 additions & 2 deletions slash/mycharacter.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class MyCharacter extends Command {
if (!thisLangStr?.length) {
console.log("[/mycharacter] Missing stat langStr:");
console.log(s, thisLangStr);
statStr += s + " ".repeat(8 - s.length) + "\n";
statStr += s.toString().padEnd(8-s.length) + "\n";
} else {
const rep = maxLen - (thisLangStr?.length || 0);
if (s === "Dodge Chance" || s === "Deflection Chance") {
Expand All @@ -248,7 +248,7 @@ class MyCharacter extends Command {
statStr += `${langStr[langMap[s]]}${" ".repeat(rep > 0 ? rep : 0)} :: `;
const str = stats.final[s] % 1 === 0 ? stats.final[s].toLocaleString() : (stats.final[s] * 100).toFixed(2)+"%";
const modStr = isShip ? "" : stats.mods[s] ? (stats.mods[s] % 1 === 0 ? `(${stats.mods[s].toLocaleString()})` : `(${(stats.mods[s] * 100).toFixed(2)}%)`) : "";
statStr += str + " ".repeat(8 - str.length) + modStr + "\n";
statStr += s.toString().padEnd(8-s.length) + modStr + "\n";
}
}
});
Expand Down

0 comments on commit e4b0c54

Please sign in to comment.