Skip to content

Commit

Permalink
format players for braniac and skills differently (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
horrible-little-slime authored Aug 19, 2024
1 parent 5317b1e commit 820d416
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/oaf/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(v: T | T[]) {
Expand Down

0 comments on commit 820d416

Please sign in to comment.