From f6347f3d958da942a5261b954bf8877e77f261d1 Mon Sep 17 00:00:00 2001 From: ryo-ma Date: Wed, 26 Aug 2020 01:49:49 +0900 Subject: [PATCH] Update commnet --- src/trophies.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/trophies.ts b/src/trophies.ts index cd810f1..5b592ac 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -14,7 +14,10 @@ export class Trophy { topMessage = "Unknown"; bottomMessage = "0"; title = ""; - constructor(private score: number, private rankConditions: Array) { + constructor( + private score: number, + private rankConditions: Array, + ) { this.bottomMessage = abridgeScore(score); this.setRank(); } @@ -22,10 +25,13 @@ export class Trophy { const sortedRankConditions = this.rankConditions.sort((a, b) => RANK_ORDER.indexOf(a.rank) - RANK_ORDER.indexOf(b.rank) ); - const rankCondition = sortedRankConditions.find(r => r.condition(this.score)) - if (rankCondition != null){ + // Set the rank that hit the first condition + const rankCondition = sortedRankConditions.find((r) => + r.condition(this.score) + ); + if (rankCondition != null) { this.rank = rankCondition.rank; - this.topMessage= rankCondition.message; + this.topMessage = rankCondition.message; } } render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string {