From b1babb507c0e6551ad992e5af6f41d1fd4b8d6f0 Mon Sep 17 00:00:00 2001 From: ryo-ma Date: Fri, 28 Aug 2020 02:18:29 +0900 Subject: [PATCH] Add SECRET RANK --- src/trophies.ts | 21 ++++++++++++++++++++- src/utils.ts | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/trophies.ts b/src/trophies.ts index 3a80ed4..6f2cbb6 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -9,12 +9,14 @@ class RankCondition { ) {} } + export class Trophy { rankCondition: RankCondition | null = null; rank: RANK = RANK.UNKNOWN; topMessage = "Unknown"; bottomMessage = "0"; title = ""; + hidden = false; constructor( private score: number, private rankConditions: Array, @@ -38,7 +40,8 @@ export class Trophy { } private calculateNextRankPercentage() { const nextRankIndex = RANK_ORDER.indexOf(this.rank) - 1; - if (nextRankIndex < 0) { + // When got the max rank + if (nextRankIndex < 0 || this.rank === RANK.SSS) { return 1; } const nextRank = RANK_ORDER[nextRankIndex]; @@ -87,6 +90,22 @@ export class Trophy { } } +export class MultipleLangTrophy extends Trophy{ + constructor(score: number){ + const rankConditions = [ + new RankCondition( + RANK.SECRET, + "Rainbow Lang User", + 7, + ), + ]; + super(score, rankConditions); + this.title = "MultipleLang"; + this.hidden = true; + } + +} + export class TotalStarTrophy extends Trophy { constructor(score: number) { const rankConditions = [ diff --git a/src/utils.ts b/src/utils.ts index 5c0721b..2e96ae7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -28,6 +28,7 @@ export const CONSTANTS = { }; export enum RANK { + SECRET = "SECRET", SSS = "SSS", SS = "SS", S = "S", @@ -40,4 +41,4 @@ export enum RANK { } -export const RANK_ORDER= Object.values(RANK); \ No newline at end of file +export const RANK_ORDER= Object.values(RANK);