mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
fix: some linting for new proto 5
This commit is contained in:
1 parent
53a9c5f2de
commit
96310a9d63
40 files changed
+409
-367
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { type ShellDefinition, ShellType } from '@blitzkit/core';
|
||||
|
||||
export function canSplash(type: ShellDefinition['type']): type is ShellType.HE {
|
||||
return type === ShellType.SHELL_TYPE_HE;
|
||||
return type === ShellType.HE;
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
import { Vector3Tuple } from 'three';
|
||||
import { Tier } from '../blitzkit';
|
||||
import { Tier } from '../protos';
|
||||
|
||||
export const equipmentPriceMatrix: Record<Tier, Vector3Tuple> = {
|
||||
1: [100, 200, 300],
|
||||
2: [200, 300, 400],
|
||||
3: [400, 500, 600],
|
||||
4: [4000, 5000, 6000],
|
||||
5: [40_000, 50_000, 60_000],
|
||||
6: [100_000, 120_000, 140_000],
|
||||
7: [150_000, 170_000, 190_000],
|
||||
8: [200_000, 225_000, 250_000],
|
||||
9: [250_000, 275_000, 300_000],
|
||||
10: [300_000, 350_000, 400_000],
|
||||
[Tier.I]: [100, 200, 300],
|
||||
[Tier.II]: [200, 300, 400],
|
||||
[Tier.III]: [400, 500, 600],
|
||||
[Tier.IV]: [4000, 5000, 6000],
|
||||
[Tier.V]: [40_000, 50_000, 60_000],
|
||||
[Tier.VI]: [100_000, 120_000, 140_000],
|
||||
[Tier.VII]: [150_000, 170_000, 190_000],
|
||||
[Tier.VIII]: [200_000, 225_000, 250_000],
|
||||
[Tier.IX]: [250_000, 275_000, 300_000],
|
||||
[Tier.X]: [300_000, 350_000, 400_000],
|
||||
[Tier.UNRECOGNIZED]: [0, 0, 0],
|
||||
};
|
||||
@@ -1,6 +1,9 @@
|
||||
import { ProvisionDefinitions } from '@blitzkit/core';
|
||||
import {
|
||||
GunDefinition,
|
||||
ProvisionDefinitions,
|
||||
TankDefinition,
|
||||
} from '@blitzkit/core';
|
||||
import { checkConsumableProvisionInclusivity } from './checkConsumableProvisionInclusivity';
|
||||
import { GunDefinition, TankDefinition } from './tankDefinitions';
|
||||
|
||||
export function availableProvisions(
|
||||
tank: TankDefinition,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Samples } from '.';
|
||||
import { emptyAllStats } from '../../blitz/constants';
|
||||
import { Samples } from '../../protos';
|
||||
import { BlitzkitStats } from '../../statistics';
|
||||
|
||||
export const emptyAverageDefinitionsAllStats: BlitzkitStats = {
|
||||
@@ -12,11 +12,11 @@ export const averageDefinitionsAllStatsKeys = Object.keys(
|
||||
) as (keyof BlitzkitStats)[];
|
||||
|
||||
export const emptySamples: Samples = {
|
||||
d_1: 0,
|
||||
d_7: 0,
|
||||
d_30: 0,
|
||||
d_60: 0,
|
||||
d_90: 0,
|
||||
d_120: 0,
|
||||
d1: 0,
|
||||
d7: 0,
|
||||
d30: 0,
|
||||
d60: 0,
|
||||
d90: 0,
|
||||
d120: 0,
|
||||
total: 0,
|
||||
};
|
||||
@@ -1,53 +1,64 @@
|
||||
import { ConsumableEntry, ProvisionEntry } from '@blitzkit/core';
|
||||
import { GunDefinition, TankDefinition } from './tankDefinitions';
|
||||
import {
|
||||
Consumable,
|
||||
ConsumableTankCategoryFilterCategory,
|
||||
GunDefinition,
|
||||
Provision,
|
||||
TankDefinition,
|
||||
} from '../protos';
|
||||
|
||||
export function checkConsumableProvisionInclusivity(
|
||||
consumableProvision: ConsumableEntry | ProvisionEntry,
|
||||
consumableProvision: Consumable | Provision,
|
||||
tank: TankDefinition,
|
||||
gun: GunDefinition,
|
||||
) {
|
||||
const included =
|
||||
!consumableProvision.gameMode &&
|
||||
!consumableProvision.gameModeExclusive &&
|
||||
consumableProvision.include?.every((rule) => {
|
||||
switch (rule.type) {
|
||||
case 'tier':
|
||||
return rule.min <= tank.tier && tank.tier <= rule.max;
|
||||
switch (rule.filterType!.$case) {
|
||||
case 'tiers':
|
||||
return (
|
||||
rule.filterType!.value.min <= tank.tier &&
|
||||
tank.tier <= rule.filterType!.value.max
|
||||
);
|
||||
|
||||
case 'ids':
|
||||
return rule.ids.includes(tank.id);
|
||||
return rule.filterType!.value.ids.includes(tank.id);
|
||||
|
||||
case 'nation':
|
||||
return rule.nations.includes(tank.nation);
|
||||
case 'nations':
|
||||
return rule.filterType!.value.nations.includes(tank.nation);
|
||||
|
||||
case 'category':
|
||||
case 'categories':
|
||||
throw new SyntaxError('Category filtering found in include rule');
|
||||
}
|
||||
});
|
||||
const excluded =
|
||||
consumableProvision.gameMode ||
|
||||
consumableProvision.gameModeExclusive ||
|
||||
consumableProvision.exclude?.some((rule) => {
|
||||
switch (rule.type) {
|
||||
case 'tier':
|
||||
return rule.min <= tank.tier && tank.tier <= rule.max;
|
||||
switch (rule.filterType!.$case) {
|
||||
case 'tiers':
|
||||
return (
|
||||
rule.filterType!.value.min <= tank.tier &&
|
||||
tank.tier <= rule.filterType!.value.max
|
||||
);
|
||||
|
||||
case 'ids':
|
||||
return rule.ids.includes(tank.id);
|
||||
return rule.filterType!.value.ids.includes(tank.id);
|
||||
|
||||
case 'nation':
|
||||
return rule.nations.includes(tank.nation);
|
||||
case 'nations':
|
||||
return rule.filterType!.value.nations.includes(tank.nation);
|
||||
|
||||
case 'category':
|
||||
return rule.categories.some((category) => {
|
||||
case 'categories':
|
||||
return rule.filterType!.value.categories.some((category) => {
|
||||
switch (category) {
|
||||
case 'clip':
|
||||
return gun.type !== 'regular';
|
||||
case ConsumableTankCategoryFilterCategory.CLIP:
|
||||
return gun.gunType!.$case !== 'regular';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
!consumableProvision.gameMode &&
|
||||
!consumableProvision.gameModeExclusive &&
|
||||
consumableProvision.include?.length > 0 &&
|
||||
included &&
|
||||
!excluded
|
||||
|
||||
@@ -5,7 +5,7 @@ export function createDefaultSkills(skillDefinitions: SkillDefinitions) {
|
||||
const skills: Record<string, number> = {};
|
||||
|
||||
Object.values(skillDefinitions.classes).forEach((tankSkills) => {
|
||||
tankSkills.forEach((skill) => {
|
||||
tankSkills.skills.forEach((skill) => {
|
||||
skills[skill] = permanentSkills.includes(skill) ? 7 : 0;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import { RatingInfo, Region, asset, superDecompress } from '@blitzkit/core';
|
||||
// import { RatingInfo, Region, asset } from '@blitzkit/core';
|
||||
|
||||
const cache: Record<
|
||||
Region,
|
||||
Record<
|
||||
number,
|
||||
RatingInfo & {
|
||||
detail: undefined;
|
||||
}
|
||||
>
|
||||
> = {
|
||||
com: {},
|
||||
eu: {},
|
||||
asia: {},
|
||||
};
|
||||
// const cache: Record<
|
||||
// Region,
|
||||
// Record<
|
||||
// number,
|
||||
// RatingInfo & {
|
||||
// detail: undefined;
|
||||
// }
|
||||
// >
|
||||
// > = {
|
||||
// com: {},
|
||||
// eu: {},
|
||||
// asia: {},
|
||||
// };
|
||||
|
||||
export async function getArchivedRatingInfo(region: Region, season: number) {
|
||||
if (!cache[region][season]) {
|
||||
const info = await fetch(
|
||||
asset(`regions/${region}/rating/${season}/info.cdon.lz4`),
|
||||
)
|
||||
.then((response) => response.arrayBuffer())
|
||||
.then((buffer) =>
|
||||
superDecompress<RatingInfo & { detail: undefined }>(buffer),
|
||||
);
|
||||
cache[region][season] = info;
|
||||
}
|
||||
// export async function getArchivedRatingInfo(region: Region, season: number) {
|
||||
// if (!cache[region][season]) {
|
||||
// const info = await fetch(
|
||||
// asset(`regions/${region}/rating/${season}/info.cdon.lz4`),
|
||||
// )
|
||||
// .then((response) => response.arrayBuffer())
|
||||
// .then((buffer) =>
|
||||
// superDecompress<RatingInfo & { detail: undefined }>(buffer),
|
||||
// );
|
||||
// cache[region][season] = info;
|
||||
// }
|
||||
|
||||
return cache[region][season];
|
||||
}
|
||||
// return cache[region][season];
|
||||
// }
|
||||
@@ -10,10 +10,9 @@ export * from './consumableDefinitions';
|
||||
export * from './createDefaultSkills';
|
||||
export * from './degressiveStat';
|
||||
export * from './discoveredIdDefinitions';
|
||||
// export * from './emblemURL';
|
||||
export * from './emblemURL';
|
||||
export * from './equipmentDefinitions';
|
||||
export * from './eventManager';
|
||||
export * from './resolveGun';
|
||||
// export * from './flagUserActivity';
|
||||
export * from './gameDefinitions';
|
||||
// export * from './getArchivedLatestSeasonNumber';
|
||||
@@ -23,7 +22,7 @@ export * from './gameDefinitions';
|
||||
// export * from './getTimeDaysAgo';
|
||||
export * from './isExplosive';
|
||||
// export * from './linkBlitzAndDiscord';
|
||||
// export * from './mapDefinitions';
|
||||
export * from './mapDefinitions';
|
||||
export * from './modelDefinitions';
|
||||
export * from './normalizeBoundingBox';
|
||||
// export * from './parseBkni';
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { BoundingBox } from '@blitzkit/core';
|
||||
import { Vector3Tuple } from 'three';
|
||||
import { BoundingBox, Vector3 } from '@blitzkit/core';
|
||||
|
||||
export function normalizeBoundingBox(boundingBox: BoundingBox) {
|
||||
return boundingBox.max.map(
|
||||
(max, index) => max - boundingBox.min[index],
|
||||
) as Vector3Tuple;
|
||||
return {
|
||||
x: boundingBox.max.x - boundingBox.min.x,
|
||||
y: boundingBox.max.y - boundingBox.min.y,
|
||||
z: boundingBox.max.z - boundingBox.min.z,
|
||||
} satisfies Vector3;
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
import { GunDefinition, ShellDefinition } from './tankDefinitions';
|
||||
import {
|
||||
GunDefinition,
|
||||
GunDefinitionAutoReloaderProperties,
|
||||
ShellDefinition,
|
||||
} from '../protos';
|
||||
|
||||
export function resolveDpm(
|
||||
gun: GunDefinition,
|
||||
@@ -7,30 +11,38 @@ export function resolveDpm(
|
||||
reloadCoefficient = 1,
|
||||
intraClipCoefficient = 1,
|
||||
) {
|
||||
const alpha = shell.damage.armor * damageCoefficient;
|
||||
const alpha = shell.armorDamage * damageCoefficient;
|
||||
let dps: number;
|
||||
|
||||
if (gun.type === 'regular') {
|
||||
dps = alpha / (reloadCoefficient * gun.reload);
|
||||
} else if (gun.type === 'autoLoader') {
|
||||
if (gun.gunType!.$case === 'regular') {
|
||||
dps = alpha / (reloadCoefficient * gun.gunType!.value.extension.reload);
|
||||
} else if (gun.gunType!.$case === 'autoLoader') {
|
||||
dps =
|
||||
(alpha * gun.count) /
|
||||
(gun.reload * reloadCoefficient +
|
||||
(gun.count - 1) * gun.intraClip * intraClipCoefficient);
|
||||
(alpha * gun.gunType!.value.extension.shellCount) /
|
||||
(gun.gunType!.value.extension.clipReload * reloadCoefficient +
|
||||
(gun.gunType!.value.extension.shellCount - 1) *
|
||||
gun.gunType!.value.extension.intraClip *
|
||||
intraClipCoefficient);
|
||||
} else {
|
||||
const mostOptimalShell = gun.reload.reduce<null | {
|
||||
index: number;
|
||||
reload: number;
|
||||
}>((current, reloadRaw, index) => {
|
||||
const reload =
|
||||
reloadRaw * reloadCoefficient +
|
||||
(index > 0 ? gun.intraClip * intraClipCoefficient : 0);
|
||||
const mostOptimalShell =
|
||||
gun.gunType!.value.extension.shellReloads.reduce<null | {
|
||||
index: number;
|
||||
reload: number;
|
||||
}>((current, reloadRaw, index) => {
|
||||
const reload =
|
||||
reloadRaw * reloadCoefficient +
|
||||
(index > 0
|
||||
? (
|
||||
gun.gunType!.value
|
||||
.extension as GunDefinitionAutoReloaderProperties
|
||||
).intraClip * intraClipCoefficient
|
||||
: 0);
|
||||
|
||||
if (current === null || reload < current.reload) {
|
||||
return { index, reload };
|
||||
}
|
||||
return current;
|
||||
}, null)!;
|
||||
if (current === null || reload < current.reload) {
|
||||
return { index, reload };
|
||||
}
|
||||
return current;
|
||||
}, null)!;
|
||||
|
||||
dps = alpha / mostOptimalShell?.reload;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { GunDefinition } from '../protos';
|
||||
|
||||
export function resolveGun(gun: GunDefinition) {
|
||||
if (gun.regular) return gun.regular;
|
||||
else if (gun.autoLoader) return gun.autoLoader;
|
||||
else if (gun.autoReloader) return gun.autoReloader;
|
||||
|
||||
throw new Error('Could not resolve gun');
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ShellType } from '../blitzkit/tankDefinitions';
|
||||
import { ShellType } from '../protos';
|
||||
|
||||
export function resolvePenetrationCoefficient(
|
||||
calibratedShells: boolean,
|
||||
@@ -6,11 +6,11 @@ export function resolvePenetrationCoefficient(
|
||||
) {
|
||||
if (!calibratedShells) return 1;
|
||||
|
||||
return type === 'ap'
|
||||
return type === ShellType.AP
|
||||
? 1.08
|
||||
: type === 'ap_cr'
|
||||
: type === ShellType.APCR
|
||||
? 1.05
|
||||
: type === 'hc'
|
||||
: type === ShellType.HEAT
|
||||
? 1.13
|
||||
: 1.08;
|
||||
}
|
||||
@@ -9,3 +9,4 @@ export * from './protos';
|
||||
export * from './statistics';
|
||||
export * from './streams';
|
||||
export * from './types';
|
||||
|
||||
@@ -12,7 +12,7 @@ message Consumable {
|
||||
required uint32 id = 1;
|
||||
required string name = 2;
|
||||
required uint32 cooldown = 3;
|
||||
optional uint32 duration = 4;
|
||||
optional float duration = 4;
|
||||
required bool game_mode_exclusive = 5;
|
||||
repeated ConsumableTankFilter include = 6;
|
||||
repeated ConsumableTankFilter exclude = 7;
|
||||
|
||||
@@ -16,7 +16,7 @@ message ModelDefinition {
|
||||
}
|
||||
|
||||
message Armor {
|
||||
map<uint32, uint32> thickness = 1;
|
||||
map<uint32, float> thickness = 1;
|
||||
repeated uint32 spaced = 2;
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ message BoundingBox {
|
||||
}
|
||||
|
||||
message TrackModelDefinition {
|
||||
required uint32 thickness = 1;
|
||||
required float thickness = 1;
|
||||
required Vector3 origin = 2;
|
||||
}
|
||||
|
||||
message GunModelDefinition {
|
||||
required Armor armor = 1;
|
||||
required uint32 thickness = 2;
|
||||
required float thickness = 2;
|
||||
required uint32 model_id = 3;
|
||||
required PitchLimits pitch = 4;
|
||||
optional float mask = 5;
|
||||
|
||||
@@ -30,7 +30,7 @@ message TankDefinition {
|
||||
repeated EngineDefinition engines = 21;
|
||||
repeated TrackDefinition tracks = 22;
|
||||
required TankPrice price = 23;
|
||||
optional uint32 xp = 24;
|
||||
optional ResearchCost research_cost = 24;
|
||||
required float speed_forwards = 25;
|
||||
required float speed_backwards = 26;
|
||||
required float camouflage_still = 27;
|
||||
@@ -40,6 +40,18 @@ message TankDefinition {
|
||||
required uint32 weight = 31;
|
||||
}
|
||||
|
||||
message ResearchCost {
|
||||
oneof research_cost_type {
|
||||
uint32 xp = 1;
|
||||
ResearchCostSeasonalTokens seasonal_tokens = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ResearchCostSeasonalTokens {
|
||||
required uint32 season = 1;
|
||||
required uint32 tokens = 2;
|
||||
}
|
||||
|
||||
enum TankPriceType {
|
||||
TANK_PRICE_TYPE_CREDITS = 0;
|
||||
TANK_PRICE_TYPE_GOLD = 1;
|
||||
@@ -56,7 +68,7 @@ message TrackDefinition {
|
||||
required string name = 3;
|
||||
required uint32 weight = 4;
|
||||
required float traverse_speed = 5;
|
||||
optional uint32 xp = 6;
|
||||
optional ResearchCost research_cost = 6;
|
||||
required float dispersion_move = 7;
|
||||
required float dispersion_traverse = 8;
|
||||
required float resistance_hard = 9;
|
||||
@@ -68,7 +80,7 @@ message TrackDefinition {
|
||||
message EngineDefinition {
|
||||
required uint32 id = 1;
|
||||
required string name = 2;
|
||||
optional uint32 xp = 3;
|
||||
optional ResearchCost research_cost = 3;
|
||||
required Tier tier = 4;
|
||||
required float fire_chance = 5;
|
||||
required uint32 power = 6;
|
||||
@@ -81,7 +93,7 @@ message TurretDefinition {
|
||||
required uint32 health = 2;
|
||||
required uint32 view_range = 3;
|
||||
required float traverse_speed = 4;
|
||||
optional uint32 xp = 5;
|
||||
optional ResearchCost research_cost = 5;
|
||||
required string name = 6;
|
||||
required Tier tier = 7;
|
||||
required uint32 weight = 8;
|
||||
@@ -131,7 +143,7 @@ message GunDefinitionAutoReloaderProperties {
|
||||
message GunDefinitionBase {
|
||||
required uint32 id = 1;
|
||||
required float rotation_speed = 2;
|
||||
optional uint32 xp = 3;
|
||||
optional ResearchCost research_cost = 3;
|
||||
required uint32 weight = 4;
|
||||
required string name = 5;
|
||||
required Tier tier = 6;
|
||||
@@ -151,13 +163,13 @@ message ShellDefinition {
|
||||
required uint32 velocity = 3;
|
||||
required uint32 armor_damage = 4;
|
||||
required uint32 module_damage = 5;
|
||||
required uint32 caliber = 6;
|
||||
required float caliber = 6;
|
||||
required string icon = 7;
|
||||
required ShellPenetration penetration = 8;
|
||||
required ShellType type = 9;
|
||||
required uint32 normalization = 10;
|
||||
required uint32 ricochet = 11;
|
||||
required uint32 explosion_radius = 12;
|
||||
optional float normalization = 10;
|
||||
optional float ricochet = 11;
|
||||
optional float explosion_radius = 12;
|
||||
}
|
||||
|
||||
enum ShellType {
|
||||
@@ -168,8 +180,8 @@ enum ShellType {
|
||||
}
|
||||
|
||||
message ShellPenetration {
|
||||
required uint32 near = 1;
|
||||
required uint32 far = 2;
|
||||
required float near = 1;
|
||||
required float far = 2;
|
||||
}
|
||||
|
||||
message Unlock {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { tankDefinitions, Tier } from '../blitzkit/tankDefinitions';
|
||||
import { fetchTankDefinitions } from '../blitzkit';
|
||||
import { Tier } from '../protos';
|
||||
import { BlitzStats } from './compositeStats/constants';
|
||||
|
||||
export async function getTierWeights(
|
||||
stats: Record<number, BlitzStats>,
|
||||
order: number[] = Object.keys(stats).map(parseInt),
|
||||
) {
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const tankDefinitions = await fetchTankDefinitions();
|
||||
const tierWeights: TierWeightsRecord = {};
|
||||
|
||||
order.forEach((id) => {
|
||||
const entry = awaitedTankDefinitions[id];
|
||||
const entry = tankDefinitions.tanks[id];
|
||||
|
||||
if (!entry) return;
|
||||
if (!tierWeights[entry.tier]) tierWeights[entry.tier] = 0;
|
||||
|
||||
Reference in new issue
Block a user