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";
bottomMessage = "0";
title = "";
constructor(private score: number, private rankConditions: Array<RankCondition>) {
constructor(
private score: number,
private rankConditions: Array<RankCondition>,
) {
this.bottomMessage = abridgeScore(score);
this.setRank();
}
@ -22,7 +25,10 @@ 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))
// 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;