fix pricing

This commit is contained in:
Nathan 2026-02-19 16:32:41 -05:00
parent ad001bd9ad
commit 144993457a
4 changed files with 13 additions and 13 deletions

View file

@ -8,7 +8,7 @@ import { userBonusesTable } from "../schemas/users";
export const PHI = (1 + Math.sqrt(5)) / 2;
export const MULTIPLIER = 10;
export const SCRAPS_PER_HOUR = PHI * MULTIPLIER;
export const DOLLARS_PER_HOUR = 4;
export const DOLLARS_PER_HOUR = 5;
export const SCRAPS_PER_DOLLAR = SCRAPS_PER_HOUR / DOLLARS_PER_HOUR;
export const TIER_MULTIPLIERS: Record<number, number> = {
@ -93,10 +93,10 @@ export function calculateShopItemPricing(
export function calculateRollCost(
basePrice: number,
effectiveProbability: number,
baseProbability: number,
): number {
// Scales with effective probability so expected spend per win ≈ price always
return Math.max(1, Math.round(basePrice * (effectiveProbability / 100)));
// Roll cost is fixed based on base probability, doesn't change with upgrades
return Math.max(1, Math.round(basePrice * (baseProbability / 100)));
}
export function computeRollThreshold(probability: number): number {

View file

@ -544,10 +544,10 @@ shop.post("/items/:id/try-luck", async ({ params, headers }) => {
100,
);
// Roll cost = price * p/100, so expected spend per win ≈ price always
// Roll cost is fixed based on base probability, doesn't change with upgrades
const rollCost = calculateRollCost(
currentItem.price,
effectiveProbability,
currentItem.baseProbability,
);
// Check if user can afford the roll cost

View file

@ -22,7 +22,7 @@
const PHI = (1 + Math.sqrt(5)) / 2;
const SCRAPS_PER_HOUR = PHI * 10;
const DOLLARS_PER_HOUR = 4;
const DOLLARS_PER_HOUR = 5;
const SCRAPS_PER_DOLLAR = SCRAPS_PER_HOUR / DOLLARS_PER_HOUR;
interface ShopStats {

View file

@ -83,13 +83,13 @@
const PHI = (1 + Math.sqrt(5)) / 2;
const SCRAPS_PER_HOUR = PHI * 10;
const DOLLARS_PER_HOUR = 4;
const DOLLARS_PER_HOUR = 5;
const SCRAPS_PER_DOLLAR = SCRAPS_PER_HOUR / DOLLARS_PER_HOUR;
// Must match backend calculateRollCost exactly
// Backend scales roll cost with effectiveProbability so expected spend ≈ price always
function calculateRollCost(basePrice: number, effectiveProbability: number): number {
return Math.max(1, Math.round(basePrice * (effectiveProbability / 100)));
// Roll cost is fixed based on base probability, doesn't change with upgrades
function calculateRollCost(basePrice: number, baseProbability: number): number {
return Math.max(1, Math.round(basePrice * (baseProbability / 100)));
}
// Must match backend computeRollThreshold exactly
@ -150,8 +150,8 @@
const boostPercent = k * boostAmount;
const effectiveProbability = Math.min(baseProbability + boostPercent, 100);
// Backend: roll cost scales with effectiveProbability
const rollCost = calculateRollCost(price, effectiveProbability);
// Roll cost is fixed at base probability
const rollCost = calculateRollCost(price, baseProbability);
// Cumulative upgrade cost (geometric series)
let upgradeCostCumulative = 0;