Add all s rank trophy

This commit is contained in:
ryo-ma 2020-09-12 02:09:16 +09:00
parent d89b242989
commit 3ceb08fce5
2 changed files with 25 additions and 1 deletions

View file

@ -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<Trophy>(
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));
});
}

View file

@ -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 = [