mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Update commnet
This commit is contained in:
parent
0fdc4b7434
commit
f6347f3d95
1 changed files with 10 additions and 4 deletions
|
|
@ -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,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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue