feat: Making the game harder to 'beat'
This commit is contained in:
@@ -5,11 +5,27 @@
|
||||
import { modifiersFor } from './modifiers.js';
|
||||
import { createState, META_KEYS } from './state.js';
|
||||
|
||||
/** Points a restart would grant right now (0 until the run is big enough). */
|
||||
/**
|
||||
* How many points a lifetime production deserves in total. Diminishing returns
|
||||
* (a power below 1) on EVERYTHING ever produced, not on a single run: each
|
||||
* further point needs far more production than the last, so restarting more and
|
||||
* more often cannot snowball.
|
||||
*/
|
||||
export function pointsFor(lifetimeProduced, ctx, mods) {
|
||||
const { threshold, exponent } = ctx.rules.legacy;
|
||||
if (!(lifetimeProduced >= threshold)) return 0;
|
||||
return Math.floor((lifetimeProduced / threshold) ** exponent * mods.legacyGain);
|
||||
}
|
||||
|
||||
/** Lifetime production at which the next point is earned (ignoring bonuses to point gains). */
|
||||
export function nextPointAt(state, ctx) {
|
||||
const { threshold, exponent } = ctx.rules.legacy;
|
||||
return threshold * (state.legacy.earned + 1) ** (1 / exponent);
|
||||
}
|
||||
|
||||
/** Points a restart would grant right now (0 until the next point is within reach). */
|
||||
export function legacyGain(state, ctx, mods) {
|
||||
const { threshold } = ctx.rules.legacy;
|
||||
if (state.totalProduced < threshold) return 0;
|
||||
return Math.floor(Math.sqrt(state.totalProduced / threshold) * mods.legacyGain);
|
||||
return Math.max(0, pointsFor(state.lifetimeProduced, ctx, mods) - state.legacy.earned);
|
||||
}
|
||||
|
||||
export function perkLevel(state, perk) {
|
||||
|
||||
Reference in New Issue
Block a user