mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 05:06:11 +01:00
feat: rename a bit
This commit is contained in:
1 parent
66eaaef6de
commit
6ce1135835
8 files changed
+104
-59
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import type {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
StageParameters,
|
||||
TankAttributeChange_AttributeName,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import {
|
||||
characteristics,
|
||||
type CharacteristicName,
|
||||
type CharacteristicOutput,
|
||||
} from "./characteristics";
|
||||
|
||||
export function renderCharacteristics(
|
||||
parameters: StageParameters,
|
||||
shellId: number
|
||||
) {
|
||||
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 attribute(name: TankAttributeChange_AttributeName) {
|
||||
const attribute = parameters.attributes.find(
|
||||
(attribute) => attribute.attribute_name === name
|
||||
);
|
||||
|
||||
if (!attribute) throw new Error(`Attribute ${name} not found`);
|
||||
("");
|
||||
|
||||
return attribute.value;
|
||||
}
|
||||
|
||||
function shell(name: ShellUpgrageSingleChange_AttributeName) {
|
||||
const shell = parameters.shells_upgrades.find(
|
||||
(shell) => shell.shell_id === name
|
||||
);
|
||||
|
||||
if (!shell) throw new Error(`Shell ${name} not found`);
|
||||
|
||||
const attribute = shell.changes.find(
|
||||
(change) => change.attribute_name === name
|
||||
);
|
||||
|
||||
if (!attribute) throw new Error(`Shell attribute ${name} not found`);
|
||||
|
||||
return attribute.value;
|
||||
}
|
||||
|
||||
for (const _name in characteristics) {
|
||||
const name = _name as CharacteristicName;
|
||||
const _characteristic = characteristics[name];
|
||||
const value = _characteristic.value({ characteristic, attribute, shell });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user