Fix abridgeScore logic

This commit is contained in:
ryo-ma 2020-08-24 23:54:31 +09:00
parent df90cfb52b
commit 6721eb28d6
2 changed files with 4 additions and 1 deletions

View file

@ -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 {

View file

@ -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+"