fix: Changing prices and dynamics in revenus
This commit is contained in:
@@ -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) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user