primordial-soup/engine/catalog.js

230 lines
5.6 KiB
JavaScript

export const COLORS = ["green", "red", "blue", "yellow"];
export const COLOR_NAMES = ["Green", "Coral", "Blue", "Gold"];
export const CELLS = Array.from({ length: 25 }, (_, i) => i).filter(
(i) => ![0, 4, 5, 10, 12, 20].includes(i),
);
export const DIRECTIONS = ["West", "North", "East", "South", "Still"];
export const PHASES = [
"Movement & feeding",
"Environment",
"New genes",
"Cell division",
"Survival",
"Evolution",
];
export const coordinate = (cell) =>
`${"ABCDE"[cell % 5]}${Math.floor(cell / 5) + 1}`;
export function destination(cell, direction) {
const [dx, dy] = [
[-1, 0],
[0, -1],
[1, 0],
[0, 1],
[0, 0],
][direction];
const x = (cell % 5) + dx,
y = Math.floor(cell / 5) + dy,
next = y * 5 + x;
return x >= 0 && x < 5 && y >= 0 && y < 5 && CELLS.includes(next)
? next
: cell;
}
export const adjacent = (cell) =>
[...new Set([0, 1, 2, 3].map((d) => destination(cell, d)))].filter(
(x) => x !== cell,
);
const gene = (id, name, cost, mutation, copies, text, base = []) => ({
id,
name,
cost,
mutation,
copies,
text,
base,
points: base.length ? 2 : id === "ray" ? 0 : 1,
});
export const GENES = [
gene(
"intelligence",
"Intelligence",
2,
3,
[1, 2],
"No special action, but counts as a gene for evolution.",
),
gene(
"movement1",
"Movement I",
3,
2,
[2, 2],
"Roll two dice when swimming and choose either result. Swimming still costs 1 BP.",
),
gene(
"spores",
"Spores",
3,
3,
[1, 1],
"Place new amoebas anywhere without another amoeba of your colour.",
),
gene(
"speed",
"Speed",
4,
3,
[1, 2],
"After swimming, you may swim a second time for free. Roll again, then feed once after both moves. Does not apply to drift.",
),
gene(
"defense",
"Defense",
4,
4,
[1, 1],
"When attacked, spend 1 BP to fight. Each side rolls a die; higher wins, ties are rerolled. A successful defense stops the attack.",
),
gene(
"escape",
"Escape",
4,
4,
[1, 2],
"When attacked, you may swim away for 1 BP using your movement genes. Reaching another space avoids the attack.",
),
gene(
"substitution",
"Substitution",
4,
4,
[1, 1],
"Replace a missing colour by eating one extra cube: two of each of two colours in a four-player game, or four of one colour in a three-player game.",
),
gene(
"ray",
"Ray Protection",
5,
-2,
[1, 2],
"Reduces total mutation sensitivity by 2. Does not count as a gene when scoring evolution.",
),
gene(
"streamline",
"Streamline",
5,
4,
[1, 1],
"Swimming and escaping cost no BP. Dice still determine movement unless you have Movement II.",
),
gene(
"tentacle",
"Tentacle",
5,
4,
[1, 2],
"Carry up to two food cubes when moving with three players, or three cubes with four players. You may take any colour, including your own.",
),
gene(
"holding",
"Holding",
5,
4,
[1, 1],
"You may stay instead of drifting. When another amoeba leaves your space, your amoebas may travel with it for free.",
),
gene(
"longevity",
"Longevity",
5,
5,
[1, 2],
"Your amoebas die with three injuries instead of two during the survival phase.",
),
gene(
"frugality",
"Frugality",
6,
5,
[0, 1],
"Eat one fewer food cube. Still leave two cubes of your own colour after feeding.",
),
gene(
"struggle",
"Struggle for Survival",
6,
4,
[2, 2],
"If you cannot feed, spend 1 BP to attack an amoeba in your space. A successful attack feeds you and leaves one cube of each colour.",
),
gene(
"parasitism",
"Parasitism",
6,
5,
[0, 1],
"Share a space with an opponent who has BP: make them pay 1 BP to eat one fewer food cube. You may use this even when enough food is available.",
),
gene(
"division",
"Division Rate",
6,
5,
[1, 2],
"New amoebas cost 4 BP instead of 6 BP.",
),
gene(
"persistence",
"Persistence",
4,
4,
[1, 2],
"After a failed attack or defense, you may make a second attempt for free. Replaces Speed; it does not keep Speed's extra swim.",
["speed"],
),
gene(
"movement2",
"Movement II",
5,
5,
[1, 2],
"Choose a direction when swimming instead of rolling. Swimming still costs 1 BP unless you also have Streamline.",
["movement1"],
),
gene(
"aggression",
"Aggression",
5,
5,
[1, 1],
"After natural deaths, attack one opponent in the same space for 1 BP, once per round. Still allows attacking instead of starving. Armor converts the survival-phase attack to one injury.",
["struggle"],
),
gene(
"armor",
"Armor",
6,
6,
[1, 1],
"Cannot be eaten by Struggle for Survival. Aggression causes one injury instead of immediate death.",
["defense", "escape"],
),
];
export const GENE = Object.fromEntries(GENES.map((g) => [g.id, g]));
export const populationPoints = (n) => [0, 0, 0, 1, 2, 4, 5, 6][n];
export const genePoints = (n) => Math.min(4, Math.max(0, n - 2));
// Private playtest deck: exact printed card distribution is still awaiting verification.
// Keep this separate from movement rules; see README.md.
export const ENVIRONMENTS = [
{ ozone: 6, direction: 2 },
{ ozone: 7, direction: 0 },
{ ozone: 8, direction: 2 },
{ ozone: 8, direction: 3 },
{ ozone: 9, direction: 2 },
{ ozone: 10, direction: 4 },
{ ozone: 11, direction: 0 },
{ ozone: 12, direction: 0 },
{ ozone: 12, direction: 3 },
{ ozone: 13, direction: 2 },
{ ozone: 14, direction: 0 },
];