mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
Merge pull request #11 from tresabhi/1.8.1
This commit is contained in:
4 files changed
+6
-18
No files matched your search
@@ -11,7 +11,7 @@ import { StatType } from '../renderers/stats.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatsSubCommandGroups(
|
||||
|
||||
@@ -6,15 +6,6 @@ import { PERIOD_NAMES } from './resolvePeriod.js';
|
||||
|
||||
export type Period = 'today' | '30' | '60' | '90' | 'career' | 'custom';
|
||||
|
||||
export const RELATIVE_PERIOD_NAMES: Record<Period, string> = {
|
||||
today: 'A day ago',
|
||||
30: '30 days ago',
|
||||
60: '60 days ago',
|
||||
90: '90 days ago',
|
||||
career: 'Extent of data',
|
||||
custom: 'Custom period',
|
||||
};
|
||||
|
||||
export default function addPeriodSubCommands(
|
||||
option: SlashCommandSubcommandGroupBuilder,
|
||||
extra: (
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import getPeriodNow from '../blitzstars/getPeriodNow.js';
|
||||
import getPeriodStart from '../blitzstars/getPeriodStart.js';
|
||||
import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo.js';
|
||||
import { Period, RELATIVE_PERIOD_NAMES } from './addPeriodSubCommands.js';
|
||||
import { Period } from './addPeriodSubCommands.js';
|
||||
|
||||
export const PERIOD_NAMES: Record<Period, string> = {
|
||||
today: "Today's statistics",
|
||||
@@ -23,7 +23,6 @@ export const EVOLUTION_PERIOD_NAMES: Record<Period, string> = {
|
||||
};
|
||||
|
||||
export interface ResolvedPeriod {
|
||||
relativePeriodName: string;
|
||||
statsName: string;
|
||||
evolutionName: string;
|
||||
start: number;
|
||||
@@ -38,8 +37,6 @@ export default function resolvePeriod(
|
||||
let evolutionName: string;
|
||||
let start: number;
|
||||
let end: number;
|
||||
const relativePeriodName =
|
||||
RELATIVE_PERIOD_NAMES[interaction.options.getSubcommand() as Period];
|
||||
|
||||
if (period === 'custom') {
|
||||
const startRaw = interaction.options.getInteger('start')!;
|
||||
@@ -63,6 +60,5 @@ export default function resolvePeriod(
|
||||
evolutionName,
|
||||
start,
|
||||
end,
|
||||
relativePeriodName,
|
||||
} satisfies ResolvedPeriod;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import { StatType } from './stats.js';
|
||||
|
||||
export default async function evolution<Type extends StatType>(
|
||||
type: Type,
|
||||
{ start, end, evolutionName, relativePeriodName }: ResolvedPeriod,
|
||||
{ start, end, evolutionName }: ResolvedPeriod,
|
||||
{ server, id }: ResolvedPlayer,
|
||||
tankId: Type extends 'tank' ? number : never,
|
||||
) {
|
||||
@@ -78,6 +78,7 @@ export default async function evolution<Type extends StatType>(
|
||||
const battleYs = careerBattles.map(([, y]) => y);
|
||||
const maxBattle = Math.max(...battleYs);
|
||||
const minBattle = Math.min(...battleYs);
|
||||
const minTime = Math.min(...careerBattles.map(([x]) => x));
|
||||
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
@@ -97,8 +98,8 @@ export default async function evolution<Type extends StatType>(
|
||||
{/* goofy ahh bug forces me to call them as functions */}
|
||||
{careerWinrate.length > 0 && (
|
||||
<Graph.Root
|
||||
xMinLabel={relativePeriodName}
|
||||
xMaxLabel="Latest recorded battle" // TODO: this is not true in custom periods
|
||||
xMinLabel={new Date(minTime * 1000).toDateString()}
|
||||
xMaxLabel={new Date(end * 1000).toDateString()}
|
||||
leftVerticalMargin={{
|
||||
min: minWinrate,
|
||||
max: maxWinrate,
|
||||
|
||||
Reference in new issue
Block a user