feat: More bonus (exponential) and method to list icons needed

This commit is contained in:
gauvainboiche
2026-10-08 14:20:58 +02:00
parent fc0d5e3ba4
commit a88b8f5f14
25 changed files with 977 additions and 40 deletions
+13 -1
View File
@@ -72,11 +72,23 @@ const APPLY = {
export const EFFECT_TYPES = Object.keys(APPLY);
// Endless upgrades stack without limit, so keep every result finite and sensible.
const CAP = 1e100; // low enough that products of several multipliers stay finite; real play never gets close
const FLOORS = { generatorCost: 0.05, batchDiscount: 0.001 };
function finalize(m) {
const keep = (value) => (Number.isFinite(value) ? Math.min(CAP, value) : CAP);
for (const key of Object.keys(m)) if (typeof m[key] === 'number') m[key] = keep(m[key]);
for (const id of Object.keys(m.generators)) m.generators[id] = keep(m.generators[id]);
for (const [key, floor] of Object.entries(FLOORS)) m[key] = Math.max(floor, m[key]);
return m;
}
/** Fold a list of `{ effect, times }` entries into one set of multipliers. */
export function foldEffects(entries) {
const m = newModifiers();
for (const { effect, times = 1 } of entries) {
if (effect && times > 0) APPLY[effect.type]?.(m, effect, times);
}
return m;
return finalize(m);
}