Update commnet

This commit is contained in:
ryo-ma 2020-08-26 01:49:49 +09:00
parent 0fdc4b7434
commit f6347f3d95

View file

@ -14,7 +14,10 @@ export class Trophy {
topMessage = "Unknown"; topMessage = "Unknown";
bottomMessage = "0"; bottomMessage = "0";
title = ""; title = "";
constructor(private score: number, private rankConditions: Array<RankCondition>) { constructor(
private score: number,
private rankConditions: Array<RankCondition>,
) {
this.bottomMessage = abridgeScore(score); this.bottomMessage = abridgeScore(score);
this.setRank(); this.setRank();
} }
@ -22,10 +25,13 @@ export class Trophy {
const sortedRankConditions = this.rankConditions.sort((a, b) => const sortedRankConditions = this.rankConditions.sort((a, b) =>
RANK_ORDER.indexOf(a.rank) - RANK_ORDER.indexOf(b.rank) RANK_ORDER.indexOf(a.rank) - RANK_ORDER.indexOf(b.rank)
); );
const rankCondition = sortedRankConditions.find(r => r.condition(this.score)) // Set the rank that hit the first condition
if (rankCondition != null){ const rankCondition = sortedRankConditions.find((r) =>
r.condition(this.score)
);
if (rankCondition != null) {
this.rank = rankCondition.rank; this.rank = rankCondition.rank;
this.topMessage= rankCondition.message; this.topMessage = rankCondition.message;
} }
} }
render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string { render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string {