diff --git a/src/icons.ts b/src/icons.ts index 92706d1..8149f02 100644 --- a/src/icons.ts +++ b/src/icons.ts @@ -26,46 +26,52 @@ Created by potrace 1.15, written by Peter Selinger 2001-2017 `; -function getPlusIcon(color: string): string { - return ` - - - + - -`; + +function getSmallTropyIcon(icon: string, color: string, count: number): string { + const leftXPosition = 2; + const rightXPosition = 73; + const getIcon = (x: number) => { + return ` + ${icon} + ` + }; + if (count == 1) { + // Double Rank + return getIcon(rightXPosition); + } else if (count == 2){ + // Triple Rank + return `${getIcon(leftXPosition)}${getIcon(rightXPosition)}` + } + // Single Rank + return '' + } export function getTropyIcon(rank = RANK.UNKNOWN) { - let color = "currentColor"; - let backgroundIcon = ""; - let optionRankIcon = ""; - if (rank == RANK.SP) { - color = goldColor; - backgroundIcon = leafIcon; - optionRankIcon = getPlusIcon(color); - } else if (rank == RANK.S) { - color = goldColor; - backgroundIcon = leafIcon; - } else if (rank == RANK.AP) { - color = silverColor; - backgroundIcon = leafIcon; - optionRankIcon = getPlusIcon(color); - } else if (rank == RANK.A) { - color = silverColor; - backgroundIcon = leafIcon; - } else if (rank == RANK.B) { - color = bronzeColor; - } - return ` - ${backgroundIcon} - ${optionRankIcon} - + const icon = ` - ${ - rank.replace("+", "") - } + ${rank.slice(0, 1)} + `; + + let color = "currentColor"; + let backgroundIcon = ""; + if (rank.slice(0, 1) === RANK.S) { + color = goldColor; + backgroundIcon = leafIcon; + } else if (rank.slice(0, 1) === RANK.A) { + color = silverColor; + backgroundIcon = leafIcon; + } else if (rank === RANK.B) { + color = bronzeColor; + } + const optionRankIcon = getSmallTropyIcon(icon, color, rank.length - 1); + return ` + ${backgroundIcon} + ${optionRankIcon} + + ${icon} `; } diff --git a/src/trophies.ts b/src/trophies.ts index 52e6476..a5062e3 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -6,6 +6,9 @@ export abstract class Trophy { topMessage = "Unknown"; bottomMessage = "0"; title = ""; + constructor(score: number) { + this.bottomMessage = abridgeScore(score); + } abstract setRank(): void; render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string { return ` @@ -39,12 +42,11 @@ export abstract class Trophy { export class TotalStarTrophy extends Trophy { constructor(private score: number) { - super(); + super(score); this.title = "Star"; this.setRank(); } setRank() { - this.bottomMessage = abridgeScore(this.score); if (this.score >= 200) { this.rank = RANK.S; this.topMessage = "Super Star"; @@ -63,16 +65,21 @@ export class TotalStarTrophy extends Trophy { export class TotalCommitTrophy extends Trophy { constructor(private score: number) { - super(); + super(score); this.title = "Commit"; this.setRank(); } setRank() { - this.bottomMessage = abridgeScore(this.score); if (this.score >= 1000) { this.rank = RANK.S; this.topMessage = "Super Commiter"; } else if (this.score >= 500) { + this.rank = RANK.AAA; + this.topMessage = "High Commiter"; + } else if (this.score >= 300) { + this.rank = RANK.AA; + this.topMessage = "High Commiter"; + } else if (this.score >= 200) { this.rank = RANK.A; this.topMessage = "High Commiter"; } else if (this.score >= 100) { @@ -87,12 +94,11 @@ export class TotalCommitTrophy extends Trophy { export class TotalFollowerTrophy extends Trophy { constructor(private score: number) { - super(); + super(score); this.title = "Follower"; this.setRank(); } setRank() { - this.bottomMessage = abridgeScore(this.score); if (this.score >= 100) { this.rank = RANK.S; this.topMessage = "Celebrity"; @@ -110,20 +116,19 @@ export class TotalFollowerTrophy extends Trophy { } export class TotalIssueTrophy extends Trophy { constructor(private score: number) { - super(); + super(score); this.title = "Issue"; this.setRank(); } setRank() { - this.bottomMessage = abridgeScore(this.score); if(this.score >= 300) { - this.rank = RANK.SP; + this.rank = RANK.SS; this.topMessage = "Deep Issuer"; } else if (this.score >= 100) { this.rank = RANK.S; this.topMessage = "Super Issuer"; } else if (this.score >= 50) { - this.rank = RANK.AP; + this.rank = RANK.AA; this.topMessage = "Heavy Issuer"; } else if (this.score >= 20) { this.rank = RANK.A; @@ -140,17 +145,16 @@ export class TotalIssueTrophy extends Trophy { export class TotalPullRequestTrophy extends Trophy { constructor(private score: number) { - super(); + super(score); this.title = "PR"; this.setRank(); } setRank() { - this.bottomMessage = abridgeScore(this.score); if (this.score >= 100) { this.rank = RANK.S; this.topMessage = "God PR User"; } else if (this.score >= 50) { - this.rank = RANK.AP; + this.rank = RANK.AA; this.topMessage = "Heavy PR User"; } else if (this.score >= 20) { this.rank = RANK.A; @@ -167,15 +171,20 @@ export class TotalPullRequestTrophy extends Trophy { export class TotalRepositoryTrophy extends Trophy { constructor(private score: number) { - super(); + super(score); this.title = "Repo"; this.setRank(); } setRank() { - this.bottomMessage = abridgeScore(this.score); if (this.score >= 100) { this.rank = RANK.S; this.topMessage = "God Repo Creator"; + } else if (this.score >= 50) { + this.rank = RANK.AAA; + this.topMessage = "High Repo Creator"; + } else if (this.score >= 40) { + this.rank = RANK.AA; + this.topMessage = "High Repo Creator"; } else if (this.score >= 20) { this.rank = RANK.A; this.topMessage = "High Repo Creator"; diff --git a/src/utils.ts b/src/utils.ts index 1ae8bb0..f7437b5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -31,9 +31,11 @@ export const CONSTANTS = { }; export enum RANK { - SP = "S+", + SSS = "SSS", + SS = "SS", S = "S", - AP = "A+", + AAA = "AAA", + AA = "AA", A = "A", B = "B", C = "C",