docs: clarify priceOf stock contract (review)

This commit is contained in:
2026-06-12 14:00:57 +00:00
parent 922926cc6d
commit 4ec8cb10f4
+2
View File
@@ -1,6 +1,8 @@
import { GOODS, BASE_PRICE, TYPICAL_STOCK, MAX_STOCK } from './constants.js';
// Deterministic price curve: scarce -> expensive. Clamped to [0.25x, 4x].
// Always pass the raw float planet.stock[good]; never reconstruct price from
// the floored integer stock shown in marketView rows.
export function priceOf(good, stock) {
const ratio = TYPICAL_STOCK / Math.max(stock, 1);
const mult = Math.min(4, Math.max(0.25, ratio));