diff --git a/api/index.ts b/api/index.ts index dfe8e19c..a7b05295 100644 --- a/api/index.ts +++ b/api/index.ts @@ -60,6 +60,7 @@ async function app(req: Request): Promise { const ranks: Array = params.getAll("rank").flatMap((r) => r.split(",") ).map((r) => r.trim()); + const trophy_style = params.get("trophy_style"); if (username === null) { const [base] = req.url.split("?"); @@ -139,6 +140,7 @@ async function app(req: Request): Promise { paddingHeight, noBackground, noFrame, + trophy_style, ).render(userInfo, theme), { headers: defaultHeaders, diff --git a/src/TrophyStyles/football.ts b/src/TrophyStyles/football.ts new file mode 100644 index 00000000..0b945080 --- /dev/null +++ b/src/TrophyStyles/football.ts @@ -0,0 +1,21 @@ +const SECRET = ``; +const SSS = ``; +const SS = ``; +const S = ``; +const AAA = ``; +const AA = ``; +const A = ``; +const B = ``; +const C = ``; + +export default { + SECRET, + SSS, + SS, + S, + AAA, + AA, + A, + B, + C, +}; \ No newline at end of file diff --git a/src/TrophyStyles/index.ts b/src/TrophyStyles/index.ts new file mode 100644 index 00000000..61000936 --- /dev/null +++ b/src/TrophyStyles/index.ts @@ -0,0 +1,7 @@ +import football from "./football.ts"; + +export const trophyStyles = { + football +}; + +export default trophyStyles; \ No newline at end of file diff --git a/src/card.ts b/src/card.ts index b2762b42..7c2d70e2 100644 --- a/src/card.ts +++ b/src/card.ts @@ -16,6 +16,7 @@ export class Card { private marginHeight: number, private noBackground: boolean, private noFrame: boolean, + private trophyStyle: string | null, ) { this.width = panelSize * this.maxColumn + this.marginWidth * (this.maxColumn - 1); @@ -61,7 +62,7 @@ export class Card { fill="none" xmlns="http://www.w3.org/2000/svg" > - ${this.renderTrophy(trophyList, theme)} + ${this.renderTrophy(trophyList, theme, this.trophyStyle)} `; } private getRow(trophyList: TrophyList) { @@ -76,7 +77,7 @@ export class Card { return this.panelSize * row + this.marginHeight * (row - 1); } - private renderTrophy(trophyList: TrophyList, theme: Theme) { + private renderTrophy(trophyList: TrophyList, theme: Theme, trophyStyle: string | null) { return trophyList.getArray.reduce( (sum: string, trophy: Trophy, i: number) => { const currentColumn = i % this.maxColumn; @@ -92,6 +93,7 @@ export class Card { this.panelSize, this.noBackground, this.noFrame, + trophyStyle, ); }, "", diff --git a/src/icons.ts b/src/icons.ts index 7cabc097..5d7a5171 100644 --- a/src/icons.ts +++ b/src/icons.ts @@ -1,5 +1,6 @@ import { RANK } from "./utils.ts"; import { Theme } from "./theme.ts"; +import trophyStyles from "./TrophyStyles/index.ts"; const leafIcon = (laurel: string): string => { return ` @@ -88,7 +89,7 @@ const getSmallTrophyIcon = ( // Single Rank return ""; }; -export const getTrophyIcon = (theme: Theme, rank = RANK.UNKNOWN) => { +export const getTrophyIcon = (theme: Theme, rank = RANK.UNKNOWN, trophyStyle: string | null = null) => { let color = theme.DEFAULT_RANK_BASE; let rankColor = theme.DEFAULT_RANK_TEXT; let backgroundIcon = ""; @@ -138,21 +139,29 @@ export const getTrophyIcon = (theme: Theme, rank = RANK.UNKNOWN) => { - ${ - rank.slice(0, 1) - } + ${rank.slice(0, 1) + } `; const optionRankIcon = getSmallTrophyIcon(icon, color, rank.length - 1); return ` - ${backgroundIcon} - ${optionRankIcon} - - - ${gradationColor} - - - - ${icon} - + ${trophyStyle ? + // custom trophy style + ` + ${trophyStyles[trophyStyle][rank]} + ` + : + // default trophy style + ` + ${backgroundIcon} + ${optionRankIcon} + + + ${gradationColor} + + + + ${icon} + + `} `; }; diff --git a/src/trophy.ts b/src/trophy.ts index f81cdc78..14cfbdca 100644 --- a/src/trophy.ts +++ b/src/trophy.ts @@ -65,6 +65,7 @@ export class Trophy { panelSize = CONSTANTS.DEFAULT_PANEL_SIZE, noBackground = CONSTANTS.DEFAULT_NO_BACKGROUND, noFrame = CONSTANTS.DEFAULT_NO_FRAME, + trophyStyle: string | null = null, ): string { const { BACKGROUND: PRIMARY, TITLE: SECONDARY, TEXT, NEXT_RANK_BAR } = theme; @@ -94,7 +95,7 @@ export class Trophy { stroke-opacity="${noFrame ? "0" : "1"}" fill-opacity="${noBackground ? "0" : "1"}" /> - ${getTrophyIcon(theme, this.rank)} + ${getTrophyIcon(theme, this.rank, trophyStyle)} ${this.title} ${this.topMessage} ${this.bottomMessage}