Add joined2020 trophy

This commit is contained in:
ryo-ma 2020-09-12 01:53:04 +09:00
parent a6aac67444
commit d89b242989
3 changed files with 23 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import {
MultipleLangTrophy,
LongTimeAccountTrophy,
AncientAccountTrophy,
Joined2020Trophy,
} from "./trophies.ts";
import { UserInfo } from "./github_api_client.ts";
import { RANK_ORDER, RANK } from "./utils.ts";
@ -42,6 +43,7 @@ export class Card {
new MultipleLangTrophy(userInfo.languageCount),
new LongTimeAccountTrophy(userInfo.durationYear),
new AncientAccountTrophy(userInfo.acientAccount),
new Joined2020Trophy(userInfo.joined2020),
);
// Filter by hidden

View file

@ -10,6 +10,7 @@ export class UserInfo {
public languageCount: number,
public durationYear: number,
public acientAccount: number,
public joined2020: number,
) {
}
}
@ -94,6 +95,9 @@ export class GithubAPIClient {
const acientAccount = new Date(userData.createdAt).getFullYear() <= 2010
? 1
: 0;
const joined2020 = new Date(userData.createdAt).getFullYear() == 2020
? 1
: 0;
const userInfo = new UserInfo(
totalCommits,
userData.followers.totalCount,
@ -104,6 +108,7 @@ export class GithubAPIClient {
languages.size,
durationYear,
acientAccount,
joined2020
);
return userInfo;
}

View file

@ -116,6 +116,22 @@ export class MultipleLangTrophy extends Trophy{
}
}
export class Joined2020Trophy extends Trophy{
constructor(score: number){
const rankConditions = [
new RankCondition(
RANK.SECRET,
"Everything started...",
1,
),
];
super(score, rankConditions);
this.title = "Joined2020";
this.filterTitles = ["Joined2020"];
this.bottomMessage = "Joined 2020"
this.hidden = true;
}
}
export class AncientAccountTrophy extends Trophy{
constructor(score: number){
const rankConditions = [