Files
AIHostingTycoon/packages/game-engine/src/systems/market/obsolescenceSystem.ts
T
josh c1cc70eeb9
Balance Check / balance-simulation (pull_request) Successful in 38s
Balance Check / multi-run-balance (pull_request) Successful in 13m44s
Rename AI Tycoon to Token Empire across entire codebase
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>
2026-04-27 21:04:07 -04:00

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,
};
}