feat: More bonus (exponential) and method to list icons needed
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
click,
|
||||
derive,
|
||||
generatorQuote,
|
||||
materialPurchase,
|
||||
setPrice,
|
||||
simulateOffline,
|
||||
upgradeVisible,
|
||||
@@ -311,3 +312,38 @@ test('state survives a serialize / sanitize round trip', () => {
|
||||
assert.equal(back.marketing, 3);
|
||||
});
|
||||
|
||||
|
||||
test('a partial lot can always be bought: material is never out of reach', () => {
|
||||
const s = fresh();
|
||||
s.upgrades = ['stack_1', 'stack_2', 'stack_3', 'stack_4', 'stack_5'];
|
||||
s.endless = { e_stack: 30 }; // a lot far larger than any funds
|
||||
s.generators.gen1 = 5;
|
||||
s.material = 0;
|
||||
s.funds = 50;
|
||||
const d = derive(s, ctx);
|
||||
assert.ok(d.batchCost > 1e6, 'the whole lot is out of reach');
|
||||
const purchase = materialPurchase(s, d);
|
||||
assert.equal(purchase.cost, 50, 'spends what it can');
|
||||
assert.ok(Math.abs(purchase.amount / d.batchSize - 50 / d.batchCost) < 1e-12, 'proportional to the lot price');
|
||||
assert.ok(buyMaterial(s, ctx));
|
||||
assert.equal(s.funds, 0);
|
||||
assert.ok(s.material > 0);
|
||||
assert.equal(buyMaterial(s, ctx), false, 'nothing left to spend');
|
||||
});
|
||||
|
||||
test('a whole lot is bought when affordable', () => {
|
||||
const s = fresh();
|
||||
s.funds = 1e6;
|
||||
const d = derive(s, ctx);
|
||||
assert.deepEqual(materialPurchase(s, d), { amount: d.batchSize, cost: d.batchCost });
|
||||
});
|
||||
|
||||
test('auto-buy still restocks when the lot is out of reach (urgent partial buy)', () => {
|
||||
const s = fresh();
|
||||
s.upgrades = ['auto_buy'];
|
||||
s.endless = { e_stack: 30 };
|
||||
s.funds = 100;
|
||||
s.material = 0;
|
||||
advance(s, ctx, 0.1, () => 0.5);
|
||||
assert.ok(s.material > 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user