diff --git a/src/card.ts b/src/card.ts index 1227930..df9fe2f 100644 --- a/src/card.ts +++ b/src/card.ts @@ -10,6 +10,7 @@ import { LongTimeAccountTrophy, AncientAccountTrophy, Joined2020Trophy, + AllSuperRankTrophy, } from "./trophies.ts"; import { UserInfo } from "./github_api_client.ts"; import { RANK_ORDER, RANK } from "./utils.ts"; @@ -33,6 +34,7 @@ export class Card { userInfo: UserInfo, theme: Theme, ): string { + // Base trophies let trophyList = new Array( new TotalStarTrophy(userInfo.totalStargazers), new TotalCommitTrophy(userInfo.totalCommits), @@ -40,10 +42,16 @@ export class Card { new TotalIssueTrophy(userInfo.totalIssues), new TotalPullRequestTrophy(userInfo.totalPullRequests), new TotalRepositoryTrophy(userInfo.totalRepositories), + ); + const isAllSRank = + trophyList.every((trophy) => trophy.rank.slice(0, 1) == RANK.S) ? 1 : 0; + // Secret trophies + trophyList.push( new MultipleLangTrophy(userInfo.languageCount), new LongTimeAccountTrophy(userInfo.durationYear), new AncientAccountTrophy(userInfo.acientAccount), new Joined2020Trophy(userInfo.joined2020), + new AllSuperRankTrophy(isAllSRank), ); // Filter by hidden @@ -54,7 +62,7 @@ export class Card { // Filter by titles if (this.titles.length != 0) { trophyList = trophyList.filter((trophy) => { - return trophy.filterTitles.some((title) => this.titles.includes(title)) + return trophy.filterTitles.some((title) => this.titles.includes(title)); }); } diff --git a/src/trophies.ts b/src/trophies.ts index 04d05c6..5a20a46 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -116,6 +116,22 @@ export class MultipleLangTrophy extends Trophy{ } } +export class AllSuperRankTrophy extends Trophy{ + constructor(score: number){ + const rankConditions = [ + new RankCondition( + RANK.SECRET, + "S Rank Hacker", + 1, + ), + ]; + super(score, rankConditions); + this.title = "AllSuperRank"; + this.filterTitles = ["AllSuperRank"]; + this.bottomMessage = "All S Rank" + this.hidden = true; + } +} export class Joined2020Trophy extends Trophy{ constructor(score: number){ const rankConditions = [