@energy8platform/shell 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html.cjs.js +9 -5
- package/dist/html.cjs.js.map +1 -1
- package/dist/html.d.ts +5 -2
- package/dist/html.esm.js +9 -5
- package/dist/html.esm.js.map +1 -1
- package/dist/index.cjs.js +9 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.esm.js +9 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/pixi.cjs.js +9 -5
- package/dist/pixi.cjs.js.map +1 -1
- package/dist/pixi.d.ts +5 -2
- package/dist/pixi.esm.js +9 -5
- package/dist/pixi.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/core/format.ts +8 -4
- package/src/core/types.ts +3 -0
- package/src/core/version.ts +1 -1
package/package.json
CHANGED
package/src/core/format.ts
CHANGED
|
@@ -8,15 +8,19 @@ import type { CurrencyConfig } from './types';
|
|
|
8
8
|
* trailing zeros are trimmed down to (but never past) `minDecimals`, so small wins keep their
|
|
9
9
|
* significant digits. Balance / bet / prices stay fixed at `minDecimals`.
|
|
10
10
|
*
|
|
11
|
+
* Separators default to the platform convention — `.` decimal, `,` thousands (`€1,234.50`).
|
|
12
|
+
* A comma decimal is NOT safe as a default: players read "2,50" as 250 and believe they were
|
|
13
|
+
* paid far more than they were. Games that need another convention pass `currency.separator`.
|
|
14
|
+
*
|
|
11
15
|
* Example with `maxDecimals: 4, minDecimals: 2`:
|
|
12
|
-
* fixed → 0.0673 → 0
|
|
13
|
-
* variable → 0.0673 → 0
|
|
16
|
+
* fixed → 0.0673 → 0.07 0.3 → 0.30
|
|
17
|
+
* variable → 0.0673 → 0.0673 0.067 → 0.067 0.3 → 0.30 0 → 0.00
|
|
14
18
|
*/
|
|
15
19
|
export function formatCurrency(value: number, currency: CurrencyConfig, variableDecimals = false): string {
|
|
16
20
|
const maxDecimals = currency.maxDecimals ?? 2;
|
|
17
21
|
const minDecimals = Math.max(0, Math.min(maxDecimals, currency.minDecimals ?? maxDecimals));
|
|
18
|
-
const thousands = currency.separator?.thousands ?? '
|
|
19
|
-
const decimal = currency.separator?.decimal ?? '
|
|
22
|
+
const thousands = currency.separator?.thousands ?? ',';
|
|
23
|
+
const decimal = currency.separator?.decimal ?? '.';
|
|
20
24
|
const safe = Number.isFinite(value) ? value : 0;
|
|
21
25
|
|
|
22
26
|
// fixed callers round at minDecimals; variable callers round at maxDecimals then trim back down.
|
package/src/core/types.ts
CHANGED
|
@@ -20,6 +20,9 @@ export interface CurrencyConfig {
|
|
|
20
20
|
* trimmed down to this many places so small wins keep their significant digits (e.g. 0.0673)
|
|
21
21
|
* while round amounts stay compact (e.g. 0.30). Everything else is shown at exactly this many. */
|
|
22
22
|
minDecimals?: number;
|
|
23
|
+
/** Defaults to the platform convention: `{ thousands: ',', decimal: '.' }` → `€1,234.50`.
|
|
24
|
+
* Override only for a jurisdiction that requires another convention — a comma decimal reads
|
|
25
|
+
* as a thousands group to most players and inflates the perceived payout. */
|
|
23
26
|
separator?: { thousands?: string; decimal?: string };
|
|
24
27
|
}
|
|
25
28
|
|
package/src/core/version.ts
CHANGED