mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: evolution command for tanks
This commit is contained in:
1 parent
35f0f614af
commit
70145abe86
18 files changed
+633
-90
No files matched your search
@@ -1,15 +1,9 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { AllStats } from '../../types/accountInfo.js';
|
||||
import getTankStats from '../blitz/getTankStats.js';
|
||||
|
||||
export interface TankHistoryNode {
|
||||
all: AllStats;
|
||||
last_battle_time: number;
|
||||
mark_of_mastery: number;
|
||||
battle_life_time: number;
|
||||
account_id: number;
|
||||
tank_id: number;
|
||||
}
|
||||
import getTankHistories, {
|
||||
TankHistories,
|
||||
TankHistory,
|
||||
} from './getTankHistories.js';
|
||||
|
||||
export const emptyAllStats: AllStats = {
|
||||
battles: 0,
|
||||
@@ -31,7 +25,7 @@ export const emptyAllStats: AllStats = {
|
||||
wins: 0,
|
||||
};
|
||||
|
||||
export const emptyTankHistoryNode: TankHistoryNode = {
|
||||
export const emptyTankHistoryNode: TankHistory = {
|
||||
account_id: 0,
|
||||
battle_life_time: 0,
|
||||
last_battle_time: 0,
|
||||
@@ -40,23 +34,18 @@ export const emptyTankHistoryNode: TankHistoryNode = {
|
||||
all: emptyAllStats,
|
||||
};
|
||||
|
||||
export type TankHistory = TankHistoryNode[];
|
||||
|
||||
export default async function getTankStatsOverTime(
|
||||
server: BlitzServer,
|
||||
id: number,
|
||||
start: number,
|
||||
end: number,
|
||||
) {
|
||||
const latestTankStatsRaw = await getTankStats(server, id);
|
||||
const tankHistoriesResponse = await fetch(
|
||||
`https://www.blitzstars.com/api/tankhistories/for/${id}/`,
|
||||
);
|
||||
const tankHistories = (await tankHistoriesResponse.json()) as TankHistory;
|
||||
const history = [...tankHistories, ...latestTankStatsRaw];
|
||||
const history = await getTankHistories(server, id, {
|
||||
includeLatestHistories: true,
|
||||
});
|
||||
|
||||
// sort them even though most won't be used
|
||||
const tankSortedHistory: Record<number, TankHistory> = {};
|
||||
const tankSortedHistory: Record<number, TankHistories> = {};
|
||||
const tankIds: number[] = [];
|
||||
history.forEach((node) => {
|
||||
if (!tankSortedHistory[node.tank_id]) {
|
||||
|
||||
Reference in new issue
Block a user