fix: Changing prices and dynamics in revenus
This commit is contained in:
+47
-6
@@ -165,15 +165,56 @@ test('material is costly at first and cheaper relative to the sale price as prod
|
||||
assert.ok(costShare(1e9) < 0.1, 'a small share of revenue late in the game');
|
||||
});
|
||||
|
||||
test('material lots grow with the operation, in doublings', () => {
|
||||
const sizeAt = (total) => {
|
||||
test('material lots follow current output, in doublings', () => {
|
||||
const sizeWith = (gen1) => {
|
||||
const s = fresh();
|
||||
s.totalProduced = total;
|
||||
s.generators.gen1 = gen1;
|
||||
return derive(s, ctx).batchSize;
|
||||
};
|
||||
assert.equal(sizeAt(0), ctx.rules.materialMarket.minBatch);
|
||||
assert.ok(sizeAt(1e6) > sizeAt(1e4));
|
||||
assert.equal(Math.log2(sizeAt(1e6) / ctx.rules.materialMarket.minBatch) % 1, 0);
|
||||
const { minBatch } = ctx.rules.materialMarket;
|
||||
assert.equal(sizeWith(0), minBatch);
|
||||
assert.ok(sizeWith(500) > sizeWith(5));
|
||||
assert.equal(Math.log2(sizeWith(500) / minBatch) % 1, 0);
|
||||
});
|
||||
|
||||
test('stack upgrades multiply the lot, and its price grows in proportion', () => {
|
||||
const lot = (upgrades) => {
|
||||
const s = fresh();
|
||||
s.upgrades = upgrades;
|
||||
s.materialFactor = 1;
|
||||
return derive(s, ctx);
|
||||
};
|
||||
const base = lot([]);
|
||||
const doubled = lot(['stack_1']);
|
||||
const x12 = lot(['stack_1', 'stack_2', 'stack_3']);
|
||||
assert.equal(doubled.batchSize, base.batchSize * 2);
|
||||
assert.equal(x12.batchSize, base.batchSize * 12);
|
||||
assert.ok(Math.abs(doubled.batchCost - base.batchCost * 2) <= 0.01, 'twice the wire costs twice as much');
|
||||
assert.ok(Math.abs(x12.batchCost - base.batchCost * 12) <= 0.06);
|
||||
});
|
||||
|
||||
test('the price PER UNIT of material is unchanged by stack size and keeps falling with scale', () => {
|
||||
const unitPrice = (totalProduced, upgrades) => {
|
||||
const s = fresh();
|
||||
s.totalProduced = totalProduced;
|
||||
s.upgrades = upgrades;
|
||||
s.materialFactor = 1;
|
||||
const d = derive(s, ctx);
|
||||
return d.batchCost / d.batchSize;
|
||||
};
|
||||
const early = unitPrice(0, []);
|
||||
assert.ok(Math.abs(unitPrice(0, ['stack_1', 'stack_2']) - early) < early * 0.01);
|
||||
assert.ok(unitPrice(1e6, ['stack_1', 'stack_2']) < unitPrice(1e4, ['stack_1', 'stack_2']));
|
||||
assert.ok(unitPrice(1e9, []) < early / 5, 'much cheaper per unit late in the game');
|
||||
});
|
||||
|
||||
test('stack upgrades form a chain', () => {
|
||||
const s = fresh();
|
||||
s.totalProduced = 1e9;
|
||||
assert.ok(upgradeVisible(s, ctx.upgradesById.get('stack_1')));
|
||||
assert.equal(upgradeVisible(s, ctx.upgradesById.get('stack_2')), false);
|
||||
s.upgrades = ['stack_1'];
|
||||
assert.ok(upgradeVisible(s, ctx.upgradesById.get('stack_2')));
|
||||
});
|
||||
|
||||
test('the material market is erratic but stays within its bounds', () => {
|
||||
|
||||
Reference in New Issue
Block a user