mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Fix abridgeScore logic
This commit is contained in:
parent
df90cfb52b
commit
6721eb28d6
2 changed files with 4 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ import { CONSTANTS, RANK, abridgeScore } from "./utils.ts";
|
||||||
export abstract class Trophy {
|
export abstract class Trophy {
|
||||||
rank: RANK = RANK.UNKNOWN;
|
rank: RANK = RANK.UNKNOWN;
|
||||||
topMessage = "Unknown";
|
topMessage = "Unknown";
|
||||||
bottomMessage = "+0";
|
bottomMessage = "0";
|
||||||
title = "";
|
title = "";
|
||||||
abstract setRank(): void;
|
abstract setRank(): void;
|
||||||
render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string {
|
render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ export function abridgeScore(score: number): string {
|
||||||
if (score < 1) {
|
if (score < 1) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
if (score < 10) {
|
||||||
|
return score.toString() + "+"
|
||||||
|
}
|
||||||
if (Math.abs(score) > 999){
|
if (Math.abs(score) > 999){
|
||||||
return (Math.sign(score) * (Math.abs(score) / 1000)).toFixed(1) + "k+"
|
return (Math.sign(score) * (Math.abs(score) / 1000)).toFixed(1) + "k+"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue