29 lines
1.6 KiB
TypeScript
29 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { POLICY_HOME, policyBonuses, policyBoost, targetsOf } from "../src/game/island/data.ts";
|
|
|
|
describe("政策落地:政策和小島的關係", () => {
|
|
it("每種政策對象都有一棟家;長照中心是長輩政策的家", () => {
|
|
expect(POLICY_HOME.old).toBe("care");
|
|
expect(targetsOf("plaza")).toEqual(["客家鄉親", "信眾"]);
|
|
});
|
|
|
|
it("長輩補助:落地+長照中心的長輩區加成合成一列;政策研究院 3 級才算生效", () => {
|
|
const rows = policyBonuses({ target: "old", method: "subsidy" }, { care: 2, library: 1 });
|
|
const care = rows.find((r) => r.building === "care")!;
|
|
expect(care.home).toBe(true);
|
|
expect(care.text).toBe("政策落地 +20%;打在長輩多的區 +16%");
|
|
expect(care.active).toBe(true);
|
|
expect(rows.find((r) => r.building === "library")!.active).toBe(false);
|
|
// 一定吃得到的只有落地 +20%
|
|
expect(policyBoost({ target: "old", method: "subsidy" }, { care: 2, library: 1 })).toBe(20);
|
|
});
|
|
|
|
it("修法、減稅算媒體牌:媒體中心也會加;還沒蓋的寫「蓋了每級 +N%」", () => {
|
|
const rows = policyBonuses({ target: "young", method: "tax_cut" }, { media: 1 });
|
|
expect(rows.map((r) => r.building)).toEqual(["techpark", "media", "library"]);
|
|
expect(rows[0]!.text).toBe("政策落地:蓋了每級 +10%");
|
|
expect(rows[1]!.text).toBe("算媒體牌 +6%");
|
|
expect(policyBoost({ target: "young", method: "tax_cut" }, { media: 1, techpark: 1, library: 3 })).toBe(Math.round((1.1 * 1.06 * 1.15 - 1) * 100));
|
|
});
|
|
});
|