mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: implement some
This commit is contained in:
1 parent
15172e8b33
commit
be4af0bf84
5 files changed
+254
-16
No files matched your search
@@ -206,8 +206,6 @@ export function aggregateStageParameters(
|
|||||||
|
|
||||||
stage0.stage_number = 0;
|
stage0.stage_number = 0;
|
||||||
|
|
||||||
console.log(stages.length);
|
|
||||||
|
|
||||||
stages.forEach((stage) => patch(stage0, stage));
|
stages.forEach((stage) => patch(stage0, stage));
|
||||||
|
|
||||||
return stage0;
|
return stage0;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export type CharacteristicOutput = number | null;
|
|||||||
type Characteristic = (helpers: {
|
type Characteristic = (helpers: {
|
||||||
characteristic: (name: CharacteristicName) => CharacteristicOutput;
|
characteristic: (name: CharacteristicName) => CharacteristicOutput;
|
||||||
attribute: (name: TankAttributeChange_AttributeName) => number;
|
attribute: (name: TankAttributeChange_AttributeName) => number;
|
||||||
|
attributeSafe: (name: TankAttributeChange_AttributeName) => number | null;
|
||||||
shell: (name: ShellUpgrageSingleChange_AttributeName) => number;
|
shell: (name: ShellUpgrageSingleChange_AttributeName) => number;
|
||||||
shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null;
|
shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null;
|
||||||
}) => CharacteristicOutput;
|
}) => CharacteristicOutput;
|
||||||
@@ -123,4 +124,186 @@ export const characteristics = {
|
|||||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_AIMING_TIME
|
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>;
|
} satisfies Record<string, Characteristic>;
|
||||||
@@ -18,7 +18,7 @@ type CharacteristicsOrder = {
|
|||||||
)[];
|
)[];
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
export const characteristicsGroups = [
|
export const characteristicsGroups: CharacteristicsOrder = [
|
||||||
{
|
{
|
||||||
group: "firepower",
|
group: "firepower",
|
||||||
order: [
|
order: [
|
||||||
@@ -40,19 +40,69 @@ export const characteristicsGroups = [
|
|||||||
{ name: "shell_velocity" },
|
{ name: "shell_velocity" },
|
||||||
{ name: "shell_range" },
|
{ name: "shell_range" },
|
||||||
{ name: "shell_capacity" },
|
{ name: "shell_capacity" },
|
||||||
|
|
||||||
{ name: "aim_time" },
|
{ 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",
|
group: "maneuverability",
|
||||||
order: [],
|
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",
|
group: "survivability",
|
||||||
order: [],
|
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",
|
group: "miscellaneous",
|
||||||
order: [],
|
order: [],
|
||||||
},
|
},
|
||||||
] satisfies CharacteristicsOrder;
|
];
|
||||||
@@ -22,18 +22,24 @@ export function computeCharacteristics(
|
|||||||
throw new Error(`${name} not computed yet`);
|
throw new Error(`${name} not computed yet`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function attribute(name: TankAttributeChange_AttributeName) {
|
function attributeSafe(name: TankAttributeChange_AttributeName) {
|
||||||
const attribute = parameters.attributes.find(
|
const attribute = parameters.attributes.find(
|
||||||
(attribute) => attribute.attribute_name === name
|
(attribute) => attribute.attribute_name === name
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!attribute) {
|
return attribute ? attribute.value : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function attribute(name: TankAttributeChange_AttributeName) {
|
||||||
|
const attribute = attributeSafe(name);
|
||||||
|
|
||||||
|
if (attribute === null) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found`
|
`Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return attribute.value;
|
return attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shellSafe(name: ShellUpgrageSingleChange_AttributeName) {
|
function shellSafe(name: ShellUpgrageSingleChange_AttributeName) {
|
||||||
@@ -71,6 +77,7 @@ export function computeCharacteristics(
|
|||||||
const value = characteristics[name]({
|
const value = characteristics[name]({
|
||||||
characteristic,
|
characteristic,
|
||||||
attribute,
|
attribute,
|
||||||
|
attributeSafe,
|
||||||
shell,
|
shell,
|
||||||
shellSafe,
|
shellSafe,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,16 +81,16 @@ function Content({ id }: { id: string }) {
|
|||||||
|
|
||||||
if (characteristic === null) return null;
|
if (characteristic === null) return null;
|
||||||
|
|
||||||
let rendered: string | number = characteristic;
|
let rendered: string | number;
|
||||||
|
|
||||||
if (typeof rendered === "number") {
|
if (Number.isFinite(characteristic)) {
|
||||||
if (rendered === Infinity) {
|
if (entry.decimals === undefined) {
|
||||||
rendered = "∞";
|
rendered = characteristic;
|
||||||
} else {
|
} else {
|
||||||
if (entry.decimals !== undefined) {
|
rendered = characteristic.toFixed(entry.decimals);
|
||||||
rendered = rendered.toFixed(entry.decimals);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
rendered = `${Math.sign(characteristic) === 1 ? "" : "-"}∞`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user