31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import ts from "typescript";
|
|
|
|
const configUrl = new URL("../../../assets/Script/module/Config/ReviveCostConfig.ts", import.meta.url);
|
|
const { outputText } = ts.transpileModule(await readFile(configUrl, "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.ESNext },
|
|
});
|
|
const moduleUrl = "data:text/javascript;base64," + Buffer.from(outputText).toString("base64");
|
|
const { getReviveCoinCost, MAX_REVIVE_COST_STEP } = await import(moduleUrl);
|
|
|
|
test("all players use the settled C curve, capped at 1500", () => {
|
|
assert.deepEqual(
|
|
Array.from({ length: 8 }, (_, count) => getReviveCoinCost(count)),
|
|
[500, 700, 900, 1100, 1300, 1500, 1500, 1500],
|
|
);
|
|
assert.equal(MAX_REVIVE_COST_STEP, 5);
|
|
assert.equal(getReviveCoinCost(100), 1500);
|
|
});
|
|
|
|
test("revive counts are normalized and restarting at zero costs 500", () => {
|
|
for (const count of [undefined, null, "invalid", -1, 0]) {
|
|
assert.equal(getReviveCoinCost(count), 500);
|
|
}
|
|
assert.equal(getReviveCoinCost("2"), 900);
|
|
assert.equal(getReviveCoinCost(1.9), 700);
|
|
assert.equal(getReviveCoinCost(5), 1500);
|
|
assert.equal(getReviveCoinCost(0), 500);
|
|
});
|