/** Which colour a side is handed, and that it keeps it. */ import { expect, test } from "bun:test"; import { ENEMY, enemyColours, makeSides, PALETTE } from "../../static/engine/sides.js"; test("a body with no side wears today's enemy colours, and takes no slot", () => { const book = makeSides(); expect(enemyColours({}, book)).toBe(ENEMY); expect(ENEMY).toEqual({ skin: "#d8483f", dot: "#e35d5b", mark: "rgba(235,150,120,0.9)" }); expect(book.size).toBe(0); }); test("sides are handed the palette in the order they are first seen, and keep it", () => { const book = makeSides(); const a = enemyColours({ side: "a" }, book); const b = enemyColours({ side: "b" }, book); const c = enemyColours({ side: "c" }, book); expect([a, b, c]).toEqual([PALETTE[0], PALETTE[1], PALETTE[2]]); // The first side is the enemy red a two-side game already wears. expect(a).toBe(ENEMY); expect(enemyColours({ side: "c" }, book)).toBe(c); expect(enemyColours({ side: "a" }, book)).toBe(a); }); test("the palette is all different, and none of it is a mate, the dead or you", () => { const all = PALETTE.flatMap((p) => [p.skin, p.dot]); expect(new Set(all).size).toBe(all.length); for (const taken of ["#3f9fd6", "#4fb3d9", "#eaeaea", "#555a63", "#4a4e57"]) expect(all).not.toContain(taken); }); test("more sides than colours wrap round rather than fail", () => { const book = makeSides(); for (let i = 0; i < PALETTE.length; i++) enemyColours({ side: `s${i}` }, book); expect(enemyColours({ side: "one more" }, book)).toBe(PALETTE[0]); });