From d89b24298941417da793d70e11f16a9571ed01a4 Mon Sep 17 00:00:00 2001 From: ryo-ma Date: Sat, 12 Sep 2020 01:53:04 +0900 Subject: [PATCH] Add joined2020 trophy --- src/card.ts | 2 ++ src/github_api_client.ts | 5 +++++ src/trophies.ts | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/card.ts b/src/card.ts index e7a225e..1227930 100644 --- a/src/card.ts +++ b/src/card.ts @@ -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 diff --git a/src/github_api_client.ts b/src/github_api_client.ts index 6ae538f..7cde852 100644 --- a/src/github_api_client.ts +++ b/src/github_api_client.ts @@ -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; } diff --git a/src/trophies.ts b/src/trophies.ts index ab969ef..04d05c6 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -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 = [