mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-18 19:36:13 +01:00
Compare commits
7
Commits
48fbf59036
...
be4af0bf84
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be4af0bf84 | ||
|
|
15172e8b33 | ||
|
|
c6b7918525 | ||
|
|
4f1c4421e5 | ||
|
|
7b830f5a71 | ||
|
|
6ce1135835 | ||
|
|
66eaaef6de |
No files matched your search
@@ -8,7 +8,7 @@ import AstroPWA from "@vite-pwa/astro";
|
||||
import favicons from "astro-favicons";
|
||||
import { defineConfig } from "astro/config";
|
||||
import packageJSON from "../../package.json";
|
||||
import { tools } from "./src/constants/tools";
|
||||
import { tools } from "./src/core/tools/tools";
|
||||
|
||||
const POSSIBLE_TARGETS = ["app", "web"];
|
||||
|
||||
|
||||
@@ -1,397 +0,0 @@
|
||||
// import { TankAttributeChange_AttributeName } from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
|
||||
import { TankAttributeChange_AttributeName } from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
|
||||
export enum CharacteristicsGroup {
|
||||
Firepower = "firepower",
|
||||
Maneuverability = "maneuverability",
|
||||
Survivability = "survivability",
|
||||
Miscellaneous = "miscellaneous",
|
||||
}
|
||||
|
||||
// type CharacteristicsOrder = {
|
||||
// group: CharacteristicsGroup;
|
||||
|
||||
// characteristics: {
|
||||
// name: string;
|
||||
// value(
|
||||
// get: (name: TankAttributeChange_AttributeName) => number
|
||||
// ): number | string | null;
|
||||
// }[];
|
||||
// }[];
|
||||
|
||||
// export const characteristicsOrder: CharacteristicsOrder = [
|
||||
// {
|
||||
// group: CharacteristicsGroup.Firepower,
|
||||
|
||||
// characteristics: [
|
||||
// {
|
||||
// name: "gun_type",
|
||||
|
||||
// value(get) {
|
||||
// const isPump = get(
|
||||
// TankAttributeChange_AttributeName.ATTRIBUTE_NAME_IS_PUMP
|
||||
// );
|
||||
|
||||
// if (isPump === 1) return "auto_reloader";
|
||||
|
||||
// const clipSize = get(
|
||||
// TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE
|
||||
// );
|
||||
|
||||
// if (clipSize === 1) return "regular";
|
||||
|
||||
// return "auto_loader";
|
||||
// },
|
||||
// },
|
||||
|
||||
// {
|
||||
// name: "dpm",
|
||||
|
||||
// value(get) {
|
||||
// return -1;
|
||||
// },
|
||||
// },
|
||||
|
||||
// {
|
||||
// name: "clipping_potential",
|
||||
|
||||
// value(get) {
|
||||
// const clipSize = get(
|
||||
// TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE
|
||||
// );
|
||||
|
||||
// if (clipSize === 1) return null;
|
||||
|
||||
// // const damage
|
||||
|
||||
// return -1;
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ];
|
||||
|
||||
// type _CharacteristicsOrder = {
|
||||
// group: CharacteristicsGroup;
|
||||
|
||||
// attributes: {
|
||||
// name: TankAttributeChange_AttributeName;
|
||||
// }[];
|
||||
// }[];
|
||||
|
||||
// export const _characteristicsOrder: _CharacteristicsOrder = [
|
||||
// {
|
||||
// group: CharacteristicsGroup.Firepower,
|
||||
|
||||
// attributes: [
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_RELOAD_TIME,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_ANGLE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_AIMING_TIME,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_VEHICLE_MOVEMENT,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_VEHICLE_ROTATION,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_TURRET_ROTATION,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_AFTER_SHOT,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_WHILE_GUN_DAMAGED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_DOWN,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_UP,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_YAW_LIMIT_LEFT,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_YAW_LIMIT_RIGHT,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_RATE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_IS_PUMP,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_SLOTS,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_BURST_SIZE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_BURST_RATE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_RELOAD_SPEED_SCALE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_ARMOR_DAMAGE_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_SPEED_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_PIERCING_POWER_LOSS_REDUCTION,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ENGINE_HIT_CHANCE_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CREW_HIT_CHANCE_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_AMMO_BAY_EXPLOSION_CHANCE_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_LARGE_CALIBER_HE_PIERCING_FACTOR,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_PIERCING_MULTIPLIER_AP,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_PIERCING_MULTIPLIER_APCR,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_PIERCING_MULTIPLIER_HC,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_PIERCING_MULTIPLIER_HE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TRACER_SHELLS_ENABLED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ROTATION_RELOAD_SPEED_SCALE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ARMOR_DAMAGE_HE_SHELLS,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MODULE_DAMAGE_HE_SHELLS,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
|
||||
// {
|
||||
// group: CharacteristicsGroup.Maneuverability,
|
||||
|
||||
// attributes: [
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_GUN_ROTATION_SPEED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TURRET_ROTATION_SPEED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_HULL_ROTATION_SPEED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ENGINE_POWER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_BRAKE_FORCE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MASS,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_FORWARD_MAX_SPEED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_BACKWARD_MAX_SPEED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_HARD,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_MEDIUM,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_SOFT,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_SIDE_FRICTION,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_FORWARD_FRICTION,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_RESERVE_TRACK_BACKWARD_SPEED,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
|
||||
// {
|
||||
// group: CharacteristicsGroup.Survivability,
|
||||
|
||||
// attributes: [
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MAX_HEALTH,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_HEALTH_BURN_PER_SEC,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CIRCULAR_VISION_RADIUS,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_MOVING,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_STILL,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FIRE_PENALTY,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FACTOR_AT_SHOT,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_FIRE_START_CHANCE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_AVERAGE_THICKNESS,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONSUMABLE_COOLDOWN_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONSUMABLE_DURATION_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONSUMABLE_RECHARGE_SPEED_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_RAMMING_DAMAGE_RESISTANCE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_LARGE_CALIBER_HE_SHELLS_DAMAGE_RESISTANCE,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ENHANCED_TRACKS_ENABLED,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ARMOR_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MODULE_REGEN_PER_SEC_MULTIPLIER,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MODULES_DAMAGED_DEBUFF_EFFICIENCY,
|
||||
// },
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MAX_FIRE_DURATION,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
|
||||
// {
|
||||
// group: CharacteristicsGroup.Miscellaneous,
|
||||
|
||||
// attributes: [
|
||||
// {
|
||||
// name: TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CREW_XP_MULTIPLIER,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ];
|
||||
|
||||
// if (import.meta.env.DEV) {
|
||||
// for (const name of Object.values(TankAttributeChange_AttributeName).filter(
|
||||
// (value) => typeof value === "number"
|
||||
// )) {
|
||||
// if (name === TankAttributeChange_AttributeName.ATTRIBUTE_NAME_UNSPECIFIED) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// const isImplemented = _characteristicsOrder.some((group) =>
|
||||
// group.attributes.some((attribute) => attribute.name === name)
|
||||
// );
|
||||
|
||||
// if (!isImplemented) {
|
||||
// throw new Error(`Attribute ${name} is not implemented`);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
type Characteristics = Record<
|
||||
string,
|
||||
{
|
||||
render: (
|
||||
characteristic: (name: Characteristic) => number,
|
||||
attribute: (name: TankAttributeChange_AttributeName) => number
|
||||
) => number | string | null;
|
||||
}
|
||||
>;
|
||||
|
||||
export const characteristics = {
|
||||
gun_type: {
|
||||
render(_, attribute) {
|
||||
const isPump = attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_IS_PUMP
|
||||
);
|
||||
|
||||
if (isPump === 1) return "auto_reloader";
|
||||
|
||||
const clipSize = attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE
|
||||
);
|
||||
|
||||
if (clipSize === 1) return "regular";
|
||||
|
||||
return "auto_loader";
|
||||
},
|
||||
},
|
||||
|
||||
dpm: {
|
||||
render(characteristic, attribute) {
|
||||
const damage = characteristic("damage");
|
||||
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
} satisfies Characteristics;
|
||||
|
||||
export type Characteristic = keyof typeof characteristics;
|
||||
|
||||
type CharacteristicsOrder = {
|
||||
group: CharacteristicsGroup;
|
||||
characteristics: Characteristic[];
|
||||
}[];
|
||||
|
||||
export const characteristicsOrder: CharacteristicsOrder = [
|
||||
{
|
||||
group: CharacteristicsGroup.Firepower,
|
||||
characteristics: ["gun_type", "dpm"],
|
||||
},
|
||||
{
|
||||
group: CharacteristicsGroup.Maneuverability,
|
||||
characteristics: [],
|
||||
},
|
||||
{
|
||||
group: CharacteristicsGroup.Survivability,
|
||||
characteristics: [],
|
||||
},
|
||||
{
|
||||
group: CharacteristicsGroup.Miscellaneous,
|
||||
characteristics: [],
|
||||
},
|
||||
];
|
||||
+25
-27
@@ -11,7 +11,6 @@ import {
|
||||
TankAttributeChange_Modifier,
|
||||
VisualChanges,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import { times } from "lodash-es";
|
||||
|
||||
function patch(stage0: StageParameters, stage1: StageParameters) {
|
||||
if (stage1.stage_number !== ++stage0.stage_number) {
|
||||
@@ -118,33 +117,32 @@ function patch(stage0: StageParameters, stage1: StageParameters) {
|
||||
(baseShell) => baseShell.shell_id === shellUpgrades1.shell_id
|
||||
);
|
||||
|
||||
if (!shellUpgrades0) {
|
||||
shellUpgrades0 = ShellUpgrade.create({
|
||||
shell_id: shellUpgrades1.shell_id,
|
||||
});
|
||||
}
|
||||
if (shellUpgrades0) {
|
||||
shellUpgrades0.shell_type = shellUpgrades1.shell_type;
|
||||
|
||||
shellUpgrades0.shell_type = shellUpgrades1.shell_type;
|
||||
|
||||
for (const changedShellUpgrade of shellUpgrades1.changes) {
|
||||
const baseShellUpgrade = shellUpgrades0.changes.find(
|
||||
(baseShellUpgrade) =>
|
||||
baseShellUpgrade.attribute_name === changedShellUpgrade.attribute_name
|
||||
);
|
||||
|
||||
if (baseShellUpgrade) {
|
||||
baseShellUpgrade.value = changedShellUpgrade.value;
|
||||
} else {
|
||||
shellUpgrades0.changes.push(
|
||||
ShellUpgrageSingleChange.create(changedShellUpgrade)
|
||||
for (const changedShellUpgrade of shellUpgrades1.changes) {
|
||||
const shellUpgrade0 = shellUpgrades0.changes.find(
|
||||
(baseShellUpgrade) =>
|
||||
baseShellUpgrade.attribute_name ===
|
||||
changedShellUpgrade.attribute_name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
shellUpgrades0.silver_price =
|
||||
shellUpgrades1.silver_price === undefined
|
||||
? undefined
|
||||
: StandardSinglePrice.create(shellUpgrades1.silver_price);
|
||||
if (shellUpgrade0) {
|
||||
shellUpgrade0.value = changedShellUpgrade.value;
|
||||
} else {
|
||||
shellUpgrades0.changes.push(
|
||||
ShellUpgrageSingleChange.create(changedShellUpgrade)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
shellUpgrades0.silver_price =
|
||||
shellUpgrades1.silver_price === undefined
|
||||
? undefined
|
||||
: StandardSinglePrice.create(shellUpgrades1.silver_price);
|
||||
} else {
|
||||
stage0.shells_upgrades.push(ShellUpgrade.create(shellUpgrades1));
|
||||
}
|
||||
}
|
||||
|
||||
if (stage1.pump_reload_times.length > 0) {
|
||||
@@ -184,7 +182,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
export function aggregateStages(
|
||||
export function aggregateStageParameters(
|
||||
base: StageParameters,
|
||||
stages: StageParameters[],
|
||||
stage: number
|
||||
@@ -208,7 +206,7 @@ export function aggregateStages(
|
||||
|
||||
stage0.stage_number = 0;
|
||||
|
||||
times(stage, (index) => patch(stage0, stages[index]));
|
||||
stages.forEach((stage) => patch(stage0, stage));
|
||||
|
||||
return stage0;
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
import {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
TankAttributeChange_AttributeName,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
|
||||
export type CharacteristicOutput = number | null;
|
||||
|
||||
type Characteristic = (helpers: {
|
||||
characteristic: (name: CharacteristicName) => CharacteristicOutput;
|
||||
attribute: (name: TankAttributeChange_AttributeName) => number;
|
||||
attributeSafe: (name: TankAttributeChange_AttributeName) => number | null;
|
||||
shell: (name: ShellUpgrageSingleChange_AttributeName) => number;
|
||||
shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null;
|
||||
}) => CharacteristicOutput;
|
||||
|
||||
export type CharacteristicName = keyof typeof characteristics;
|
||||
|
||||
export enum GunType {
|
||||
Regular,
|
||||
AutoLoader,
|
||||
AutoReloader,
|
||||
}
|
||||
|
||||
export const characteristics = {
|
||||
gun_type({ attribute }) {
|
||||
const isPump = attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_IS_PUMP
|
||||
);
|
||||
|
||||
if (isPump === 1) return GunType.AutoReloader;
|
||||
|
||||
const clipSize = attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CLIP_SIZE
|
||||
);
|
||||
|
||||
if (clipSize === 1) return GunType.Regular;
|
||||
|
||||
return GunType.AutoLoader;
|
||||
},
|
||||
|
||||
damage({ shell }) {
|
||||
return shell(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_ARMOR_DAMAGE
|
||||
);
|
||||
},
|
||||
|
||||
module_damage({ shell }) {
|
||||
return shell(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MODULE_DAMAGE
|
||||
);
|
||||
},
|
||||
|
||||
penetration({ shell }) {
|
||||
return shell(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_PIERCING_POWER
|
||||
);
|
||||
},
|
||||
|
||||
reload({ characteristic, attribute }) {
|
||||
const gunType = characteristic("gun_type")!;
|
||||
|
||||
if (gunType !== GunType.Regular) return null;
|
||||
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_RELOAD_TIME
|
||||
);
|
||||
},
|
||||
|
||||
dpm({ characteristic }) {
|
||||
let dps: number;
|
||||
const gunType = characteristic("gun_type")!;
|
||||
const damage = characteristic("damage")!;
|
||||
|
||||
switch (gunType) {
|
||||
case GunType.Regular: {
|
||||
const reload = characteristic("reload")!;
|
||||
dps = damage / reload;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error("Unknown gun type");
|
||||
}
|
||||
|
||||
return 60 * dps;
|
||||
},
|
||||
|
||||
caliber({ shell }) {
|
||||
return shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_CALIBER);
|
||||
},
|
||||
|
||||
normalization({ shellSafe }) {
|
||||
return shellSafe(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_NORMALIZATION
|
||||
);
|
||||
},
|
||||
|
||||
ricochet({ shell }) {
|
||||
return shell(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_RICOCHET_ANGLE
|
||||
);
|
||||
},
|
||||
|
||||
shell_velocity({ shell }) {
|
||||
return shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_SPEED);
|
||||
},
|
||||
|
||||
shell_range({ shellSafe }) {
|
||||
const maxDistance = shellSafe(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_DISTANCE
|
||||
);
|
||||
return maxDistance === null ? Infinity : maxDistance;
|
||||
},
|
||||
|
||||
shell_capacity({ shellSafe }) {
|
||||
const count = shellSafe(
|
||||
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_COUNT
|
||||
);
|
||||
return count === -1 || count === null ? Infinity : count;
|
||||
},
|
||||
|
||||
aim_time({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_AIMING_TIME
|
||||
);
|
||||
},
|
||||
|
||||
dispersion_still({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_ANGLE
|
||||
);
|
||||
},
|
||||
|
||||
dispersion_moving({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_VEHICLE_MOVEMENT
|
||||
);
|
||||
},
|
||||
|
||||
dispersion_hull_traversing({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_VEHICLE_ROTATION
|
||||
);
|
||||
},
|
||||
|
||||
dispersion_turret_traversing({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_TURRET_ROTATION
|
||||
);
|
||||
},
|
||||
|
||||
dispersion_shooting({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_AFTER_SHOT
|
||||
);
|
||||
},
|
||||
|
||||
dispersion_gun_damaged({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_WHILE_GUN_DAMAGED
|
||||
);
|
||||
},
|
||||
|
||||
gun_depression({ attributeSafe }) {
|
||||
return (
|
||||
attributeSafe(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_DOWN
|
||||
) ?? -Infinity
|
||||
);
|
||||
},
|
||||
|
||||
gun_elevation({ attributeSafe }) {
|
||||
return (
|
||||
attributeSafe(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_UP
|
||||
) ?? -Infinity
|
||||
);
|
||||
},
|
||||
|
||||
speed_forward({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_FORWARD_MAX_SPEED
|
||||
);
|
||||
},
|
||||
|
||||
speed_backward({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_BACKWARD_MAX_SPEED
|
||||
);
|
||||
},
|
||||
|
||||
engine_power({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ENGINE_POWER
|
||||
);
|
||||
},
|
||||
|
||||
weight({ attribute }) {
|
||||
return attribute(TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MASS);
|
||||
},
|
||||
|
||||
terrain_coefficient_hard({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_HARD
|
||||
);
|
||||
},
|
||||
|
||||
terrain_coefficient_medium({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_MEDIUM
|
||||
);
|
||||
},
|
||||
|
||||
terrain_coefficient_soft({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_SOFT
|
||||
);
|
||||
},
|
||||
|
||||
power_to_weight_hard() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
power_to_weight_medium() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
power_to_weight_soft() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
turret_traverse_speed({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TURRET_ROTATION_SPEED
|
||||
);
|
||||
},
|
||||
|
||||
hull_traverse_speed_hard() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
hull_traverse_speed_medium() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
hull_traverse_speed_soft() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
health({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MAX_HEALTH
|
||||
);
|
||||
},
|
||||
|
||||
fire_chance({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_FIRE_START_CHANCE
|
||||
);
|
||||
},
|
||||
|
||||
view_range({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CIRCULAR_VISION_RADIUS
|
||||
);
|
||||
},
|
||||
|
||||
camouflage_still({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_STILL
|
||||
);
|
||||
},
|
||||
|
||||
camouflage_moving({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_MOVING
|
||||
);
|
||||
},
|
||||
|
||||
camouflage_shooting_still({ attribute }) {
|
||||
return attribute(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FACTOR_AT_SHOT
|
||||
);
|
||||
},
|
||||
|
||||
camouflage_shooting_moving() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
camouflage_on_fire({ attributeSafe }) {
|
||||
return (
|
||||
attributeSafe(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FIRE_PENALTY
|
||||
) ?? -Infinity
|
||||
);
|
||||
},
|
||||
|
||||
height() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
length() {
|
||||
return -1;
|
||||
},
|
||||
|
||||
volume() {
|
||||
return -1;
|
||||
},
|
||||
} satisfies Record<string, Characteristic>;
|
||||
@@ -0,0 +1,108 @@
|
||||
import type { CharacteristicName } from "./characteristics";
|
||||
|
||||
export enum BetterDirection {
|
||||
Higher,
|
||||
Lower,
|
||||
}
|
||||
|
||||
type CharacteristicsOrder = {
|
||||
group: string;
|
||||
order: (
|
||||
| {
|
||||
name: CharacteristicName;
|
||||
decimals?: number;
|
||||
}
|
||||
| {
|
||||
toy: string;
|
||||
}
|
||||
)[];
|
||||
}[];
|
||||
|
||||
export const characteristicsGroups: CharacteristicsOrder = [
|
||||
{
|
||||
group: "firepower",
|
||||
order: [
|
||||
{ name: "gun_type" },
|
||||
{ name: "dpm", decimals: 0 },
|
||||
{ name: "damage" },
|
||||
{ name: "module_damage" },
|
||||
{ name: "penetration" },
|
||||
{ name: "reload" },
|
||||
|
||||
{ toy: "reload" },
|
||||
|
||||
{ name: "caliber" },
|
||||
{ name: "normalization" },
|
||||
{ name: "ricochet" },
|
||||
|
||||
{ toy: "ricochet" },
|
||||
|
||||
{ name: "shell_velocity" },
|
||||
{ name: "shell_range" },
|
||||
{ name: "shell_capacity" },
|
||||
|
||||
{ name: "aim_time" },
|
||||
|
||||
{ name: "dispersion_still" },
|
||||
{ name: "dispersion_moving" },
|
||||
{ name: "dispersion_hull_traversing" },
|
||||
{ name: "dispersion_turret_traversing" },
|
||||
{ name: "dispersion_shooting" },
|
||||
{ name: "dispersion_gun_damaged" },
|
||||
|
||||
{ name: "gun_depression" },
|
||||
{ name: "gun_elevation" },
|
||||
|
||||
{ toy: "flexibility" },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: "maneuverability",
|
||||
order: [
|
||||
{ name: "speed_forward" },
|
||||
{ name: "speed_backward" },
|
||||
|
||||
{ name: "engine_power" },
|
||||
{ name: "weight" },
|
||||
|
||||
{ name: "terrain_coefficient_hard" },
|
||||
{ name: "terrain_coefficient_medium" },
|
||||
{ name: "terrain_coefficient_soft" },
|
||||
|
||||
{ name: "power_to_weight_hard" },
|
||||
{ name: "power_to_weight_medium" },
|
||||
{ name: "power_to_weight_soft" },
|
||||
|
||||
{ name: "turret_traverse_speed" },
|
||||
{ name: "hull_traverse_speed_hard" },
|
||||
{ name: "hull_traverse_speed_medium" },
|
||||
{ name: "hull_traverse_speed_soft" },
|
||||
|
||||
{ toy: "traverse" },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: "survivability",
|
||||
order: [
|
||||
{ name: "health" },
|
||||
{ name: "fire_chance" },
|
||||
{ name: "view_range" },
|
||||
|
||||
{ toy: "view_range" },
|
||||
|
||||
{ name: "camouflage_still" },
|
||||
{ name: "camouflage_moving" },
|
||||
{ name: "camouflage_shooting_still" },
|
||||
{ name: "camouflage_shooting_moving" },
|
||||
{ name: "camouflage_on_fire" },
|
||||
|
||||
{ name: "height" },
|
||||
{ name: "length" },
|
||||
{ name: "volume" },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: "miscellaneous",
|
||||
order: [],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,88 @@
|
||||
import {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
TankAttributeChange_AttributeName,
|
||||
type StageParameters,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import {
|
||||
characteristics,
|
||||
type CharacteristicName,
|
||||
type CharacteristicOutput,
|
||||
} from "./characteristics";
|
||||
import type { TankState } from "./tankState";
|
||||
|
||||
export function computeCharacteristics(
|
||||
parameters: StageParameters,
|
||||
state: TankState
|
||||
) {
|
||||
const computed: Partial<Record<CharacteristicName, CharacteristicOutput>> =
|
||||
{};
|
||||
|
||||
function characteristic(name: CharacteristicName) {
|
||||
if (name in computed) return computed[name] as CharacteristicOutput;
|
||||
throw new Error(`${name} not computed yet`);
|
||||
}
|
||||
|
||||
function attributeSafe(name: TankAttributeChange_AttributeName) {
|
||||
const attribute = parameters.attributes.find(
|
||||
(attribute) => attribute.attribute_name === name
|
||||
);
|
||||
|
||||
return attribute ? attribute.value : null;
|
||||
}
|
||||
|
||||
function attribute(name: TankAttributeChange_AttributeName) {
|
||||
const attribute = attributeSafe(name);
|
||||
|
||||
if (attribute === null) {
|
||||
throw new Error(
|
||||
`Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found`
|
||||
);
|
||||
}
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
function shellSafe(name: ShellUpgrageSingleChange_AttributeName) {
|
||||
const shell = parameters.shells_upgrades.find(
|
||||
(shell) => shell.shell_id === state.shell
|
||||
);
|
||||
|
||||
if (!shell) {
|
||||
throw new Error(
|
||||
`Shell ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found`
|
||||
);
|
||||
}
|
||||
|
||||
const attribute = shell.changes.find(
|
||||
(change) => change.attribute_name === name
|
||||
);
|
||||
|
||||
return attribute ? attribute.value : null;
|
||||
}
|
||||
|
||||
function shell(name: ShellUpgrageSingleChange_AttributeName) {
|
||||
const attribute = shellSafe(name);
|
||||
|
||||
if (attribute === null) {
|
||||
throw new Error(
|
||||
`Shell attribute ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found`
|
||||
);
|
||||
}
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
for (const _name in characteristics) {
|
||||
const name = _name as CharacteristicName;
|
||||
const value = characteristics[name]({
|
||||
characteristic,
|
||||
attribute,
|
||||
attributeSafe,
|
||||
shell,
|
||||
shellSafe,
|
||||
});
|
||||
computed[name] = value;
|
||||
}
|
||||
|
||||
return computed as Record<CharacteristicName, CharacteristicOutput>;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface TankState {
|
||||
stage: number;
|
||||
|
||||
shell: number;
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _characteristicsOrder } from "../../../../constants/characteristics";
|
||||
import { _characteristicsOrder } from "../../../../core/tankopedia/characteristics";
|
||||
|
||||
export function GET() {
|
||||
return Response.json(_characteristicsOrder);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { times } from "lodash-es";
|
||||
import { Suspense, useMemo } from "react";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { aggregateStages } from "../../../core/blitz/aggregateStages";
|
||||
import { aggregateStageParameters } from "../../../core/tankopedia/aggregateStageParameters";
|
||||
import { characteristicsGroups } from "../../../core/tankopedia/characteristicsGroups";
|
||||
import { computeCharacteristics } from "../../../core/tankopedia/computeCharacteristics";
|
||||
import { useAwait } from "../../../hooks/useAwait";
|
||||
import { Tankopedia } from "../../../stores/tankopedia";
|
||||
|
||||
@@ -16,49 +18,90 @@ export function Page({ id }: { id: string }) {
|
||||
function Content({ id }: { id: string }) {
|
||||
const tank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
|
||||
const stage = Tankopedia.use((state) => state.stage);
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
const parameters = useMemo(
|
||||
() => aggregateStages(tank.base_stats!, tank.upgrade_stages, stage),
|
||||
[stage]
|
||||
() =>
|
||||
aggregateStageParameters(
|
||||
tank.base_stats!,
|
||||
tank.upgrade_stages.slice(0, protagonist.stage),
|
||||
protagonist.shell
|
||||
),
|
||||
[protagonist]
|
||||
);
|
||||
const characteristics = useMemo(
|
||||
() => computeCharacteristics(parameters, protagonist),
|
||||
[protagonist]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{id}</h1>
|
||||
|
||||
<div style={{ display: "flex", flexWrap: "wrap" }}>
|
||||
{times(tank.upgrade_stages.length, (index) => (
|
||||
{times(tank.upgrade_stages.length + 1, (index) => (
|
||||
<button
|
||||
key={index}
|
||||
onClick={() => {
|
||||
Tankopedia.mutate((draft) => {
|
||||
draft.stage = index;
|
||||
draft.protagonist.stage = index;
|
||||
});
|
||||
}}
|
||||
>
|
||||
Stage {index} {index === stage && "(selected)"}
|
||||
Stage {index} {index === protagonist.stage && "(selected)"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<pre children={JSON.stringify(parameters, null, 2)} />
|
||||
<h1>{tank.name?.value}</h1>
|
||||
<br />
|
||||
|
||||
<h2>Characteristics</h2>
|
||||
<div style={{ display: "flex", flexWrap: "wrap" }}>
|
||||
{parameters.shells_upgrades.map((shell) => (
|
||||
<button
|
||||
key={shell.shell_id}
|
||||
onClick={() => {
|
||||
Tankopedia.mutate((draft) => {
|
||||
draft.protagonist.shell = shell.shell_id;
|
||||
});
|
||||
}}
|
||||
>
|
||||
Shell {shell.shell_id}{" "}
|
||||
{shell.shell_id === protagonist.shell && "(selected)"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* {_characteristicsOrder.map((group) => (
|
||||
{characteristicsGroups.map(({ group, order }) => (
|
||||
<>
|
||||
<h2>{CharacteristicsGroup[group.group]}</h2>
|
||||
<h2 key={group}>{group}</h2>
|
||||
|
||||
{group.attributes.map(
|
||||
(attribute) =>
|
||||
attribute.name in attributes && (
|
||||
<p>
|
||||
{TankAttributeChange_AttributeName[attribute.name]}:{" "}
|
||||
{attributes[attribute.name]}
|
||||
{order.map((entry) => {
|
||||
if ("toy" in entry) {
|
||||
} else {
|
||||
const characteristic = characteristics[entry.name];
|
||||
|
||||
if (characteristic === null) return null;
|
||||
|
||||
let rendered: string | number;
|
||||
|
||||
if (Number.isFinite(characteristic)) {
|
||||
if (entry.decimals === undefined) {
|
||||
rendered = characteristic;
|
||||
} else {
|
||||
rendered = characteristic.toFixed(entry.decimals);
|
||||
}
|
||||
} else {
|
||||
rendered = `${Math.sign(characteristic) === 1 ? "" : "-"}∞`;
|
||||
}
|
||||
|
||||
return (
|
||||
<p key={entry.name}>
|
||||
{entry.name}: {rendered}
|
||||
</p>
|
||||
)
|
||||
)}
|
||||
);
|
||||
}
|
||||
})}
|
||||
</>
|
||||
))} */}
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import type { GetStaticPaths } from "astro";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import BaseLayout from "../../../layouts/BaseLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
@@ -15,4 +16,6 @@ export const getStaticPaths = (async () => {
|
||||
const { id } = Astro.props;
|
||||
---
|
||||
|
||||
<Page {id} client:load />
|
||||
<BaseLayout>
|
||||
<Page {id} client:load />
|
||||
</BaseLayout>
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Varuna } from "varuna";
|
||||
import type { TankState } from "../core/tankopedia/tankState";
|
||||
|
||||
interface Tankopedia {
|
||||
stage: number;
|
||||
protagonist: TankState;
|
||||
}
|
||||
|
||||
export const Tankopedia = new Varuna<Tankopedia>({ stage: 0 });
|
||||
export const Tankopedia = new Varuna<Tankopedia>({
|
||||
protagonist: { stage: 0, shell: 0 },
|
||||
});
|
||||
Reference in new issue
Block a user