Fix energy efficiency

This commit is contained in:
thepaperpilot 2022-12-22 12:06:53 -06:00
parent ab6e04de4b
commit fa556849c1

View file

@ -129,16 +129,16 @@ const factory = createLayer(id, () => {
.map(c => FACTORY_COMPONENTS[c.type]?.energyCost ?? 0) .map(c => FACTORY_COMPONENTS[c.type]?.energyCost ?? 0)
.reduce((a, b) => a + b, 0) .reduce((a, b) => a + b, 0)
); );
const energyEfficiency = computed(() =>
Decimal.div(energyConsumption.value, computedEnergy.value).recip().pow(2).min(1)
);
const tickRate = createSequentialModifier(() => [ const tickRate = createSequentialModifier(() => [
createMultiplicativeModifier(() => ({ createMultiplicativeModifier(() => ({
multiplier: elvesEffect, multiplier: elvesEffect,
description: "Trained Elves" description: "Trained Elves"
})), })),
createMultiplicativeModifier(() => ({ createMultiplicativeModifier(() => ({
multiplier: Decimal.div(energyConsumption.value, computedEnergy.value) multiplier: energyEfficiency,
.recip()
.pow(2)
.min(1),
description: "Energy Consumption", description: "Energy Consumption",
enabled: () => Decimal.gt(energyConsumption.value, computedEnergy.value) enabled: () => Decimal.gt(energyConsumption.value, computedEnergy.value)
})) }))
@ -166,8 +166,8 @@ const factory = createLayer(id, () => {
<div> <div>
{formatWhole(energyConsumption.value)} / {formatWhole(computedEnergy.value)}{" "} {formatWhole(energyConsumption.value)} / {formatWhole(computedEnergy.value)}{" "}
energy used energy used
{Decimal.lt(tickRate.value, 1) ? ( {Decimal.gt(energyConsumption.value, computedEnergy.value) ? (
<>{" (" + format(Decimal.mul(tickRate.value, 100))}% efficiency)</> <>{" (" + format(Decimal.mul(energyEfficiency.value, 100))}% efficiency)</>
) : ( ) : (
"" ""
)} )}