feat(settings): add emulator-fixed CurrencyType enum
This commit is contained in:
1 parent
8e0ad40c19
commit
edbd5c89ba
6 files changed
+73
No files matched your search
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@atomcms/settings",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.0",
|
||||
"vitest": "^2.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { CurrencyType, currencyLabel } from "./currency-type.js";
|
||||
|
||||
describe("CurrencyType", () => {
|
||||
it("uses the emulator-fixed numeric values", () => {
|
||||
expect(CurrencyType.Credits).toBe(-1);
|
||||
expect(CurrencyType.Duckets).toBe(0);
|
||||
expect(CurrencyType.Diamonds).toBe(5);
|
||||
expect(CurrencyType.Points).toBe(101);
|
||||
});
|
||||
|
||||
it("maps each type to a human label", () => {
|
||||
expect(currencyLabel(CurrencyType.Credits)).toBe("Credits");
|
||||
expect(currencyLabel(CurrencyType.Diamonds)).toBe("Diamonds");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
// Numeric values are dictated by the game emulator and MUST NOT change.
|
||||
export enum CurrencyType {
|
||||
Credits = -1,
|
||||
Duckets = 0,
|
||||
Diamonds = 5,
|
||||
Points = 101,
|
||||
}
|
||||
|
||||
const LABELS: Record<CurrencyType, string> = {
|
||||
[CurrencyType.Credits]: "Credits",
|
||||
[CurrencyType.Duckets]: "Duckets",
|
||||
[CurrencyType.Diamonds]: "Diamonds",
|
||||
[CurrencyType.Points]: "Points",
|
||||
};
|
||||
|
||||
export function currencyLabel(type: CurrencyType): string {
|
||||
return LABELS[type];
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": { "rootDir": "src", "outDir": "dist" },
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
// Local config so Vitest does not walk up into the parent Laravel repo's
|
||||
// vite.config.js (this monorepo is nested inside the Laravel project).
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: "node",
|
||||
},
|
||||
});
|
||||
Generated
+9
@@ -24,6 +24,15 @@ importers:
|
||||
specifier: ^2.1.0
|
||||
version: 2.1.9(@types/[email protected])
|
||||
|
||||
packages/settings:
|
||||
devDependencies:
|
||||
typescript:
|
||||
specifier: ^5.7.0
|
||||
version: 5.9.3
|
||||
vitest:
|
||||
specifier: ^2.1.0
|
||||
version: 2.1.9(@types/[email protected])
|
||||
|
||||
packages:
|
||||
|
||||
'@esbuild/[email protected]':
|
||||
|
||||
Reference in new issue
Block a user