fix: Changing prices and dynamics in revenus

This commit is contained in:
gauvainboiche
2026-10-08 13:21:32 +02:00
parent c98995f310
commit cd6d38899c
17 changed files with 112 additions and 18 deletions
+11 -7
View File
@@ -36,15 +36,19 @@ export function materialUnitPrice(mm, totalProduced) {
}
/**
* What one purchase of material looks like. The lot grows with the operation
* (a share of everything produced so far, or `batchSecondsOfProduction` of
* current output), in doubling steps so the price stays readable.
* `factor` is the market's current noise, `discount` comes from upgrades.
* What one purchase of material looks like.
*
* The lot covers `batchSecondsOfProduction` of current output (in doubling
* steps, never below `minBatch`), times `sizeMultiplier` from the "bigger
* stacks" upgrades. The price of a lot is proportional to its size: a bigger
* stack costs more in total, while the price PER UNIT keeps falling with scale
* (see materialUnitPrice). `factor` is the market's current noise and
* `discount` comes from upgrades. Cost is exact to the cent.
*/
export function materialBatch(mm, totalProduced, rate, factor, discount) {
const basis = Math.max(totalProduced * mm.batchShareOfTotal, rate * mm.batchSecondsOfProduction);
export function materialBatch(mm, totalProduced, rate, factor, discount, sizeMultiplier = 1) {
const basis = rate * mm.batchSecondsOfProduction;
const doublings = Math.max(0, Math.floor(Math.log2(Math.max(1, basis / mm.minBatch))));
const size = mm.minBatch * 2 ** doublings;
const size = mm.minBatch * 2 ** doublings * sizeMultiplier;
const cents = size * materialUnitPrice(mm, totalProduced) * factor * discount;
return { size, cost: Math.max(0.01, Math.round(cents * 100) / 100) };
}