cool prestige update
This commit is contained in:
+65
-2
@@ -46,6 +46,17 @@ export const api = {
|
||||
body: JSON.stringify({ count }),
|
||||
}),
|
||||
inventory: () => request('/api/inventory'),
|
||||
vaultStake: (inventoryItemIds) =>
|
||||
request('/api/vault/stake', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ inventoryItemIds }),
|
||||
}),
|
||||
vaultUnstake: (inventoryItemIds) =>
|
||||
request('/api/vault/unstake', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ inventoryItemIds }),
|
||||
}),
|
||||
vaultClaim: () => request('/api/vault/claim', { method: 'POST' }),
|
||||
sellInventory: (inventoryItemIds) =>
|
||||
request('/api/inventory/sell', {
|
||||
method: 'POST',
|
||||
@@ -174,8 +185,13 @@ export const api = {
|
||||
},
|
||||
};
|
||||
|
||||
export function formatCredits(cents) {
|
||||
const fixed = (Number(cents) / 100).toFixed(2);
|
||||
/**
|
||||
* Exact credit display (cents → "1 234.56"), for tooltips / confirmations.
|
||||
*/
|
||||
export function formatCreditsExact(cents) {
|
||||
const n = Number(cents);
|
||||
if (!Number.isFinite(n)) return '0.00';
|
||||
const fixed = (n / 100).toFixed(2);
|
||||
const neg = fixed.startsWith('-');
|
||||
const body = neg ? fixed.slice(1) : fixed;
|
||||
const [intPart, dec] = body.split('.');
|
||||
@@ -183,6 +199,53 @@ export function formatCredits(cents) {
|
||||
return `${neg ? '-' : ''}${grouped}.${dec}`;
|
||||
}
|
||||
|
||||
/** Alphabet suffixes after T: aa, ab, … az, ba, … (each step ×1000). */
|
||||
function alphabetSuffix(index) {
|
||||
let num = Math.max(0, Math.floor(index));
|
||||
let result = '';
|
||||
do {
|
||||
result = String.fromCharCode(97 + (num % 26)) + result;
|
||||
num = Math.floor(num / 26);
|
||||
} while (num > 0);
|
||||
while (result.length < 2) result = `a${result}`;
|
||||
return result;
|
||||
}
|
||||
|
||||
function tierSuffix(tier) {
|
||||
if (tier <= 0) return '';
|
||||
if (tier === 1) return 'K';
|
||||
if (tier === 2) return 'M';
|
||||
if (tier === 3) return 'B';
|
||||
if (tier === 4) return 'T';
|
||||
return alphabetSuffix(tier - 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compact credit display for UI readability.
|
||||
* K / M / B / T, then aa, ab, … (×1000 each). Input is cents.
|
||||
*/
|
||||
export function formatCredits(cents) {
|
||||
const n = Number(cents);
|
||||
if (!Number.isFinite(n)) return '0.00';
|
||||
const neg = n < 0;
|
||||
const credits = Math.abs(n) / 100;
|
||||
|
||||
if (credits < 1000) {
|
||||
return `${neg ? '-' : ''}${credits.toFixed(2)}`;
|
||||
}
|
||||
|
||||
let tier = 0;
|
||||
let scaled = credits;
|
||||
while (scaled >= 1000 && tier < 1000) {
|
||||
scaled /= 1000;
|
||||
tier += 1;
|
||||
}
|
||||
|
||||
const suffix = tierSuffix(tier);
|
||||
const shown = String(Number(scaled.toFixed(2)));
|
||||
return `${neg ? '-' : ''}${shown}${suffix}`;
|
||||
}
|
||||
|
||||
export function formatChance(pct) {
|
||||
return `${Number(pct || 0).toFixed(1)}%`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user