Explain game flow and clarify building cards and action journal
This commit is contained in:
parent
274d5c0d1f
commit
6cbd0c8b9a
7 changed files with 848 additions and 101 deletions
|
|
@ -1011,7 +1011,7 @@ export function move(state, m, p) {
|
|||
const s = clone(state),
|
||||
t = s.tasks[0],
|
||||
a = s.players[p],
|
||||
extra = {};
|
||||
extra = { phase: t.kind };
|
||||
const custom = {
|
||||
assign: "assign",
|
||||
produce: "produce",
|
||||
|
|
@ -1028,15 +1028,28 @@ export function move(state, m, p) {
|
|||
m.decline.every((id) => optionalPoints(s, p, m).includes(id)),
|
||||
);
|
||||
} else assert(legal(s, p).some((x) => sameMove(x, m)));
|
||||
if (m.target)
|
||||
extra.targetId =
|
||||
m.target === "reserve" ? "reserve" : tileRef(a, m.target).id;
|
||||
if (Number.isInteger(m.estate)) extra.estateId = a.estates[m.estate]?.id;
|
||||
const declined = (id) => m.decline?.includes(id);
|
||||
if (t.kind === "produce" && ["produce", "pass"].includes(m.type)) {
|
||||
if (active(a, "chapel")) {
|
||||
if (citizen(a, "chapel")) {
|
||||
if (!declined("chapel")) vp(s, p, 1);
|
||||
} else a.coins++;
|
||||
if (!declined("chapel")) {
|
||||
vp(s, p, 1);
|
||||
extra.vp = 1;
|
||||
}
|
||||
} else {
|
||||
a.coins++;
|
||||
extra.coins = 1;
|
||||
}
|
||||
}
|
||||
if (active(a, "tailorShop")) {
|
||||
const coins = Math.min(citizens(a), s.options.tailorLimit ? 3 : Infinity);
|
||||
a.coins += coins;
|
||||
extra.coins = (extra.coins ?? 0) + coins;
|
||||
}
|
||||
if (active(a, "tailorShop"))
|
||||
a.coins += Math.min(citizens(a), s.options.tailorLimit ? 3 : Infinity);
|
||||
}
|
||||
const next = () => s.tasks.shift();
|
||||
switch (m.type) {
|
||||
|
|
@ -1066,6 +1079,7 @@ export function move(state, m, p) {
|
|||
if (m.type === "hacienda") next();
|
||||
else {
|
||||
a.coins--;
|
||||
extra.coins = -1;
|
||||
t.zoneUsed = true;
|
||||
}
|
||||
const id = drawEstate(s);
|
||||
|
|
@ -1090,6 +1104,7 @@ export function move(state, m, p) {
|
|||
assert(gainPerson(s, p, "w", true));
|
||||
a.reserve.w--;
|
||||
a.buildings[t.building].w++;
|
||||
extra.targetId = a.buildings[t.building].id;
|
||||
next();
|
||||
break;
|
||||
case "park":
|
||||
|
|
@ -1101,11 +1116,13 @@ export function move(state, m, p) {
|
|||
if (m.type === "park") next();
|
||||
else {
|
||||
a.coins++;
|
||||
extra.coins = 1;
|
||||
t.zoneUsed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "villa":
|
||||
extra.kind = s.citizenSupply ? "c" : "w";
|
||||
assert(gainPerson(s, p, s.citizenSupply ? "c" : "w"));
|
||||
next();
|
||||
break;
|
||||
|
|
@ -1159,6 +1176,10 @@ export function move(state, m, p) {
|
|||
Object.assign(x, { w: m[key][i].w, c: m[key][i].c }),
|
||||
);
|
||||
a.reserve = { w: availableW - nw, c: availableC - nc };
|
||||
extra.allocation = [...a.estates, ...a.buildings]
|
||||
.filter((x) => x.w + x.c > 0)
|
||||
.map(({ id, w, c }) => ({ id, w, c }));
|
||||
extra.reserve = { ...a.reserve };
|
||||
next();
|
||||
break;
|
||||
}
|
||||
|
|
@ -1173,10 +1194,12 @@ export function move(state, m, p) {
|
|||
break;
|
||||
case "parkReward":
|
||||
vp(s, p, 2);
|
||||
extra.vp = 2;
|
||||
next();
|
||||
break;
|
||||
case "assembly":
|
||||
vp(s, p, sum(GOODS.map((g) => Math.floor(a.goods[g] / 2))));
|
||||
extra.vp = sum(GOODS.map((g) => Math.floor(a.goods[g] / 2)));
|
||||
vp(s, p, extra.vp);
|
||||
next();
|
||||
break;
|
||||
case "build": {
|
||||
|
|
@ -1200,8 +1223,10 @@ export function move(state, m, p) {
|
|||
s.market[m.id]--;
|
||||
const b = { id: m.id, w: 0, c: 0 };
|
||||
a.buildings.push(b);
|
||||
if (church && !declined("church"))
|
||||
vp(s, p, B[m.id].size === 2 ? 2 : B[m.id].vp >= 2 ? 1 : 0);
|
||||
if (church && !declined("church")) {
|
||||
extra.vp = B[m.id].size === 2 ? 2 : B[m.id].vp >= 2 ? 1 : 0;
|
||||
vp(s, p, extra.vp);
|
||||
}
|
||||
if (citySize(a) === 12) s.endReason ??= "city";
|
||||
next();
|
||||
if (school)
|
||||
|
|
@ -1256,6 +1281,7 @@ export function move(state, m, p) {
|
|||
a.goods[m.good]--;
|
||||
s.supply[m.good]++;
|
||||
vp(s, p, 1);
|
||||
extra.vp = 1;
|
||||
t.used.push(m.good);
|
||||
if (--t.remaining === 0) next();
|
||||
break;
|
||||
|
|
@ -1286,6 +1312,8 @@ export function move(state, m, p) {
|
|||
points = cargo[m.good];
|
||||
full = ship.amount === ship.capacity;
|
||||
capacity = ship.capacity;
|
||||
extra.shipCapacity = capacity;
|
||||
extra.shipLoad = ship.amount;
|
||||
}
|
||||
for (const g of GOODS) {
|
||||
a.goods[g] -= cargo[g];
|
||||
|
|
@ -1299,7 +1327,10 @@ export function move(state, m, p) {
|
|||
active(a, "publishingHouse") && !declined("publishingHouse") ? 2 : 1;
|
||||
}
|
||||
vp(s, p, points);
|
||||
if (active(a, "lighthouse")) a.coins++;
|
||||
if (active(a, "lighthouse")) {
|
||||
a.coins++;
|
||||
extra.coins = 1;
|
||||
}
|
||||
extra.goods = cargo;
|
||||
extra.vp = points;
|
||||
t.p = (p + 1) % s.players.length;
|
||||
|
|
@ -1340,6 +1371,8 @@ export function move(state, m, p) {
|
|||
ship.amount > 0,
|
||||
);
|
||||
const good = ship.good;
|
||||
extra.good = good;
|
||||
extra.shipCapacity = ship.capacity;
|
||||
a.goods[good] += m.amount;
|
||||
s.supply[good] += ship.amount - m.amount;
|
||||
ship.good = null;
|
||||
|
|
@ -1348,7 +1381,8 @@ export function move(state, m, p) {
|
|||
break;
|
||||
}
|
||||
case "plunder":
|
||||
vp(s, p, s.trade.length);
|
||||
extra.vp = s.trade.length;
|
||||
vp(s, p, extra.vp);
|
||||
for (const g of s.trade) s.supply[g]++;
|
||||
s.trade = [];
|
||||
next();
|
||||
|
|
@ -1372,6 +1406,7 @@ export function move(state, m, p) {
|
|||
break;
|
||||
case "capture":
|
||||
s.captured = { id: m.id, p };
|
||||
extra.coins = s.roles.find((r) => r.id === m.id).coins;
|
||||
a.coins += s.roles.find((r) => r.id === m.id).coins;
|
||||
s.roles.find((r) => r.id === m.id).coins = 0;
|
||||
next();
|
||||
|
|
|
|||
82
test/journal.test.js
Normal file
82
test/journal.test.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as E from "../engine/index.js";
|
||||
import { RELEASE } from "../release-config.js";
|
||||
import { journalContent } from "../viewer/journal.js";
|
||||
import { translator } from "../viewer/i18n.js";
|
||||
const text = (html) => html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ");
|
||||
|
||||
test("preview setup is explained once, while real player draft decisions stay visible", () => {
|
||||
let state = E.init(3, RELEASE.expansions, RELEASE.options, "journal");
|
||||
while (state.tasks[0].kind === "draft") state = E.moveAI(state);
|
||||
const fr = translator("fr");
|
||||
const preview = text(journalContent(state, fr, { automatedSetup: true }));
|
||||
assert.match(preview, /marché des bâtiments a été préparé automatiquement/);
|
||||
assert.match(preview, /Aucun coup joué/);
|
||||
assert.doesNotMatch(preview, /Ajout au marché commun/);
|
||||
const hosted = text(journalContent(state, fr));
|
||||
assert.match(hosted, /Ajout au marché commun/);
|
||||
assert.doesNotMatch(hosted, /automatiquement|Aucun coup joué/);
|
||||
for (const event of state.events.filter((e) => e.type === "draft")) {
|
||||
assert.ok(hosted.includes(fr(event.id)));
|
||||
}
|
||||
});
|
||||
|
||||
test("journal tells what was sold, earned, built, shipped and lost in both languages", () => {
|
||||
const state = {
|
||||
players: [{ name: '<img src=x onerror="alert(1)">' }],
|
||||
events: [
|
||||
{ type: "round", round: 1 },
|
||||
{ type: "role", p: 0, id: "trader", coins: 2 },
|
||||
{ type: "trade", p: 0, good: "coffee", coins: 5 },
|
||||
{ type: "build", p: 0, id: "smallSugar", coins: -1 },
|
||||
{
|
||||
type: "ship",
|
||||
p: 0,
|
||||
goods: { sugar: 3 },
|
||||
vp: 4,
|
||||
shipCapacity: 4,
|
||||
shipLoad: 3,
|
||||
},
|
||||
{ type: "store", p: 0, goods: { coffee: 1 }, lost: { corn: 2 } },
|
||||
],
|
||||
};
|
||||
for (const locale of ["en", "fr"]) {
|
||||
const t = translator(locale);
|
||||
const html = journalContent(state, t);
|
||||
const log = text(html);
|
||||
assert.ok(log.includes(t("smallSugar")));
|
||||
assert.ok(log.includes(t("journalTrade")));
|
||||
assert.ok(log.includes(t("journalLost")));
|
||||
assert.match(html, new RegExp(`title="${t("coffee")}"`));
|
||||
assert.match(log, /\+5/);
|
||||
assert.match(log, /-1/);
|
||||
assert.match(log, /3\/4/);
|
||||
assert.match(log, /\+4/);
|
||||
assert.ok(!html.includes("<img"));
|
||||
assert.ok(html.includes("<img"));
|
||||
}
|
||||
});
|
||||
|
||||
test("worker allocation logs retain destinations even if estates change later", () => {
|
||||
let state = E.init(3, [], {}, "allocation");
|
||||
state.players[0].estates = [{ id: "sugar", w: 0, c: 0 }];
|
||||
state.players[0].buildings = [{ id: "smallSugar", w: 0, c: 0 }];
|
||||
state.players[0].reserve = { w: 2, c: 0 };
|
||||
state.role = "recruiter";
|
||||
state.tasks = [{ kind: "assign", p: 0 }];
|
||||
state = E.move(
|
||||
state,
|
||||
{ type: "assign", estates: [{ w: 1, c: 0 }], buildings: [{ w: 1, c: 0 }] },
|
||||
0,
|
||||
);
|
||||
const event = state.events.find((e) => e.type === "assign");
|
||||
assert.deepEqual(
|
||||
event.allocation.map((x) => x.id),
|
||||
["sugar", "smallSugar"],
|
||||
);
|
||||
state.players[0].estates = [];
|
||||
const log = text(journalContent(state, translator("fr")));
|
||||
assert.match(log, /Sucre/);
|
||||
assert.match(log, /Petite sucrerie/);
|
||||
});
|
||||
200
viewer/i18n.js
200
viewer/i18n.js
|
|
@ -87,7 +87,7 @@ const labels = {
|
|||
round: ["Round", "Manche"],
|
||||
governor: ["Governor", "Gouverneur"],
|
||||
you: ["You", "Vous"],
|
||||
rules: ["Rules", "Règles"],
|
||||
rules: ["How to play", "Comment jouer"],
|
||||
journal: ["Journal", "Journal"],
|
||||
chat: ["Chat", "Discussion"],
|
||||
close: ["Close", "Fermer"],
|
||||
|
|
@ -195,21 +195,197 @@ const labels = {
|
|||
error: ["Unable to play this move", "Ce coup n’a pas pu être joué"],
|
||||
inspect: ["Details", "Détails"],
|
||||
schoolWorker: ["Include the School worker", "Placer l’ouvrier de l’école"],
|
||||
ruleGoalTitle: [
|
||||
"Build an economy, earn points",
|
||||
"Développez votre économie, gagnez des points",
|
||||
],
|
||||
ruleGoal: [
|
||||
"Win with the most VP: ship goods and develop your city. Coins pay for buildings; goods can be sold for coins or shipped for points.",
|
||||
"Gagnez avec le plus de PV en expédiant des marchandises et en développant votre ville. Les pièces financent les bâtiments ; les marchandises se vendent contre des pièces ou s’expédient contre des points.",
|
||||
],
|
||||
ruleRoundTitle: ["How a round works", "Comment se déroule une manche"],
|
||||
ruleChooseTitle: ["Choose a role", "Choisir un rôle"],
|
||||
ruleChoose: [
|
||||
"The Governor chooses an available role and takes its coins. That role becomes the next phase; there is no fixed role order.",
|
||||
"Le Gouverneur choisit un rôle disponible et prend ses pièces. Ce rôle devient la prochaine phase ; aucun ordre n’est imposé.",
|
||||
],
|
||||
ruleFollowTitle: ["Everyone takes that action", "Chacun joue cette action"],
|
||||
ruleFollow: [
|
||||
"The chooser acts first and gets the privilege (for example, Builder: −1 coin), then everyone follows clockwise with the same action.",
|
||||
"Le joueur qui l’a choisi agit d’abord et reçoit son privilège (par exemple, Bâtisseur : −1 pièce), puis chacun joue la même action dans l’ordre du tour.",
|
||||
],
|
||||
ruleNextTitle: ["The next player chooses", "Le joueur suivant choisit"],
|
||||
ruleNext: [
|
||||
"After the phase, the next player chooses a different role. Repeat until everyone has chosen once. Used roles stay unavailable this round.",
|
||||
"Après la phase, le joueur suivant choisit un autre rôle. Continuez jusqu’à ce que chacun ait choisi une fois. Les rôles utilisés restent indisponibles cette manche.",
|
||||
],
|
||||
ruleNextTwo: [
|
||||
"After each phase, alternate choosing different roles until you have each chosen three. Used roles stay unavailable this round.",
|
||||
"Après chaque phase, choisissez alternativement un autre rôle, jusqu’à trois choix chacun. Les rôles utilisés restent indisponibles cette manche.",
|
||||
],
|
||||
ruleResetTitle: ["Prepare the next round", "Préparer la manche suivante"],
|
||||
ruleReset: [
|
||||
"Add 1 coin to each unchosen role, return the chosen roles, and pass the Governor to the next player.",
|
||||
"Ajoutez 1 pièce sur chaque rôle non choisi, rendez les rôles choisis, puis passez le Gouverneur au joueur suivant.",
|
||||
],
|
||||
ruleSmugglerCoin: [
|
||||
"The Smuggler never accumulates coins.",
|
||||
"Le Contrebandier n’accumule jamais de pièces.",
|
||||
],
|
||||
ruleOptional: [
|
||||
"Actions and privileges are optional, except mandatory shipping. Smuggler and Adventurer, when present, only let their chooser act.",
|
||||
"Les actions et privilèges sont facultatifs, sauf le chargement obligatoire. Le Contrebandier et l’Aventurier, s’ils sont présents, ne font agir que celui qui les choisit.",
|
||||
],
|
||||
ruleOptionalBase: [
|
||||
"You can decline an action or privilege, except mandatory shipping.",
|
||||
"Vous pouvez renoncer à une action ou à un privilège, sauf au chargement obligatoire.",
|
||||
],
|
||||
ruleProductionTitle: ["From an estate to a crate", "Du domaine à la caisse"],
|
||||
ruleProductionIntro: [
|
||||
"Build this chain through the roles chosen by you or your opponents:",
|
||||
"Construisez cette chaîne grâce aux rôles choisis par vous ou vos adversaires :",
|
||||
],
|
||||
rulePlantStep: ["Take an estate", "Prendre un domaine"],
|
||||
ruleBuildStep: ["Buy a building", "Acheter un bâtiment"],
|
||||
ruleRecruitStep: ["Assign workers", "Affecter les ouvriers"],
|
||||
ruleProduceStep: ["Produce crates", "Produire des caisses"],
|
||||
ruleProduction: [
|
||||
"Example: an occupied Sugar estate + an occupied sugar-mill slot produce 1 sugar crate during Craftsman. Corn needs no building. Empty tiles neither produce nor activate effects.",
|
||||
"Exemple : un domaine de sucre occupé + une case occupée dans une sucrerie produisent 1 caisse à l’Artisan. Le maïs n’a pas besoin de bâtiment. Sans ouvrier, ni production ni effet.",
|
||||
],
|
||||
ruleActivation: [
|
||||
"Rearrange all your workers during Recruiter. Occupied quarries discount construction, within the building’s limit.",
|
||||
"Réaffectez tous vos ouvriers au Recruteur. Les carrières occupées réduisent le prix des constructions, dans la limite du bâtiment.",
|
||||
],
|
||||
ruleGoodsTitle: [
|
||||
"Sell for coins, ship for points",
|
||||
"Vendre pour des pièces, expédier pour des PV",
|
||||
],
|
||||
ruleSellTitle: ["Trader → coins", "Marchand → pièces"],
|
||||
ruleSell: [
|
||||
"Sell 1 crate per player. The market has 4 spaces, normally one crate per type. It empties at phase end only if full.",
|
||||
"Vendez 1 caisse par joueur. Le marché a 4 places, normalement une caisse par type. Il se vide en fin de phase uniquement s’il est plein.",
|
||||
],
|
||||
ruleShipTitle: ["Captain → VP", "Capitaine → PV"],
|
||||
ruleShip: [
|
||||
"Take turns loading one type for 1 VP per crate. Loading is mandatory when possible: use the ship accepting the most of your chosen type. Repeat until nobody can load.",
|
||||
"Chargez chacun votre tour un type, pour 1 PV par caisse. C’est obligatoire si possible : utilisez le bateau acceptant le plus de caisses du type choisi. Répétez jusqu’à ne plus pouvoir charger.",
|
||||
],
|
||||
ruleShipLimits: [
|
||||
"One type per ship; no type on two public ships. After loading, keep 1 crate in total (more with storage buildings) and discard the rest. Full ships then empty; the others keep their cargo.",
|
||||
"Un type par bateau, sans le répartir sur deux bateaux publics. Après les chargements, gardez 1 caisse au total (davantage avec des bâtiments de stockage) et défaussez le reste. Les bateaux pleins se vident ensuite ; les autres gardent leur cargaison.",
|
||||
],
|
||||
ruleTimingTitle: ["Timing matters", "Le bon moment compte"],
|
||||
ruleTiming: [
|
||||
"Choosing a role helps your opponents too. Check who can produce, sell or fill a ship before you.",
|
||||
"Choisir un rôle aide aussi vos adversaires. Regardez qui peut produire, vendre ou remplir un bateau avant vous.",
|
||||
],
|
||||
ruleEditionTitle: ["Additional mechanics", "Mécanismes supplémentaires"],
|
||||
ruleDraft: [
|
||||
"Initial building selection creates a shared market, not personal purchases. Tap a building for its price and effect.",
|
||||
"Le choix initial des bâtiments compose le marché commun ; ce ne sont pas des achats personnels. Touchez un bâtiment pour lire son prix et son effet.",
|
||||
],
|
||||
ruleDetails: [
|
||||
"Tap a building to read its effect and price.",
|
||||
"Touchez un bâtiment pour consulter son effet et son prix.",
|
||||
],
|
||||
ruleCitizens: [
|
||||
"Citizens fill worker slots and score 1 VP each. Some building effects depend on whether a worker or citizen occupies them.",
|
||||
"Les citoyens occupent les cases d’ouvriers et valent chacun 1 PV. Certains effets changent selon que l’occupant est un ouvrier ou un citoyen.",
|
||||
],
|
||||
ruleSmuggler: [
|
||||
"Raid a ship, plunder the market, poach workers or capture a role. A captured role gives 3 coins if chosen by someone else; otherwise you play it at round end. Another player must choose Smuggler before you can choose it again.",
|
||||
"Pillez un bateau ou le marché, débauchez des ouvriers ou capturez un rôle. Ce dernier rapporte 3 pièces si quelqu’un le choisit ; sinon, vous le jouez en fin de manche. Un autre joueur doit prendre le Contrebandier avant que vous puissiez le reprendre.",
|
||||
],
|
||||
ruleAdventurer: [
|
||||
"Only the chooser gains 1 coin, plus the coins already on this role.",
|
||||
"Seul le joueur qui le choisit gagne 1 pièce, en plus des pièces déjà posées sur ce rôle.",
|
||||
],
|
||||
ruleFestival: [
|
||||
"The first player to fulfill each shared objective earns its reward automatically. Tap it for the exact condition and reward.",
|
||||
"Le premier à remplir chaque objectif commun reçoit sa récompense automatiquement. Touchez-le pour voir sa condition et son gain.",
|
||||
],
|
||||
ruleEndTitle: ["End of the game", "Fin de la partie"],
|
||||
ruleEnd: [
|
||||
"Finish the current round when a city fills, the VP supply runs out, or the work register cannot be refilled. Worker shortage does not end a Citizens game.",
|
||||
"Terminez la manche lorsqu’une ville est pleine, que les PV sont épuisés ou que le registre ne peut plus être rempli. Avec les Citoyens, le manque d’ouvriers ne termine pas la partie.",
|
||||
"Finish the current round when a city fills its 12 spaces or the VP token supply runs out.",
|
||||
"Terminez la manche en cours lorsqu’une ville remplit ses 12 cases ou que la réserve de jetons PV est épuisée.",
|
||||
],
|
||||
ruleFlow: [
|
||||
"The Governor chooses first. Pick a role: everyone performs its action, starting with you, and you receive its privilege. Each player chooses once per round (three times with two players). Unchosen roles gain a coin; the Governor moves clockwise.",
|
||||
"Le Gouverneur choisit en premier. Choisissez un rôle : chacun en joue l’action en commençant par vous, et vous recevez son privilège. Chacun choisit un rôle par manche (trois à deux joueurs). Les rôles non choisis gagnent une pièce ; le Gouverneur passe au suivant.",
|
||||
ruleEndWorkers: [
|
||||
"The game also ends if the work register cannot be refilled after Recruiter.",
|
||||
"La partie se termine aussi si le registre d’ouvriers ne peut plus être rempli après le Recruteur.",
|
||||
],
|
||||
ruleShipping: [
|
||||
"You must load when a public ship can accept your goods. Choose one type and load as much as possible. A type cannot occupy two public ships. Only full ships leave at the end of the phase.",
|
||||
"Vous devez charger si un bateau public accepte vos marchandises. Choisissez un type et chargez-en le maximum. Un type ne peut occuper deux bateaux publics. Seuls les bateaux pleins partent en fin de phase.",
|
||||
ruleEndCitizens: [
|
||||
"With Citizens, worker shortage does not end the game.",
|
||||
"Avec les Citoyens, le manque d’ouvriers ne déclenche pas la fin de partie.",
|
||||
],
|
||||
ruleWorkers: [
|
||||
"Workers activate estates and building effects. Non-corn goods require a worker on an estate and one in the matching production building. Reassign everyone during the Recruiter phase; citizens also score 1 VP each.",
|
||||
"Les ouvriers activent les domaines et les bâtiments. Hors maïs, chaque caisse exige un ouvrier sur un domaine et un dans le bâtiment de production correspondant. Réaffectez-les au Recruteur ; chaque citoyen rapporte aussi 1 PV.",
|
||||
ruleScore: [
|
||||
"Score your VP tokens, printed building points (even if empty), and occupied buildings’ endgame bonuses. Ties: most coins + remaining crates.",
|
||||
"Comptez vos jetons PV, les points imprimés des bâtiments (même vides) et les bonus finaux des bâtiments occupés. Égalité : le plus de pièces + caisses restantes.",
|
||||
],
|
||||
ruleScoreCitizens: [
|
||||
"Add 1 VP per citizen you own.",
|
||||
"Ajoutez 1 PV par citoyen que vous possédez.",
|
||||
],
|
||||
shortVP: ["VP", "PV"],
|
||||
stockAvailableOne: ["available", "disponible"],
|
||||
stockAvailable: ["available", "disponibles"],
|
||||
soldOut: ["Sold out", "Épuisé"],
|
||||
workerSpaces: ["Worker slots", "Places d’ouvriers"],
|
||||
citySpaces: ["City spaces", "Cases de ville"],
|
||||
twoCitySpaces: ["2 city spaces", "2 cases de ville"],
|
||||
printedPoints: ["Points at game end", "Points en fin de partie"],
|
||||
journalSetup: ["Setup", "Mise en place"],
|
||||
journalPreviewSetup: [
|
||||
"The building market was prepared automatically for this preview.",
|
||||
"Le marché des bâtiments a été préparé automatiquement pour cet aperçu.",
|
||||
],
|
||||
journalEmpty: ["No moves played yet.", "Aucun coup joué pour le moment."],
|
||||
journalDraft: ["Adds to the shared market:", "Ajout au marché commun :"],
|
||||
journalChooses: ["Chosen role:", "Rôle choisi :"],
|
||||
journalGains: ["Gained", "Gain :"],
|
||||
journalEstate: ["Estate taken:", "Domaine pris :"],
|
||||
journalQuarry: ["Quarry taken:", "Carrière prise :"],
|
||||
journalForest: ["Forest planted", "Forêt plantée :"],
|
||||
journalBuild: ["Built", "Construction :"],
|
||||
journalProduce: ["Produced", "Production :"],
|
||||
journalNothing: ["Produced no goods", "Aucune production"],
|
||||
journalBonus: ["Bonus crate:", "Caisse bonus :"],
|
||||
journalTrade: ["Sold", "Vente :"],
|
||||
journalShip: ["Shipped", "Expédition :"],
|
||||
journalStore: ["Kept", "Caisses conservées :"],
|
||||
journalLost: ["Discarded", "Caisses perdues :"],
|
||||
journalNoGoods: ["no crates", "aucune caisse"],
|
||||
journalAssign: ["Worker allocation:", "Affectation des ouvriers :"],
|
||||
journalRecruit: ["Recruited", "Recrutement :"],
|
||||
journalPass: ["Passed", "Passe"],
|
||||
journalFestival: ["Completed", "Objectif remporté :"],
|
||||
journalRaid: ["Ship raided, crates taken:", "Bateau pillé, caisses prises :"],
|
||||
journalPlunder: [
|
||||
"Trading house plundered and emptied",
|
||||
"Marché pillé et vidé",
|
||||
],
|
||||
journalCapture: ["Captured role:", "Rôle capturé :"],
|
||||
journalPoach: [
|
||||
"Poaching surplus workers",
|
||||
"Débauchage des ouvriers excédentaires",
|
||||
],
|
||||
journalDiscardWorker: [
|
||||
"Removed from the work register:",
|
||||
"Retrait du registre :",
|
||||
],
|
||||
journalMoveWorker: ["Moved from the Bohío:", "Déplacement depuis le Bohío :"],
|
||||
journalRemove: ["Removed", "Retrait :"],
|
||||
journalDraw: ["Extra estate drawn", "Domaine supplémentaire pioché"],
|
||||
journalBuyEstate: ["Random estate bought", "Domaine pioché acheté"],
|
||||
journalShipCapacity: ["ship capacity", "capacité du bateau"],
|
||||
journalEndCity: ["A city is full.", "Une ville est pleine."],
|
||||
journalEndPoints: [
|
||||
"The VP supply is depleted.",
|
||||
"La réserve de PV est épuisée.",
|
||||
],
|
||||
journalEndWorkers: [
|
||||
"The work register could not be refilled.",
|
||||
"Le registre d’ouvriers n’a pas pu être rempli.",
|
||||
],
|
||||
discardWorker: [
|
||||
"Discard surplus workers",
|
||||
|
|
|
|||
159
viewer/journal.js
Normal file
159
viewer/journal.js
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
import { GOODS } from "../engine/catalog.js";
|
||||
import { icon } from "./icons.js";
|
||||
const esc = (value) =>
|
||||
String(value ?? "").replace(
|
||||
/[&<>"']/g,
|
||||
(c) =>
|
||||
({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[
|
||||
c
|
||||
],
|
||||
);
|
||||
|
||||
export function journalContent(state, t, { automatedSetup = false } = {}) {
|
||||
const metric = (id, n, signed = false) =>
|
||||
`<span class="metric" title="${esc(t(id === "coin" ? "coins" : id === "worker" ? "workers" : id === "citizen" ? "citizens" : id))}">${icon(id, 20)}<b>${signed && n > 0 ? "+" : ""}${esc(n)}</b></span>`;
|
||||
const goods = (items = {}) =>
|
||||
GOODS.filter((g) => items[g])
|
||||
.map((g) => metric(g, items[g]))
|
||||
.join("");
|
||||
const people = (x = {}) =>
|
||||
`${x.w ? metric("worker", x.w) : ""}${x.c ? metric("citizen", x.c) : ""}`;
|
||||
const reward = (x = {}) =>
|
||||
`${x.coins !== undefined ? metric("coin", x.coins, true) : ""}${x.vp ? metric("vp", x.vp, true) : ""}${x.workers ? metric("worker", x.workers, true) : ""}`;
|
||||
const name = (id) => esc(t(id));
|
||||
const target = (e) => (e.targetId ? ` → ${name(e.targetId)}` : "");
|
||||
const row = (e, html, css = "") =>
|
||||
`<li class="${css}"><strong class="journal-player">${e.p === null || e.p === undefined ? "" : esc(state.players[e.p].name)}</strong><div class="journal-content">${html}</div></li>`;
|
||||
const drafts = state.events.filter((e) => e.type === "draft");
|
||||
const moves = state.events.filter(
|
||||
(e) => !["round", "draft"].includes(e.type),
|
||||
);
|
||||
let setup = "";
|
||||
if (drafts.length) {
|
||||
setup = `<li class="round-divider">${t("journalSetup")}</li>`;
|
||||
setup += automatedSetup
|
||||
? `<li class="journal-setup"><p>${t("journalPreviewSetup")}</p><button data-market>${icon("building", 20)}${t("market")}</button></li>`
|
||||
: drafts
|
||||
.map((e) =>
|
||||
row(
|
||||
e,
|
||||
`${t("journalDraft")} <button class="journal-building" data-building="${e.id}">${icon("building", 18)}${name(e.id)}</button>`,
|
||||
),
|
||||
)
|
||||
.join("");
|
||||
}
|
||||
const entries = state.events
|
||||
.filter((e) => e.type !== "draft")
|
||||
.map((e) => {
|
||||
if (e.type === "round")
|
||||
return `<li class="round-divider">${t("round")} ${e.round}</li>`;
|
||||
if (e.type === "role")
|
||||
return row(
|
||||
e,
|
||||
`${icon(e.id.startsWith("adventurer") ? "adventurer" : e.id, 24)}<strong>${t("journalChooses")} ${name(e.id)}</strong>${e.coins ? metric("coin", e.coins, true) : ""}`,
|
||||
"phase-divider",
|
||||
);
|
||||
if (e.type === "end")
|
||||
return `<li class="round-divider">${t("finished")} · ${t({ city: "journalEndCity", points: "journalEndPoints", workers: "journalEndWorkers" }[e.reason])}</li>`;
|
||||
let text = "";
|
||||
switch (e.type) {
|
||||
case "income":
|
||||
text = t("journalGains");
|
||||
break;
|
||||
case "estate":
|
||||
text = `${t(e.id === "quarry" ? "journalQuarry" : e.id === "forest" ? "journalForest" : "journalEstate")} ${icon(e.id, 22)} ${name(e.id)}`;
|
||||
break;
|
||||
case "build":
|
||||
text = `${t("journalBuild")} <button class="journal-building" data-building="${e.id}">${icon("building", 20)}${name(e.id)}</button>${e.good ? ` − ${metric(e.good, 1)}` : ""}${e.worker ? ` − ${metric(e.worker.kind === "c" ? "citizen" : "worker", 1)}` : ""}${e.point ? ` − ${metric("vp", e.point)}` : ""}`;
|
||||
break;
|
||||
case "produce":
|
||||
text = goods(e.goods)
|
||||
? `${t("journalProduce")} ${goods(e.goods)}`
|
||||
: t("journalNothing");
|
||||
break;
|
||||
case "produceBonus":
|
||||
text = `${t("journalBonus")} ${metric(e.good, 1)}`;
|
||||
break;
|
||||
case "trade":
|
||||
text = `${t("journalTrade")} ${metric(e.good, 1)}${e.outpost ? ` · ${t("merchantOutpost")}` : ""} →`;
|
||||
break;
|
||||
case "ship":
|
||||
case "smallWharf":
|
||||
text = `${t("journalShip")} ${goods(e.goods)}${e.ship === "wharf" || e.type === "smallWharf" ? ` · ${t(e.type === "smallWharf" ? "smallWharfShip" : "wharfShip")}` : e.shipCapacity ? ` <small>${icon("ship", 18)} ${e.shipLoad}/${e.shipCapacity}</small>` : ""} →`;
|
||||
break;
|
||||
case "store":
|
||||
text = `${t("journalStore")} ${goods(e.goods) || t("journalNoGoods")}${goods(e.lost) ? `<span class="journal-loss">${t("journalLost")} ${goods(e.lost)}</span>` : ""}`;
|
||||
break;
|
||||
case "assign": {
|
||||
const totals = [...e.estates, ...e.buildings].reduce(
|
||||
(n, x) => ({ w: n.w + x.w, c: n.c + x.c }),
|
||||
{ w: 0, c: 0 },
|
||||
);
|
||||
text = `${t("journalAssign")} ${people(totals)}${e.allocation?.length ? `<div class="journal-allocation">${e.allocation.map((x) => `<span>${name(x.id)} ${people(x)}</span>`).join("")}${people(e.reserve) ? `<span>${t("reserve")} ${people(e.reserve)}</span>` : ""}</div>` : ""}`;
|
||||
break;
|
||||
}
|
||||
case "hospital":
|
||||
case "school":
|
||||
case "recruitBonus":
|
||||
case "recruit":
|
||||
case "villa":
|
||||
case "bonusAssign":
|
||||
case "poachWorker":
|
||||
text = `${t("journalRecruit")} ${metric(e.kind === "c" ? "citizen" : "worker", 1)}${target(e)}`;
|
||||
break;
|
||||
case "bohio":
|
||||
text = `${t("journalMoveWorker")} ${metric(e.kind === "c" ? "citizen" : "worker", 1)}${target(e)}`;
|
||||
break;
|
||||
case "festival":
|
||||
text = `${t("journalFestival")} ${icon("festival", 22)} ${name(e.id)} → ${reward(e.reward)}`;
|
||||
break;
|
||||
case "raid":
|
||||
text = `${t("journalRaid")} ${e.good ? metric(e.good, e.amount) : esc(e.amount)}`;
|
||||
break;
|
||||
case "plunder":
|
||||
text = t("journalPlunder");
|
||||
break;
|
||||
case "capture":
|
||||
text = `${t("journalCapture")} ${icon(e.id, 22)} ${name(e.id)}`;
|
||||
break;
|
||||
case "poach":
|
||||
text = t("journalPoach");
|
||||
break;
|
||||
case "discardWorker":
|
||||
text = `${t("journalDiscardWorker")} ${metric(e.kind === "c" ? "citizen" : "worker", 1)}`;
|
||||
break;
|
||||
case "park":
|
||||
case "zoneSell":
|
||||
text = `${t("journalRemove")} ${e.estateId ? `${icon(e.estateId, 20)} ${name(e.estateId)}` : t("countryside")}`;
|
||||
break;
|
||||
case "zoneBuy":
|
||||
text = t("journalBuyEstate");
|
||||
break;
|
||||
case "hacienda":
|
||||
text = t("journalDraw");
|
||||
break;
|
||||
case "forest":
|
||||
return ""; // The resulting estate has its own entry.
|
||||
case "pension":
|
||||
text = `${t("pensionOffice")} · ${metric(e.good, 1)} →`;
|
||||
break;
|
||||
case "parkReward":
|
||||
text = `${t("parkAuthority")} →`;
|
||||
break;
|
||||
case "assembly":
|
||||
text = `${t("assemblyHall")} →`;
|
||||
break;
|
||||
case "pass":
|
||||
text = `${t("journalPass")}${e.role ? ` · ${name(e.role)}` : ""}`;
|
||||
break;
|
||||
default:
|
||||
text = name(e.type);
|
||||
}
|
||||
const declined = e.decline?.length
|
||||
? `<small>${t("withoutBonus")} · ${e.decline.map(name).join(", ")}</small>`
|
||||
: "";
|
||||
return row(e, `${text} ${reward(e)}${declined}`);
|
||||
})
|
||||
.join("");
|
||||
return `<ol class="journal-list">${setup}${entries}${!moves.length && (automatedSetup || !drafts.length) ? `<li class="journal-empty">${t("journalEmpty")}</li>` : ""}</ol>`;
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ try {
|
|||
} catch {}
|
||||
state ??= newGame();
|
||||
const ui = mountGame(document.getElementById("game"), {
|
||||
automatedSetup: true,
|
||||
async onMove(move) {
|
||||
undo.push(structuredClone(state));
|
||||
state = engine.move(state, move, 0);
|
||||
|
|
|
|||
347
viewer/style.css
347
viewer/style.css
|
|
@ -479,7 +479,7 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
gap: 3px;
|
||||
}
|
||||
.pr-game .building-face .metric {
|
||||
|
|
@ -536,51 +536,133 @@
|
|||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 7px;
|
||||
}
|
||||
.pr-game .tile-stack {
|
||||
position: relative;
|
||||
padding: 0 5px 7px 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.pr-game .tile-stack.stacked::before,
|
||||
.pr-game .tile-stack.stacked-deep::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 4px 2px 3px 3px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 9px;
|
||||
background: var(--panel);
|
||||
}
|
||||
.pr-game .tile-stack.stacked-deep::before {
|
||||
inset: 8px 0 0 6px;
|
||||
}
|
||||
.pr-game .bcard {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: 32px minmax(0, 1fr) auto;
|
||||
grid-template-rows: auto auto;
|
||||
column-gap: 7px;
|
||||
row-gap: 4px;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
grid-template-rows: auto 1fr auto auto;
|
||||
gap: 9px;
|
||||
text-align: left;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
min-height: 78px;
|
||||
padding: 12px;
|
||||
font-size: 13px;
|
||||
background: var(--paper);
|
||||
align-items: start;
|
||||
}
|
||||
.pr-game .bcard.affordable {
|
||||
border-color: #839c75;
|
||||
background: var(--selected);
|
||||
}
|
||||
.pr-game .bcard-icon {
|
||||
grid-row: 1/3;
|
||||
}
|
||||
.pr-game .bcard strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
.pr-game .bcard .price {
|
||||
grid-row: 1/3;
|
||||
grid-column: 3;
|
||||
align-self: center;
|
||||
}
|
||||
.pr-game .building-info {
|
||||
.pr-game .bcard-title {
|
||||
grid-column: 1/-1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
align-items: center;
|
||||
min-height: 38px;
|
||||
padding-right: 46px;
|
||||
}
|
||||
.pr-game .bcard-title strong {
|
||||
line-height: 1.3;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.pr-game .bcard-cost {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
font-size: 20px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.pr-game .bcard-cost small {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
min-width: 0;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.pr-game .building-info .icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
.pr-game .bcard-effect {
|
||||
grid-column: 1/-1;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.pr-game .building-info small {
|
||||
.pr-game .bcard-stats {
|
||||
grid-column: 1/-1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
.pr-game .points-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
white-space: nowrap;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pr-game .capacity-slots {
|
||||
display: inline-flex;
|
||||
gap: 3px;
|
||||
}
|
||||
.pr-game .capacity-slots > span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 23px;
|
||||
height: 24px;
|
||||
border: 1px dashed var(--muted);
|
||||
border-radius: 5px;
|
||||
}
|
||||
.pr-game .capacity-slots .icon {
|
||||
opacity: 0.65;
|
||||
}
|
||||
.pr-game .bcard-stock {
|
||||
grid-column: 1/-1;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.pr-game .bcard-stock > span:last-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
.pr-game .bcard.sold-out {
|
||||
opacity: 0.5;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.pr-game .pr-modal .building-market {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.pr-game .pr-modal .building-market > header {
|
||||
display: none;
|
||||
}
|
||||
.pr-game .pr-modal .market-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
.pr-game .action-dock {
|
||||
position: fixed;
|
||||
|
|
@ -675,10 +757,118 @@
|
|||
margin: 12px 0;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.pr-game .rules-content > section + section,
|
||||
.pr-game .rules-edition,
|
||||
.pr-game .rules-reference + section {
|
||||
margin-top: 22px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
.pr-game .rules-content h3 {
|
||||
margin: 0 0 10px;
|
||||
font-size: 17px;
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
.pr-game .rules-content h4 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.pr-game .rules-content p {
|
||||
margin: 6px 0 10px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.pr-game .rules-round {
|
||||
padding-left: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
.pr-game .rules-round li {
|
||||
padding-left: 4px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.pr-game .rules-round li::marker {
|
||||
font-weight: 700;
|
||||
}
|
||||
.pr-game .rules-round p {
|
||||
margin-top: 2px;
|
||||
}
|
||||
.pr-game .rules-chain {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
list-style: none;
|
||||
padding: 12px;
|
||||
margin: 12px 0;
|
||||
background: var(--selected);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.pr-game .rules-chain li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.pr-game .rules-chain p {
|
||||
margin: 2px 0 0;
|
||||
}
|
||||
.pr-game .rules-goods {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
.pr-game .rules-tip {
|
||||
margin-top: 18px;
|
||||
padding: 12px;
|
||||
border-left: 3px solid var(--gold);
|
||||
background: var(--sea);
|
||||
}
|
||||
.pr-game .rules-tip p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pr-game .rules-edition section {
|
||||
margin-top: 14px;
|
||||
}
|
||||
.pr-game .rules-edition section h3 {
|
||||
font-size: 14px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.pr-game .rules-content .rules-reference {
|
||||
margin-top: 16px;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.pr-game .rules-goods {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
.pr-game .rules-chain {
|
||||
padding: 10px;
|
||||
}
|
||||
.pr-game .rules-chain .icon {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
}
|
||||
.pr-game .building-detail {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 25px;
|
||||
gap: 16px;
|
||||
}
|
||||
.pr-game .building-detail-stats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14px;
|
||||
}
|
||||
.pr-game .building-detail-stats > span {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
.pr-game .building-detail-stats small {
|
||||
color: var(--muted);
|
||||
}
|
||||
.pr-game .building-detail .metric {
|
||||
font-size: 20px;
|
||||
|
|
@ -697,11 +887,64 @@
|
|||
font-size: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.pr-game .journal-list li > span {
|
||||
.pr-game .journal-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.pr-game .journal-list .journal-player {
|
||||
flex-basis: 80px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.pr-game .journal-list .phase-divider {
|
||||
margin-top: 14px;
|
||||
border-bottom: 2px solid var(--line);
|
||||
padding-top: 12px;
|
||||
}
|
||||
.pr-game .journal-list .journal-building {
|
||||
min-height: 30px;
|
||||
padding: 2px 4px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
text-align: left;
|
||||
font-size: inherit;
|
||||
}
|
||||
.pr-game .journal-content small {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.pr-game .journal-allocation,
|
||||
.pr-game .journal-loss {
|
||||
flex-basis: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
.pr-game .journal-allocation > span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: var(--paper);
|
||||
padding: 3px 5px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pr-game .journal-setup p {
|
||||
margin: 0;
|
||||
}
|
||||
.pr-game .journal-empty {
|
||||
color: var(--muted);
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.pr-game .journal-list .journal-player {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
.pr-game .journal-list .round-divider {
|
||||
font-weight: bold;
|
||||
|
|
@ -937,32 +1180,30 @@
|
|||
gap: 6px;
|
||||
}
|
||||
.pr-game .bcard {
|
||||
grid-template-columns: 24px minmax(0, 1fr);
|
||||
padding: 7px;
|
||||
gap: 4px;
|
||||
min-height: 87px;
|
||||
padding: 9px;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.pr-game .bcard-title {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 5px;
|
||||
padding-right: 0;
|
||||
}
|
||||
.pr-game .bcard-title > .icon {
|
||||
margin-right: 44px;
|
||||
}
|
||||
.pr-game .bcard-cost {
|
||||
top: 9px;
|
||||
right: 9px;
|
||||
font-size: 18px;
|
||||
}
|
||||
.pr-game .bcard-effect {
|
||||
font-size: 11px;
|
||||
}
|
||||
.pr-game .bcard-icon {
|
||||
grid-row: 1;
|
||||
}
|
||||
.pr-game .bcard-icon .icon {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
}
|
||||
.pr-game .bcard .price {
|
||||
grid-row: 2;
|
||||
grid-column: 1;
|
||||
}
|
||||
.pr-game .bcard .price .icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
.pr-game .building-info {
|
||||
gap: 4px;
|
||||
}
|
||||
.pr-game .building-info .metric + .metric {
|
||||
margin-left: 2px;
|
||||
.pr-game .capacity-slots > span {
|
||||
width: 19px;
|
||||
height: 22px;
|
||||
}
|
||||
.pr-game .action-dock {
|
||||
padding: 7px 9px max(7px, env(safe-area-inset-bottom));
|
||||
|
|
|
|||
109
viewer/ui.js
109
viewer/ui.js
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from "../engine/index.js";
|
||||
import { translator } from "./i18n.js";
|
||||
import { icon } from "./icons.js";
|
||||
import { journalContent } from "./journal.js";
|
||||
import css from "./style.css";
|
||||
|
||||
const esc = (x) =>
|
||||
|
|
@ -32,7 +33,7 @@ const spriteFor = (id) =>
|
|||
B[id]?.good && B[id].good !== "tailor" ? B[id].good : "building";
|
||||
export function mountGame(
|
||||
target,
|
||||
{ onMove, chat, onOpenPlayer, localControls } = {},
|
||||
{ onMove, chat, onOpenPlayer, localControls, automatedSetup = false } = {},
|
||||
) {
|
||||
const shell = document.createElement("div");
|
||||
shell.className = "pr-game";
|
||||
|
|
@ -95,6 +96,7 @@ export function mountGame(
|
|||
modalMode = mode;
|
||||
modal.querySelector("h2").textContent = title;
|
||||
body.innerHTML = html;
|
||||
body.scrollTop = 0;
|
||||
if (!modal.open) modal.showModal();
|
||||
modal.querySelector("[data-close]").focus();
|
||||
}
|
||||
|
|
@ -254,7 +256,7 @@ export function mountGame(
|
|||
}
|
||||
function playerBoard() {
|
||||
const a = state.players[view];
|
||||
return `<section class="player-board panel" id="own-board"><header><h2>${esc(a.name)}</h2><div>${metric("coin", a.coins)}${metric("vp", a.vp ?? "?")}${metric("worker", a.reserve.w)}${a.reserve.c ? metric("citizen", a.reserve.c) : ""}</div></header><div class="inventory">${GOODS.map((g) => metric(g, a.goods[g])).join("")}</div><h3>${t("countryside")} <small>${a.estates.length}/12</small></h3><div class="estates">${a.estates.map((x, i) => `<article class="estate ${x.id}" title="${esc(t(x.id))}">${icon(x.id, 31)}${x.id !== "forest" ? peopleSlots(`e${i}`, x) : ""}</article>`).join("")}${Array.from({ length: Math.max(0, 12 - a.estates.length) }, () => '<span class="estate empty-estate"></span>').join("")}</div><h3>${t("city")} <small>${citySize(a)}/12</small></h3><div class="city-grid">${a.buildings.map((x, i) => `<article class="owned-building ${B[x.id].size === 2 ? "expanded" : ""}"><button type="button" data-building="${x.id}" class="building-face" title="${esc(t.effect(x.id))}">${icon(spriteFor(x.id), 28)}<span>${t(x.id)}</span>${metric("vp", B[x.id].vp)}</button>${peopleSlots(`b${i}`, x, B[x.id].workers)}</article>`).join("")}${a.buildings.length ? "" : `<div class="empty-city">${icon("building", 40)}<span>${t("chooseBuild")}</span></div>`}</div><button class="mobile-market-launch" data-market>${icon("building")} ${t("market")}</button></section>`;
|
||||
return `<section class="player-board panel" id="own-board"><header><h2>${esc(a.name)}</h2><div>${metric("coin", a.coins)}${metric("vp", a.vp ?? "?")}${metric("worker", a.reserve.w)}${a.reserve.c ? metric("citizen", a.reserve.c) : ""}</div></header><div class="inventory">${GOODS.map((g) => metric(g, a.goods[g])).join("")}</div><h3>${t("countryside")} <small>${a.estates.length}/12</small></h3><div class="estates">${a.estates.map((x, i) => `<article class="estate ${x.id}" title="${esc(t(x.id))}">${icon(x.id, 31)}${x.id !== "forest" ? peopleSlots(`e${i}`, x) : ""}</article>`).join("")}${Array.from({ length: Math.max(0, 12 - a.estates.length) }, () => '<span class="estate empty-estate"></span>').join("")}</div><h3>${t("city")} <small>${citySize(a)}/12</small></h3><div class="city-grid">${a.buildings.map((x, i) => `<article class="owned-building ${B[x.id].size === 2 ? "expanded" : ""}"><button type="button" data-building="${x.id}" class="building-face" title="${esc(t.effect(x.id))}">${icon(spriteFor(x.id), 28)}<span>${t(x.id)}</span><span class="points-badge">${icon("vp", 20)}<b>${B[x.id].vp} ${t("shortVP")}</b></span></button>${peopleSlots(`b${i}`, x, B[x.id].workers)}</article>`).join("")}${a.buildings.length ? "" : `<div class="empty-city">${icon("building", 40)}<span>${t("chooseBuild")}</span></div>`}</div><button class="mobile-market-launch" data-market>${icon("building")} ${t("market")}</button></section>`;
|
||||
}
|
||||
function shipGraphic(sh) {
|
||||
return `<svg class="ship-art" viewBox="0 0 200 112" aria-hidden="true"><path fill="#edf0d4" stroke="#b6a37b" d="M96 6v58H42Zm10 9v49h43Z"/><path fill="#80614b" d="m12 66 17 31q75 22 143-3l18-28Z"/><path fill="none" stroke="#d7ac75" stroke-width="3" d="m28 77 144 0m-70-74v65"/>${Array.from({ length: sh.capacity }, (_, i) => `<rect x="${22 + i * (155 / sh.capacity)}" y="72" width="${Math.min(18, 140 / sh.capacity)}" height="17" rx="2" fill="${i < sh.amount ? "#e6c06f" : "#483e38"}" stroke="#bfa587"/>`).join("")}<path d="M5 105q20-10 40 0t40 0t40 0t40 0t30 0" fill="none" stroke="#9bbebc" stroke-width="2"/></svg>`;
|
||||
|
|
@ -284,6 +286,15 @@ export function mountGame(
|
|||
return `<button class="offer quarry" ${m && acting ? `data-move="${encode(m)}"` : "disabled"} title="${esc(t("quarry"))}">${icon("quarry", 28)}<small>${state.quarries}</small></button>`;
|
||||
})()}${acting && task.kind === "plant" && state.legal.some((m) => m.forest) ? `<button data-forests>${icon("forest")} ${t("forest")}</button>` : ""}</div></div>${state.festivals.length ? `<section class="festival-strip">${state.festivals.map((f, i) => `<button data-festival="${i}" class="festival ${f.claimed !== undefined ? "claimed" : ""}">${icon(f.claimed !== undefined ? "check" : "festival", 20)}<span>${t(f.id)}</span><span class="festival-target">${[...f.targets.goods, ...f.targets.estates].map((g) => icon(g, 22)).join("")}${f.targets.building ? icon("building", 22) : ""}</span></button>`).join("")}</section>` : ""}</section>`;
|
||||
}
|
||||
function buildingSlots(b) {
|
||||
return `<span class="capacity-slots" title="${esc(`${t("workerSpaces")} : ${b.workers}`)}" aria-label="${esc(`${t("workerSpaces")} : ${b.workers}`)}">${Array.from({ length: b.workers }, () => `<span>${icon("worker", 17)}</span>`).join("")}</span>`;
|
||||
}
|
||||
function buildingEffect(id) {
|
||||
const b = B[id];
|
||||
return b.good && b.good !== "tailor"
|
||||
? `${t("produce")} : ${t(b.good)}.`
|
||||
: t.effect(id);
|
||||
}
|
||||
function market() {
|
||||
const task = state.tasks[0],
|
||||
isDraft = task?.kind === "draft",
|
||||
|
|
@ -304,8 +315,22 @@ export function mountGame(
|
|||
(isDraft ? m.type === "draft" : m.type === "build") &&
|
||||
m.id === id,
|
||||
),
|
||||
n = state.market[id] ?? b.copies;
|
||||
return `<button class="bcard ${b.good ? "production" : "commercial"} ${m && allowed() ? "affordable" : ""} ${!n ? "sold-out" : ""}" data-building="${id}" ${!n && !m ? 'aria-disabled="true"' : ""}><span class="bcard-icon">${icon(spriteFor(id), 32)}</span><strong>${t(id)}</strong><span class="price">${metric("coin", !isDraft && task?.kind === "build" && Number.isInteger(seat) ? cost(state, seat, id) : b.cost)}</span><span class="building-info">${metric("vp", b.vp)}<span>${icon("worker", 16)}${b.workers}</span>${b.size === 2 ? '<span class="double-space">▭▭</span>' : ""}<small>×${n}</small></span></button>`;
|
||||
n = state.market[id] ?? (state.players.length === 2 ? 1 : b.copies);
|
||||
const price =
|
||||
!isDraft && task?.kind === "build" && Number.isInteger(seat)
|
||||
? cost(state, seat, id)
|
||||
: b.cost;
|
||||
const stock =
|
||||
n === 0
|
||||
? t("soldOut")
|
||||
: `${n} ${t(n === 1 ? "stockAvailableOne" : "stockAvailable")}`;
|
||||
return `<div class="tile-stack ${n > 1 ? "stacked" : ""} ${n > 2 ? "stacked-deep" : ""}"><button class="bcard ${b.good ? "production" : "commercial"} ${m && allowed() ? "affordable" : ""} ${!n ? "sold-out" : ""}" data-building="${id}" ${!n && !m ? 'aria-disabled="true"' : ""}>
|
||||
<span class="bcard-title">${icon(spriteFor(id), 30)}<strong>${t(id)}</strong></span>
|
||||
<span class="bcard-cost"><small>${t("cost")}</small>${metric("coin", price)}</span>
|
||||
<span class="bcard-effect">${esc(buildingEffect(id))}</span>
|
||||
<span class="bcard-stats"><span class="points-badge" title="${esc(t("printedPoints"))}">${icon("vp", 20)}<b>${b.vp} ${t("shortVP")}</b></span>${buildingSlots(b)}</span>
|
||||
<span class="bcard-stock">${b.size === 2 ? `<span class="city-footprint" title="${esc(t("twoCitySpaces"))}">▭▭ ${t("twoCitySpaces")}</span>` : ""}<span>${stock}</span></span>
|
||||
</button></div>`;
|
||||
})
|
||||
.join("")}</div></section>`;
|
||||
}
|
||||
|
|
@ -367,13 +392,7 @@ export function mountGame(
|
|||
}
|
||||
}
|
||||
function journal() {
|
||||
return `<ol class="journal-list">${state.events
|
||||
.map((e) => {
|
||||
if (e.type === "round")
|
||||
return `<li class="round-divider">${t("round")} ${e.round}</li>`;
|
||||
return `<li>${e.p !== null && e.p !== undefined ? `<strong>${esc(state.players[e.p].name)}</strong>` : ""}<span>${e.type === "role" ? `${icon(e.id, 21)} ${t(e.id)}` : e.type === "estate" ? `${icon("planter", 20)} ${icon(e.id, 22)} ${t(e.id)}` : e.type === "build" ? `${icon("builder", 20)} ${t(e.id)}` : e.type === "festival" ? `${icon("festival", 20)} ${t(e.id)}` : esc(t(e.type))}${e.goods ? goodsRow(e.goods) : ""}${e.good ? icon(e.good, 23) : ""}${e.coins ? metric("coin", e.coins) : ""}${e.vp ? metric("vp", e.vp) : ""}</span></li>`;
|
||||
})
|
||||
.join("")}</ol>`;
|
||||
return journalContent(state, t, { automatedSetup });
|
||||
}
|
||||
function buildingInfo(id) {
|
||||
const b = B[id],
|
||||
|
|
@ -382,7 +401,7 @@ export function mountGame(
|
|||
);
|
||||
show(
|
||||
t(id),
|
||||
`<div class="building-detail">${icon(spriteFor(id), 72)}<div>${metric("coin", b.cost)}${metric("vp", b.vp)}${metric("worker", b.workers)}</div></div><p>${esc(b.good && b.good !== "tailor" ? `${t("produce")} : ${t(b.good)}.` : t.effect(id))}</p>${moves.length && allowed() ? `<div class="action-choices">${moves.map((m) => moveButton(m, `${t(m.type === "draft" ? "selected" : "builder")} ${metric("coin", m.type === "draft" ? b.cost : cost(state, seat, id))}${m.worker ? ` − ${icon(m.worker.kind === "c" ? "citizen" : "worker")} ${targetLabel(m.worker.key)}` : ""}${m.good ? ` − ${icon(m.good)}` : ""}${m.point ? ` − ${metric("vp", 1)}` : ""}`, "check", "primary")).join("")}</div>` : ""}`,
|
||||
`<div class="building-detail">${icon(spriteFor(id), 56)}<div class="building-detail-stats"><span><small>${t("cost")}</small>${metric("coin", b.cost)}</span><span><small>${t("printedPoints")}</small>${metric("vp", b.vp)}</span><span><small>${t("workerSpaces")}</small>${buildingSlots(b)}</span></div></div><p>${esc(buildingEffect(id))}</p>${b.size === 2 ? `<p>${t("twoCitySpaces")}</p>` : ""}${moves.length && allowed() ? `<div class="action-choices">${moves.map((m) => moveButton(m, `${t(m.type === "draft" ? "selected" : "builder")} ${metric("coin", m.type === "draft" ? b.cost : cost(state, seat, id))}${m.worker ? ` − ${icon(m.worker.kind === "c" ? "citizen" : "worker")} ${targetLabel(m.worker.key)}` : ""}${m.good ? ` − ${icon(m.good)}` : ""}${m.point ? ` − ${metric("vp", 1)}` : ""}`, "check", "primary")).join("")}</div>` : ""}`,
|
||||
);
|
||||
}
|
||||
function festivalInfo(i) {
|
||||
|
|
@ -417,6 +436,55 @@ export function mountGame(
|
|||
.join("")}</div>`,
|
||||
);
|
||||
}
|
||||
function howToPlay() {
|
||||
const hasExpansion = (id) => state.expansions.includes(id);
|
||||
const smuggler = hasExpansion("smuggler");
|
||||
const adventurer = state.roles.some((r) => r.id.startsWith("adventurer"));
|
||||
const citizens = hasExpansion("citizens");
|
||||
const section = (pictogram, title, content) =>
|
||||
`<section><h3>${icon(pictogram)}${t(title)}</h3>${content}</section>`;
|
||||
const paragraph = (key) => `<p>${t(key)}</p>`;
|
||||
const roundSteps = [
|
||||
["ruleChooseTitle", t("ruleChoose")],
|
||||
["ruleFollowTitle", t("ruleFollow")],
|
||||
[
|
||||
"ruleNextTitle",
|
||||
t(state.players.length === 2 ? "ruleNextTwo" : "ruleNext"),
|
||||
],
|
||||
[
|
||||
"ruleResetTitle",
|
||||
`${t("ruleReset")}${smuggler ? ` ${t("ruleSmugglerCoin")}` : ""}`,
|
||||
],
|
||||
];
|
||||
const chain = [
|
||||
["planter", "rulePlantStep"],
|
||||
["builder", "ruleBuildStep"],
|
||||
["recruiter", "ruleRecruitStep"],
|
||||
["craftsman", "ruleProduceStep"],
|
||||
];
|
||||
const extras = [
|
||||
citizens ? section("citizen", "citizens", paragraph("ruleCitizens")) : "",
|
||||
smuggler
|
||||
? section("smuggler", "smuggler", paragraph("ruleSmuggler"))
|
||||
: "",
|
||||
adventurer
|
||||
? section("adventurer", "adventurer", paragraph("ruleAdventurer"))
|
||||
: "",
|
||||
state.festivals.length
|
||||
? section("festival", "festival", paragraph("ruleFestival"))
|
||||
: "",
|
||||
].join("");
|
||||
return `<div class="rules-content">
|
||||
${section("vp", "ruleGoalTitle", paragraph("ruleGoal"))}
|
||||
${section("governor", "ruleRoundTitle", `<ol class="rules-round">${roundSteps.map(([title, text]) => `<li><strong>${t(title)}</strong><p>${text}</p></li>`).join("")}</ol>${paragraph(smuggler || adventurer ? "ruleOptional" : "ruleOptionalBase")}`)}
|
||||
${section("sugar", "ruleProductionTitle", `${paragraph("ruleProductionIntro")}<ol class="rules-chain">${chain.map(([role, text]) => `<li>${icon(role, 28)}<div><strong>${t(role)}</strong><p>${t(text)}</p></div></li>`).join("")}</ol>${paragraph("ruleProduction")}${paragraph("ruleActivation")}`)}
|
||||
${section("ship", "ruleGoodsTitle", `<div class="rules-goods"><div><h4>${icon("coin")}${t("ruleSellTitle")}</h4>${paragraph("ruleSell")}</div><div><h4>${icon("vp")}${t("ruleShipTitle")}</h4>${paragraph("ruleShip")}</div></div>${paragraph("ruleShipLimits")}`)}
|
||||
<aside class="rules-tip"><strong>${t("ruleTimingTitle")}</strong>${paragraph("ruleTiming")}</aside>
|
||||
${extras ? `<div class="rules-edition"><h3>${t("ruleEditionTitle")}</h3>${extras}</div>` : ""}
|
||||
<p class="rules-reference">${t(hasExpansion("new-buildings") || citizens ? "ruleDraft" : "ruleDetails")}</p>
|
||||
${section("vp", "ruleEndTitle", `${paragraph("ruleEnd")}${paragraph(citizens ? "ruleEndCitizens" : "ruleEndWorkers")}${paragraph("ruleScore")}${citizens ? paragraph("ruleScoreCitizens") : ""}`)}
|
||||
</div>`;
|
||||
}
|
||||
async function send(m) {
|
||||
if (
|
||||
!allowed() &&
|
||||
|
|
@ -461,22 +529,7 @@ export function mountGame(
|
|||
body.scrollTop = body.scrollHeight;
|
||||
return;
|
||||
}
|
||||
show(
|
||||
t("rules"),
|
||||
`<div class="rules-content"><p>${t("ruleFlow")}</p>${state.roles
|
||||
.filter((r) => r.id !== "adventurer2")
|
||||
.map((r) => `<h3>${icon(r.id)} ${t(r.id)}</h3><p>${t.role(r.id)}</p>`)
|
||||
.join(
|
||||
"",
|
||||
)}<h3>${icon("worker")} ${t("workers")}</h3><p>${t("ruleWorkers")}</p><h3>${icon("ship")} ${t("ship")}</h3><p>${t("ruleShipping")}</p><h3>${icon("vp")} ${t("finalScore")}</h3><p>${t("ruleEnd")}</p><h3>${t("abilities")}</h3>${Object.keys(
|
||||
state.market,
|
||||
)
|
||||
.map(
|
||||
(id) =>
|
||||
`<p><strong>${t(id)}</strong> — ${esc(t.effect(id) || t("produce") + " : " + t(B[id].good))}</p>`,
|
||||
)
|
||||
.join("")}</div>`,
|
||||
);
|
||||
show(t("rules"), howToPlay(), "rules");
|
||||
return;
|
||||
}
|
||||
if (el.dataset.role) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue