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 @@
|
||||
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];
|
||||
}
|
||||
Reference in new issue
Block a user