c1cc70eeb9
Full rebrand: UI display text, package scope (@ai-tycoon/* -> @token-empire/*), localStorage keys, Docker/CI image paths, database names, and documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import type { ObsolescenceState, Era } from '@token-empire/shared';
|
|
import {
|
|
OBSOLESCENCE_BASELINE_GROWTH,
|
|
OBSOLESCENCE_ERA_ACCELERATOR,
|
|
FRESHNESS_DECAY_RATE,
|
|
NEW_MODEL_BOOST_TICKS,
|
|
} from '@token-empire/shared';
|
|
|
|
export function updateObsolescence(
|
|
obs: ObsolescenceState,
|
|
era: Era,
|
|
currentTick: number,
|
|
): ObsolescenceState {
|
|
const accelerator = OBSOLESCENCE_ERA_ACCELERATOR[era];
|
|
const newBaseline = obs.marketQualityBaseline + OBSOLESCENCE_BASELINE_GROWTH * accelerator;
|
|
|
|
const ticksSinceRelease = currentTick - obs.lastModelReleaseTick;
|
|
const freshness = obs.lastModelReleaseTick > 0
|
|
? Math.max(0, 1 - ticksSinceRelease * FRESHNESS_DECAY_RATE)
|
|
: 0;
|
|
|
|
const boostRemaining = Math.max(0, obs.newModelBoostRemaining - 1);
|
|
|
|
return {
|
|
...obs,
|
|
marketQualityBaseline: newBaseline,
|
|
playerModelFreshness: freshness,
|
|
newModelBoostRemaining: boostRemaining,
|
|
};
|
|
}
|
|
|
|
export function onModelDeployed(obs: ObsolescenceState, tick: number): ObsolescenceState {
|
|
return {
|
|
...obs,
|
|
playerModelFreshness: 1.0,
|
|
lastModelReleaseTick: tick,
|
|
newModelBoostRemaining: NEW_MODEL_BOOST_TICKS,
|
|
};
|
|
}
|