mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: types
This commit is contained in:
1 parent
71481f5971
commit
cb101da8a8
5 files changed
+24
-53
No files matched your search
@@ -45,7 +45,7 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
const clanImage = clan ? emblemURL(clan.emblem_set_id) : undefined;
|
||||
const leaderboard = await getArchivedRatingLeaderboard(region, 53);
|
||||
|
||||
if (leaderboard.format === BkrlFormat.Minimal) {
|
||||
if (leaderboard.format === BkrlFormat.Base) {
|
||||
throw new Error(
|
||||
'Encountered bkrl minimal format in latest season. Wait till next cron?',
|
||||
);
|
||||
@@ -412,7 +412,7 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{Math.round(delta.damageDealt / delta.battles).toLocaleString(
|
||||
{Math.round(delta.damage / delta.battles).toLocaleString(
|
||||
interaction.locale,
|
||||
)}
|
||||
</span>
|
||||
|
||||
@@ -9,11 +9,8 @@ export function deltaBkrlBlitzStats(
|
||||
) {
|
||||
return {
|
||||
battles: b1.battles - a.battles,
|
||||
damageDealt: b1.damage_dealt - a.damageDealt,
|
||||
damageReceived: b1.damage_received - a.damageReceived,
|
||||
hits: b1.hits - a.hits,
|
||||
damage: b1.damage_dealt - a.damage,
|
||||
kills: b1.frags - a.kills,
|
||||
shots: b1.shots - a.shots,
|
||||
survived: b1.survived_battles - a.survived,
|
||||
wins: b1.wins - a.wins,
|
||||
score: b2.score - a.score,
|
||||
|
||||
+11
-26
@@ -2,11 +2,11 @@ import { times } from 'lodash';
|
||||
import { ReadStream, WriteStream } from './buffer';
|
||||
|
||||
export enum BkrlFormat {
|
||||
Minimal,
|
||||
Base,
|
||||
Superset1,
|
||||
}
|
||||
|
||||
export interface BkrlMinimalEntry {
|
||||
export interface BkrlBaseEntry {
|
||||
id: number;
|
||||
score: number;
|
||||
}
|
||||
@@ -19,19 +19,14 @@ export interface BkrlSuperset1Entry {
|
||||
wins: number;
|
||||
survived: number;
|
||||
|
||||
damageDealt: number;
|
||||
damageReceived: number;
|
||||
|
||||
shots: number;
|
||||
hits: number;
|
||||
|
||||
damage: number;
|
||||
kills: number;
|
||||
}
|
||||
|
||||
export type BkrlDiscriminatedEntries =
|
||||
| {
|
||||
format: BkrlFormat.Minimal;
|
||||
entries: BkrlMinimalEntry[];
|
||||
format: BkrlFormat.Base;
|
||||
entries: BkrlBaseEntry[];
|
||||
}
|
||||
| {
|
||||
format: BkrlFormat.Superset1;
|
||||
@@ -47,16 +42,16 @@ export class BkrlReadStream extends ReadStream {
|
||||
|
||||
body(header: ReturnType<typeof this.header>): BkrlDiscriminatedEntries {
|
||||
switch (header.format) {
|
||||
case BkrlFormat.Minimal: {
|
||||
case BkrlFormat.Base: {
|
||||
return {
|
||||
format: BkrlFormat.Minimal,
|
||||
format: BkrlFormat.Base,
|
||||
entries: times(
|
||||
header.count,
|
||||
() =>
|
||||
({
|
||||
id: this.uint32(),
|
||||
score: this.uint16(),
|
||||
}) satisfies BkrlMinimalEntry,
|
||||
}) satisfies BkrlBaseEntry,
|
||||
),
|
||||
};
|
||||
}
|
||||
@@ -75,12 +70,7 @@ export class BkrlReadStream extends ReadStream {
|
||||
wins: this.uint32(),
|
||||
survived: this.uint32(),
|
||||
|
||||
damageDealt: this.uint32(),
|
||||
damageReceived: this.uint32(),
|
||||
|
||||
shots: this.uint32(),
|
||||
hits: this.uint32(),
|
||||
|
||||
damage: this.uint32(),
|
||||
kills: this.uint32(),
|
||||
}) satisfies BkrlSuperset1Entry,
|
||||
),
|
||||
@@ -115,7 +105,7 @@ export class BkrlWriteStream extends WriteStream {
|
||||
|
||||
body(discriminatedEntries: BkrlDiscriminatedEntries) {
|
||||
switch (discriminatedEntries.format) {
|
||||
case BkrlFormat.Minimal: {
|
||||
case BkrlFormat.Base: {
|
||||
discriminatedEntries.entries.forEach((entry) => {
|
||||
this.uint32(entry.id);
|
||||
this.uint16(entry.score);
|
||||
@@ -132,12 +122,7 @@ export class BkrlWriteStream extends WriteStream {
|
||||
this.uint32(entry.wins);
|
||||
this.uint32(entry.survived);
|
||||
|
||||
this.uint32(entry.damageDealt);
|
||||
this.uint32(entry.damageReceived);
|
||||
|
||||
this.uint32(entry.shots);
|
||||
this.uint32(entry.hits);
|
||||
|
||||
this.uint32(entry.damage);
|
||||
this.uint32(entry.kills);
|
||||
});
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user