feat: some more

This commit is contained in:
TrèsAbhi committed 2025-12-18 16:29:13 -06:00
1 parent 7b830f5a71
commit 4f1c4421e5
4 files changed
+99 -25

No files matched your search

@@ -6,9 +6,18 @@ import {
export type CharacteristicOutput = number | null;
type Characteristic = (helpers: {
characteristic: (name: CharacteristicName) => CharacteristicOutput;
attribute: (name: TankAttributeChange_AttributeName) => number;
shell: (name: ShellUpgrageSingleChange_AttributeName) => number;
characteristic: (
name: CharacteristicName,
error?: boolean
) => CharacteristicOutput;
attribute: (
name: TankAttributeChange_AttributeName,
error?: boolean
) => number;
shell: (
name: ShellUpgrageSingleChange_AttributeName,
error?: boolean
) => number;
}) => CharacteristicOutput;
export type CharacteristicName = keyof typeof characteristics;
@@ -82,4 +91,36 @@ export const characteristics = {
return 60 * dps;
},
caliber({ shell }) {
return shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_CALIBER);
},
normalization({ shell }) {
return shell(
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({ shell }) {
return shell(
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_DISTANCE
);
},
shell_capacity({ shell }) {
return shell(
ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_COUNT
);
},
} satisfies Record<string, Characteristic>;
@@ -7,10 +7,15 @@ export enum BetterDirection {
type CharacteristicsOrder = {
group: string;
order: {
name: CharacteristicName;
decimals?: number;
}[];
order: (
| {
name: CharacteristicName;
decimals?: number;
}
| {
toy: string;
}
)[];
}[];
export const characteristicsGroups = [
@@ -22,6 +27,19 @@ export const characteristicsGroups = [
{ 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" },
],
},
{
@@ -1,7 +1,7 @@
import type {
import {
ShellUpgrageSingleChange_AttributeName,
StageParameters,
TankAttributeChange_AttributeName,
type StageParameters,
} from "@protos/blitz_static_tank_upgrade_single_stage";
import {
characteristics,
@@ -27,8 +27,11 @@ export function computeCharacteristics(
(attribute) => attribute.attribute_name === name
);
if (!attribute) throw new Error(`Attribute ${name} not found`);
("");
if (!attribute) {
throw new Error(
`Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found`
);
}
return attribute.value;
}
@@ -38,13 +41,21 @@ export function computeCharacteristics(
(shell) => shell.shell_id === state.shell
);
if (!shell) throw new Error(`Shell ${name} not found`);
if (!shell) {
throw new Error(
`Shell ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found`
);
}
const attribute = shell.changes.find(
(change) => change.attribute_name === name
);
if (!attribute) throw new Error(`Shell attribute ${name} not found`);
if (!attribute) {
throw new Error(
`Shell attribute ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found`
);
}
return attribute.value;
}
@@ -54,22 +54,26 @@ function Content({ id }: { id: string }) {
<>
<h2>{group}</h2>
{order.map(({ name, decimals }) => {
const characteristic = characteristics[name];
{order.map((entry) => {
if ("toy" in entry) {
} else {
const characteristic = characteristics[entry.name];
if (characteristic === null) return null;
if (characteristic === null) return null;
let rendered: string | number = characteristic;
let rendered: string | number = characteristic;
if (typeof rendered === "number") {
if (decimals !== undefined) rendered = rendered.toFixed(decimals);
if (typeof rendered === "number") {
if (entry.decimals !== undefined)
rendered = rendered.toFixed(entry.decimals);
}
return (
<p>
{entry.name}: {rendered}
</p>
);
}
return (
<p>
{name}: {rendered}
</p>
);
})}
</>
))}