From 820d41609b295b14175e92c859cc7552087372ff Mon Sep 17 00:00:00 2001 From: neil <78829653+horrible-little-slime@users.noreply.github.com> Date: Sun, 18 Aug 2024 21:54:52 -0400 Subject: [PATCH] format players for braniac and skills differently (#218) --- packages/oaf/src/utils.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/oaf/src/utils.ts b/packages/oaf/src/utils.ts index c6c5b5e..6dfad58 100644 --- a/packages/oaf/src/utils.ts +++ b/packages/oaf/src/utils.ts @@ -123,14 +123,22 @@ export function titleCase(title: string) { } export function formatPlayer(player: Player | undefined, backupId?: number) { - const discordId = player?.discordId; - return discordId - ? `${userMention(discordId)}${hyperlink( - "👤", - `https://www.kingdomofloathing.com/showplayer.php?who=${player.playerId}`, - player.playerName, - )}` - : player?.playerName || `Player #${backupId}` || "Unknown player"; + return [ + player?.playerName ?? "Unknown Username", + ...(player?.playerId + ? [ + `(#${player.playerId})`, + hyperlink( + "👤", + `https://www.kingdomofloathing.com/showplayer.php?who=${player.playerId}`, + player.playerName, + ), + ] + : backupId + ? [`(#${backupId})`] + : []), + ...(player?.discordId ? userMention(player.discordId) : ""), + ].join(" "); } export function ensureArray(v: T | T[]) {