From 1a0de058bb81bc11e0ef45ad7e1ec7c68b934b45 Mon Sep 17 00:00:00 2001 From: ryo-ma Date: Sun, 6 Sep 2020 02:10:13 +0900 Subject: [PATCH] Fix trophy title name --- src/card.ts | 17 +++++++++++------ src/trophies.ts | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/card.ts b/src/card.ts index e9d266f..5ee84fe 100644 --- a/src/card.ts +++ b/src/card.ts @@ -8,8 +8,7 @@ import { TotalRepositoryTrophy, MultipleLangTrophy, LongTimeAccountTrophy, - AncientAccountTrophy - + AncientAccountTrophy, } from "./trophies.ts"; import { UserInfo } from "./github_api_client.ts"; import { CONSTANTS, RANK_ORDER, RANK } from "./utils.ts"; @@ -24,7 +23,7 @@ export class Card { private maxRow: number, private panelSize: number, private paddingWidth: number, - private paddingHight: number + private paddingHight: number, ) { this.width = panelSize * this.maxColumn; } @@ -42,16 +41,22 @@ export class Card { ); // Filter by hidden - trophyList = trophyList.filter((trophy) => !trophy.hidden || trophy.rank !== RANK.UNKNOWN); + trophyList = trophyList.filter((trophy) => + !trophy.hidden || trophy.rank !== RANK.UNKNOWN + ); // Filter by titles if (this.titles.length != 0) { - trophyList = trophyList.filter((trophy) => this.titles.includes(trophy.title)) + trophyList = trophyList.filter((trophy) => { + return trophy.filterTitles.some((title) => this.titles.includes(title)) + }); } // Filter by ranks if (this.ranks.length != 0) { - trophyList = trophyList.filter((trophy) => this.ranks.includes(trophy.rank)) + trophyList = trophyList.filter((trophy) => + this.ranks.includes(trophy.rank) + ); } // Sort by rank diff --git a/src/trophies.ts b/src/trophies.ts index 28ec4bf..446544c 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -16,6 +16,7 @@ export class Trophy { topMessage = "Unknown"; bottomMessage = "0"; title = ""; + filterTitles: Array = []; hidden = false; constructor( private score: number, @@ -102,7 +103,8 @@ export class MultipleLangTrophy extends Trophy{ ), ]; super(score, rankConditions); - this.title = "MultipleLang"; + this.title = "MultiLanguage"; + this.filterTitles = ["MultipleLang", "MultiLanguage"]; this.hidden = true; } } @@ -118,6 +120,7 @@ export class AncientAccountTrophy extends Trophy{ ]; super(score, rankConditions); this.title = "AncientUser"; + this.filterTitles = ["AncientUser"]; this.bottomMessage = "Before 2010" this.hidden = true; } @@ -133,6 +136,7 @@ export class LongTimeAccountTrophy extends Trophy{ ]; super(score, rankConditions); this.title = "LongTimeUser"; + this.filterTitles = ["LongTimeUser"]; this.hidden = true; } } @@ -182,7 +186,8 @@ export class TotalStarTrophy extends Trophy { ), ]; super(score, rankConditions); - this.title = "Star"; + this.title = "Stars"; + this.filterTitles = ["Star", "Stars"]; } } @@ -232,6 +237,7 @@ export class TotalCommitTrophy extends Trophy { ]; super(score, rankConditions); this.title = "Commit"; + this.filterTitles = ["Commit"]; } } @@ -280,7 +286,8 @@ export class TotalFollowerTrophy extends Trophy { ), ]; super(score, rankConditions); - this.title = "Follower"; + this.title = "Followers"; + this.filterTitles = ["Follower", "Followers"]; } } @@ -329,7 +336,8 @@ export class TotalIssueTrophy extends Trophy { ), ]; super(score, rankConditions); - this.title = "Issue"; + this.title = "Issues"; + this.filterTitles = ["Issue", "Issues"]; } } @@ -378,7 +386,8 @@ export class TotalPullRequestTrophy extends Trophy { ), ]; super(score, rankConditions); - this.title = "PR"; + this.title = "PullRequest"; + this.filterTitles = ["PR", "PullRequest"]; } } @@ -427,6 +436,7 @@ export class TotalRepositoryTrophy extends Trophy { ), ]; super(score, rankConditions); - this.title = "Repo"; + this.title = "Repositories"; + this.filterTitles = ["Repo", "Repository", "Repositories"]; } }