Clarify the production cycle with distinct plantation and goods visuals
This commit is contained in:
parent
31d1f09f6a
commit
cfa5e5a1b2
10 changed files with 579 additions and 56 deletions
|
|
@ -57,13 +57,13 @@ try {
|
|||
);
|
||||
assert.equal(
|
||||
await page
|
||||
.locator('.player-strip [data-player="0"] .player-card-goods')
|
||||
.locator('.player-strip [data-player="0"] .player-card-goods .metric')
|
||||
.innerText(),
|
||||
"2",
|
||||
);
|
||||
assert.equal(
|
||||
await page
|
||||
.locator('.player-strip [data-player="1"] .player-card-goods')
|
||||
.locator('.player-strip [data-player="1"] .player-card-goods .metric')
|
||||
.innerText(),
|
||||
"3",
|
||||
);
|
||||
|
|
@ -173,11 +173,44 @@ try {
|
|||
false,
|
||||
);
|
||||
await page.locator('[data-slot="e0:0"]').click();
|
||||
assert.equal(
|
||||
await page
|
||||
.locator('[data-production-good="corn"] .production-output')
|
||||
.innerText(),
|
||||
"1",
|
||||
"preview includes an assigned corn worker before confirmation",
|
||||
);
|
||||
assert.equal(await page.locator('[data-slot="e1:0"]').isEnabled(), false);
|
||||
assert.equal(await page.locator('[data-slot="e1:0"]').innerText(), "·");
|
||||
await page.locator('[data-slot="e0:0"]').click();
|
||||
assert.equal(
|
||||
await page
|
||||
.locator('[data-production-good="corn"] .production-output')
|
||||
.innerText(),
|
||||
"0",
|
||||
"removing the worker updates production immediately",
|
||||
);
|
||||
assert.equal(await page.locator('[data-slot="e1:0"]').isEnabled(), true);
|
||||
await page.locator('[data-slot="e1:0"]').click();
|
||||
assert.equal(
|
||||
await page
|
||||
.locator('[data-production-good="fruit"] .production-output')
|
||||
.innerText(),
|
||||
"0",
|
||||
);
|
||||
assert.match(
|
||||
await page
|
||||
.locator('[data-production-good="fruit"] .production-status')
|
||||
.innerText(),
|
||||
/Construisez le bâtiment/,
|
||||
"fruit still needs a production building",
|
||||
);
|
||||
const beforeHelp = await page.evaluate(() => played.length);
|
||||
await page.locator("[data-production-help]").click();
|
||||
assert.match(await page.locator(".production-guide").innerText(), /maïs/);
|
||||
assert.equal(await overflow(), false, `Production help at ${width}`);
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(await page.evaluate(() => played.length), beforeHelp);
|
||||
assert.equal(await page.locator('[data-slot="e0:0"]').isEnabled(), false);
|
||||
await page.locator("[data-confirm-assign]").click();
|
||||
const allocation = await page.evaluate(() => played.at(-1));
|
||||
|
|
@ -188,6 +221,26 @@ try {
|
|||
path: `.local/qa/${width}-board.png`,
|
||||
fullPage: true,
|
||||
});
|
||||
const buildingChoice = E.move(original, { type: "role", id: "builder" }, 0);
|
||||
await page.evaluate(
|
||||
(s) => host.emit("state", s),
|
||||
E.stripSecret(buildingChoice, 0),
|
||||
);
|
||||
await page.locator(".action-dock [data-market]").click();
|
||||
const productionCard = page.locator(
|
||||
'.pr-modal .bcard[data-building="smallFruit"]',
|
||||
);
|
||||
assert.equal(await productionCard.locator(".staffed-icon").count(), 2);
|
||||
assert.match(await productionCard.innerText(), /PRODUCTION/i);
|
||||
assert.equal(await overflow(), false, `Building choice at ${width}`);
|
||||
await page.screenshot({ path: `.local/qa/${width}-market.png` });
|
||||
await productionCard.click();
|
||||
assert.match(
|
||||
await page.locator(".modal-body").innerText(),
|
||||
/Un ouvrier sur une plantation/,
|
||||
);
|
||||
await page.keyboard.press("Escape");
|
||||
await page.evaluate((s) => host.emit("state", s), E.stripSecret(s, 0));
|
||||
// Identical state notifications preserve the SVG/board nodes instead of redrawing them.
|
||||
await page.evaluate(
|
||||
(s) => {
|
||||
|
|
|
|||
56
test/production-ui.test.js
Normal file
56
test/production-ui.test.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { productionLines } from "../viewer/production.js";
|
||||
import { translator } from "../viewer/i18n.js";
|
||||
import { richText, plainText } from "../viewer/rich-text.js";
|
||||
import { icon } from "../viewer/icons.js";
|
||||
const supply = { corn: 10, fruit: 11, sugar: 11, tobacco: 9, coffee: 9 };
|
||||
const tile = (id, w = 0, c = 0) => ({ id, w, c });
|
||||
const player = (estates, buildings = []) => ({ estates, buildings });
|
||||
|
||||
test("fruit plantation and production building each require staff", () => {
|
||||
const p = player([tile("fruit", 1), tile("fruit")]);
|
||||
assert.equal(productionLines(p, supply)[0].issue, "needWorkshop");
|
||||
p.buildings.push(tile("smallFruit"));
|
||||
assert.equal(productionLines(p, supply)[0].issue, "staffWorkshop");
|
||||
p.buildings[0].w = 1;
|
||||
assert.equal(productionLines(p, supply)[0].available, 1);
|
||||
p.estates[1].w = 1;
|
||||
assert.equal(productionLines(p, supply)[0].capacity, 1);
|
||||
p.estates.forEach((e) => (e.w = 0));
|
||||
assert.equal(productionLines(p, supply)[0].issue, "staffPlantation");
|
||||
});
|
||||
test("building alone cannot produce; corn requires no production building", () => {
|
||||
assert.equal(
|
||||
productionLines(player([], [tile("smallFruit", 1)]), supply)[0].issue,
|
||||
"needPlantation",
|
||||
);
|
||||
const line = productionLines(player([tile("corn", 1)]), supply)[0];
|
||||
assert.equal(line.available, 1);
|
||||
assert.equal(line.issue, "productionReady");
|
||||
});
|
||||
test("capacity includes occupied Canal and citizen workers, while output respects supply", () => {
|
||||
const p = player(
|
||||
[tile("fruit", 1), tile("fruit", 0, 1)],
|
||||
[tile("largeFruit", 2), tile("canal", 1)],
|
||||
);
|
||||
const line = productionLines(p, { ...supply, fruit: 1 })[0];
|
||||
assert.equal(line.capacity, 3);
|
||||
assert.equal(line.available, 1);
|
||||
assert.equal(line.issue, "limitedSupply");
|
||||
assert.equal(line.farms, 2);
|
||||
});
|
||||
test("empty and Puertoma boards do not get human production explanations", () => {
|
||||
assert.deepEqual(productionLines(player([]), supply), []);
|
||||
assert.deepEqual(
|
||||
productionLines({ ...player([]), puertoma: {} }, supply),
|
||||
[],
|
||||
);
|
||||
});
|
||||
test("generic goods have readable names and field/workshop silhouettes are distinct", () => {
|
||||
assert.equal(plainText("{crate:2}", true), "2 marchandises");
|
||||
assert.match(richText("{crate:1}", true), /symbol-word.*marchandise/);
|
||||
assert.notEqual(icon("field-fruit"), icon("fruit"));
|
||||
assert.notEqual(icon("workshop-fruit"), icon("fruit"));
|
||||
assert.match(translator("fr").roleAction("craftsman"), /plantations/);
|
||||
});
|
||||
|
|
@ -55,9 +55,9 @@ export function achievementText(id, t) {
|
|||
productionSet:
|
||||
"Have at least 1 {sugar}, 1 {tobacco}, and 1 {coffee} Production Building.",
|
||||
cheapExpanded: "Build an expanded Building paying a maximum of {coin:6}.",
|
||||
goods: "Have at least {crate:7} of one Good.",
|
||||
goods: "Have at least {crate:7} of one type.",
|
||||
store: "Store at least 2 different Goods at the end of a {captain} phase.",
|
||||
shipAmount: "Load at least {crate:5} of the same Good at once.",
|
||||
shipAmount: "Load at least {crate:5} of the same type at once.",
|
||||
captainPoints: "Gain at least {vp:7} during one {captain} phase.",
|
||||
tradeCoins: "Sell a Good to the Trading House for at least {coin:6}.",
|
||||
productionCount:
|
||||
|
|
@ -85,12 +85,12 @@ export function achievementText(id, t) {
|
|||
estates: "Posséder 12 tuiles de campagne.",
|
||||
cheapExpanded:
|
||||
"Construire un bâtiment étendu en payant au maximum {coin:6}.",
|
||||
goods: "Posséder au moins {crate:7} d’une même marchandise.",
|
||||
goods: "Posséder au moins {crate:7} d’un même type.",
|
||||
store:
|
||||
"Conserver au moins 2 marchandises différentes à la fin d’une phase de {captain}.",
|
||||
commercial: "Posséder au moins 7 bâtiments commerciaux ordinaires.",
|
||||
shipAmount:
|
||||
"Charger au moins {crate:5} d’une même marchandise en une seule action.",
|
||||
"Charger au moins {crate:5} d’un même type en une seule action.",
|
||||
captainPoints: "Gagner au moins {vp:7} durant une même phase de {captain}.",
|
||||
tradeCoins: "Vendre une marchandise au comptoir pour au moins {coin:6}.",
|
||||
productionCount:
|
||||
|
|
@ -115,16 +115,16 @@ export const abilityTexts = {
|
|||
"+1 ouvrier après une construction.",
|
||||
],
|
||||
storage: [
|
||||
"Store all of the best Good and one other Crate.",
|
||||
"Conserver toutes les caisses de la meilleure marchandise et une autre caisse.",
|
||||
"Store all goods of the best type and one other good.",
|
||||
"Conserver toutes les marchandises du meilleur type et une marchandise supplémentaire.",
|
||||
],
|
||||
buildCoin: [
|
||||
"+1 Coin when able to build.",
|
||||
"+1 pièce lorsqu’une construction est possible.",
|
||||
],
|
||||
produceCrate: [
|
||||
"+1 Crate of the best produced Good after production.",
|
||||
"+1 caisse de la meilleure marchandise produite après la production.",
|
||||
"+1 good of the best type produced after production.",
|
||||
"+1 marchandise du meilleur type produit après la production.",
|
||||
],
|
||||
produceCoins: [
|
||||
"+1 Coin per produced Goods type.",
|
||||
|
|
@ -135,8 +135,8 @@ export const abilityTexts = {
|
|||
"+1 ouvrier après le recrutement.",
|
||||
],
|
||||
plantCrate: [
|
||||
"+1 Crate matching a new Estate.",
|
||||
"+1 caisse correspondant à la plantation choisie.",
|
||||
"+1 good matching the chosen plantation.",
|
||||
"+1 marchandise correspondant à la plantation choisie.",
|
||||
],
|
||||
goodsPoints: [
|
||||
"+1 VP per Goods type before storage.",
|
||||
|
|
@ -144,7 +144,7 @@ export const abilityTexts = {
|
|||
],
|
||||
discardPoints: [
|
||||
"Discard up to 2 of the worst Good for 1 VP each before storage.",
|
||||
"Défausser jusqu’à 2 caisses de la moins bonne marchandise pour 1 PV chacune avant le stockage.",
|
||||
"Défausser jusqu’à 2 marchandises du moins bon type pour 1 PV chacune avant le stockage.",
|
||||
],
|
||||
recruitCoins: [
|
||||
"+1 Coin per Worker gained during recruitment.",
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ const quantity = (id, n) =>
|
|||
: `<span class="effect-quantity">${icon(id, 24)}<b>${n}</b></span>`;
|
||||
const arrow = () => icon("arrow", 18);
|
||||
const row = (...parts) => `<span class="effect-row">${parts.join("")}</span>`;
|
||||
const staffed = (id) =>
|
||||
`<span class="staffed-icon">${icon(id, 28)}${icon("worker", 15)}</span>`;
|
||||
|
||||
export function buildingSymbols(id, t) {
|
||||
const caption = (key) =>
|
||||
|
|
@ -21,11 +23,20 @@ export function buildingSymbols(id, t) {
|
|||
const b = B[id];
|
||||
const full =
|
||||
b.good && b.good !== "tailor"
|
||||
? `${t("produce")} : ${t(b.good)}.`
|
||||
? `${t("productionCapacity")} : ${b.workers} ${t(b.good)}. ${t("matchingWorkers")}`
|
||||
: t.effect(id);
|
||||
let visual;
|
||||
if (b.good && b.good !== "tailor")
|
||||
visual = row(icon("craftsman"), arrow(), icon(b.good, 28));
|
||||
visual =
|
||||
row(
|
||||
staffed(`field-${b.good}`),
|
||||
"<b>+</b>",
|
||||
staffed(`workshop-${b.good}`),
|
||||
arrow(),
|
||||
icon(b.good, 26),
|
||||
) +
|
||||
`<small class="effect-caption">${t("productionCapacity")} : <b>${b.workers}</b></small>` +
|
||||
caption("bothStaffed");
|
||||
else
|
||||
switch (id) {
|
||||
case "smallMarket":
|
||||
|
|
|
|||
110
viewer/i18n.js
110
viewer/i18n.js
|
|
@ -1,5 +1,76 @@
|
|||
import { plainText, richText } from "./rich-text.js";
|
||||
const labels = {
|
||||
productionTitle: ["Your production", "Votre production"],
|
||||
otherProduction: ["Production", "Production"],
|
||||
productionHelp: ["How production works", "Comprendre la production"],
|
||||
productionTiming: [
|
||||
"At Craftsman · before the role bonus",
|
||||
"À l’Artisan · hors privilège",
|
||||
],
|
||||
plantationLabel: ["Plantations", "Plantations"],
|
||||
stockLabel: ["In stock", "En stock"],
|
||||
plantedOffer: ["Plantations to choose", "Plantations à choisir"],
|
||||
occupiedLabel: ["staffed", "occupées"],
|
||||
toBuild: ["Not built", "À construire"],
|
||||
workSlots: ["Production buildings", "Bâtiments de production"],
|
||||
occupiedSlots: ["spaces staffed", "places occupées"],
|
||||
needPlantation: [
|
||||
"Add a matching plantation",
|
||||
"Il manque une plantation correspondante",
|
||||
],
|
||||
staffPlantation: [
|
||||
"Place a worker on a plantation",
|
||||
"Placez un ouvrier sur une plantation",
|
||||
],
|
||||
needWorkshop: [
|
||||
"Build the matching production building",
|
||||
"Construisez le bâtiment de production correspondant",
|
||||
],
|
||||
staffWorkshop: [
|
||||
"Place a worker in the production building",
|
||||
"Placez un ouvrier dans le bâtiment de production",
|
||||
],
|
||||
limitedSupply: [
|
||||
"Limited by the remaining supply",
|
||||
"Limité par la réserve de marchandises",
|
||||
],
|
||||
productionReady: ["Ready at Craftsman", "Prêt pour l’Artisan"],
|
||||
noWorkshopNeeded: ["No building needed", "Sans bâtiment"],
|
||||
noProductionYet: [
|
||||
"Choose a plantation, then place a worker on it.",
|
||||
"Choisissez une plantation, puis placez-y un ouvrier.",
|
||||
],
|
||||
productionBuilding: ["Production", "Production"],
|
||||
storageBuilding: ["Storage", "Stockage"],
|
||||
productionCapacity: [
|
||||
"Base capacity per Craftsman",
|
||||
"Capacité de base par Artisan",
|
||||
],
|
||||
matchingWorkers: [
|
||||
"One worker on a matching plantation and one here per good produced.",
|
||||
"Un ouvrier sur une plantation correspondante et un ici par marchandise produite.",
|
||||
],
|
||||
bothStaffed: ["Both must be staffed", "Les deux doivent être occupés"],
|
||||
productionIntro: [
|
||||
"Plantations and production buildings stay on your board. The Craftsman phase adds the goods produced to your stock.",
|
||||
"Les plantations et les bâtiments restent sur votre plateau. La phase Artisan ajoute les marchandises produites à votre stock.",
|
||||
],
|
||||
productionPair: [
|
||||
"1 occupied plantation + 1 occupied production slot → 1 good. Corn needs only an occupied plantation.",
|
||||
"1 plantation occupée + 1 place occupée dans le bâtiment → 1 marchandise. Le maïs n’a besoin que d’une plantation occupée.",
|
||||
],
|
||||
goodsMeaning: [
|
||||
"A good is one unit of corn, fruit, sugar, tobacco or coffee. The rulebook calls these units crates; there is no separate crate resource.",
|
||||
"Une marchandise est une unité de maïs, fruits, sucre, tabac ou café. Les règles les appellent « caisses » : il n’y a pas de ressource caisse supplémentaire.",
|
||||
],
|
||||
useStock: [
|
||||
"Sell your stock with Trader for coins, or load ships with Captain for victory points.",
|
||||
"Vendez votre stock avec le Marchand pour gagner des pièces, ou chargez les navires avec le Capitaine pour gagner des PV.",
|
||||
],
|
||||
storageMeaning: [
|
||||
"Storage buildings help keep unsent goods after Captain. They do not produce goods.",
|
||||
"Les bâtiments de stockage permettent de conserver des marchandises après le Capitaine. Ils ne produisent rien.",
|
||||
],
|
||||
income: ["Income", "Revenus"],
|
||||
draft: ["Market selection", "Choix du marché"],
|
||||
end: ["Game over", "Fin de partie"],
|
||||
|
|
@ -189,8 +260,11 @@ const labels = {
|
|||
autoAssign: ["Suggest allocation", "Proposer une répartition"],
|
||||
erase: ["Unassign", "Retirer"],
|
||||
produce: ["Produce goods", "Produire"],
|
||||
produceBonus: ["Choose your extra crate", "Choisissez votre caisse bonus"],
|
||||
trade: ["Sell one crate", "Vendre une caisse"],
|
||||
produceBonus: [
|
||||
"Choose your extra good",
|
||||
"Choisissez votre marchandise bonus",
|
||||
],
|
||||
trade: ["Sell one good", "Vendre une marchandise"],
|
||||
ship: ["Load a ship", "Charger un bateau"],
|
||||
store: ["Store your remaining goods", "Conservez vos marchandises"],
|
||||
keep: ["Keep", "Garder"],
|
||||
|
|
@ -230,7 +304,7 @@ const labels = {
|
|||
bohioMove: ["Move a Bohío worker", "Déplacer un ouvrier du Bohío"],
|
||||
outpost: ["Outpost", "Relais"],
|
||||
finalScore: ["Final scores", "Scores finaux"],
|
||||
tie: ["Coins + crates (tiebreak)", "Pièces + caisses (départage)"],
|
||||
tie: ["Coins + goods (tiebreak)", "Pièces + marchandises (départage)"],
|
||||
tokens: ["VP tokens", "Jetons de score"],
|
||||
bonuses: ["Bonifications", "Bonus"],
|
||||
finished: ["Game over", "Partie terminée"],
|
||||
|
|
@ -247,8 +321,8 @@ const labels = {
|
|||
],
|
||||
unassigned: ["Unassigned", "À affecter"],
|
||||
storageHint: [
|
||||
"Keep one crate, plus the storage provided by occupied buildings.",
|
||||
"Gardez une caisse, plus le stockage de vos bâtiments occupés.",
|
||||
"Keep one good, plus the storage provided by occupied buildings.",
|
||||
"Gardez une marchandise, plus le stockage de vos bâtiments occupés.",
|
||||
],
|
||||
full: ["Full", "Plein"],
|
||||
dispatch: ["Dispatched", "Expédié"],
|
||||
|
|
@ -346,7 +420,10 @@ const labels = {
|
|||
"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"],
|
||||
ruleProductionTitle: [
|
||||
"From an estate to a good",
|
||||
"Du domaine à la marchandise",
|
||||
],
|
||||
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 :",
|
||||
|
|
@ -374,8 +451,8 @@ const labels = {
|
|||
],
|
||||
ruleShipTitle: ["Captain → VP", "Capitaine → points"],
|
||||
ruleShip: [
|
||||
"Take turns loading one type for {vp:1} 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 {vp:1} 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.",
|
||||
"Take turns loading one type for {vp:1} per good. 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 {vp:1} par marchandise. C’est obligatoire si possible : utilisez le bateau acceptant le plus de marchandises 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 {crate:1} in total (more with storage buildings) and discard the rest. Full ships then empty; the others keep their cargo.",
|
||||
|
|
@ -458,8 +535,8 @@ const labels = {
|
|||
"Ouvrier si les citoyens sont épuisés",
|
||||
],
|
||||
totalStorage: [
|
||||
"Store all crates of this type",
|
||||
"Conserver toutes les caisses de ce type",
|
||||
"Store all goods of this type",
|
||||
"Conserver toutes les marchandises de ce type",
|
||||
],
|
||||
stockAvailableOne: ["available", "disponible"],
|
||||
stockAvailable: ["available", "disponibles"],
|
||||
|
|
@ -483,17 +560,20 @@ const labels = {
|
|||
journalBuild: ["Built", "Construction :"],
|
||||
journalProduce: ["Produced", "Production :"],
|
||||
journalNothing: ["Produced no goods", "Aucune production"],
|
||||
journalBonus: ["Bonus crate:", "Caisse bonus :"],
|
||||
journalBonus: ["Bonus good:", "Marchandise bonus :"],
|
||||
journalTrade: ["Sold", "Vente :"],
|
||||
journalShip: ["Shipped", "Expédition :"],
|
||||
journalStore: ["Kept", "Caisses conservées :"],
|
||||
journalLost: ["Discarded", "Caisses perdues :"],
|
||||
journalNoGoods: ["no crates", "aucune caisse"],
|
||||
journalStore: ["Kept", "Marchandises conservées :"],
|
||||
journalLost: ["Discarded", "Marchandises perdues :"],
|
||||
journalNoGoods: ["no goods", "aucune marchandise"],
|
||||
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 :"],
|
||||
journalRaid: [
|
||||
"Ship raided, goods taken:",
|
||||
"Bateau pillé, marchandises prises :",
|
||||
],
|
||||
journalPlunder: [
|
||||
"Trading house plundered and emptied",
|
||||
"Marché pillé et vidé",
|
||||
|
|
|
|||
|
|
@ -19,12 +19,10 @@ const paths = {
|
|||
coin: '<circle fill="#e7be63" cx="12" cy="12" r="10"/><path d="M12 6v12m3-10c-6-4-8 4-3 4s3 8-3 4"/>',
|
||||
building:
|
||||
'<path fill="#d6b994" d="M4 10h16v12H4Z"/><path fill="#b16b4e" d="m2 10 10-8 10 8Z"/><path d="M10 22v-7h4v7M7 13v3m10-3v3"/>',
|
||||
crate:
|
||||
'<rect x="3" y="4" width="18" height="17" rx="2" fill="#c8a77a"/><path d="M3 8h18M3 17h18M7 4v17M17 4v17m-7-9h4"/>',
|
||||
storage:
|
||||
'<path fill="#b6b69a" d="M3 9h18v13H3Z"/><path fill="#9b7555" d="m1 9 11-7 11 7Z"/><rect x="8" y="13" width="8" height="9" fill="#d4b989"/><path d="M8 17h8"/>',
|
||||
estate:
|
||||
'<path fill="#8eab6b" d="m3 8 9-5 9 5v11l-9 3-9-3Z"/><path d="m3 8 9 4 9-4m-9 4v10M6 13l3 1m-3 3 3 1m6-4 3-1m-3 5 3-1"/>',
|
||||
'<path fill="#78965c" d="m1 15 11-7 11 7-11 8Z"/><path stroke="#d7e2ad" d="m5 15 7 5m-4-7 7 5m-4-7 7 5"/><path d="M12 12V5"/><path fill="#a8c478" d="M12 8C7 8 6 5 6 2c4 0 6 2 6 6Zm0-2c5 0 7-2 7-5-4 0-7 2-7 5Z"/>',
|
||||
space:
|
||||
'<rect x="3" y="3" width="18" height="18" rx="3" stroke-dasharray="3 3"/><circle cx="12" cy="12" r="2" fill="currentColor" stroke="none"/>',
|
||||
citySpace:
|
||||
|
|
@ -42,7 +40,7 @@ const paths = {
|
|||
builder:
|
||||
'<path fill="#b87955" d="m4 18 10-11 3 3L7 21Z"/><path fill="#abbac0" d="m10 5 4-4 9 8-5 4Z"/>',
|
||||
craftsman:
|
||||
'<path fill="#d6b994" d="M3 7h18v14H3Z"/><path d="M3 12h18M8 7v14m8-14v14m-9-17h10"/>',
|
||||
'<path fill="#9ca9b0" d="m14 2 3 1-1 5-3 2-3-1-6 11-3-2 7-10-1-3 2-3 1 4 3 1Z"/><path fill="#cfa474" d="m13 14 3-3 7 9-3 2Z"/>',
|
||||
trader:
|
||||
'<path fill="#d6b994" d="M5 9h14v13H5Z"/><path fill="#c27952" d="M2 3h20v6H2Z"/><path d="M8 3v6m8-6v6M10 22v-8h4v8"/>',
|
||||
captain:
|
||||
|
|
@ -91,5 +89,15 @@ export function scoreToken(value, size = 26) {
|
|||
}
|
||||
export function icon(id, size = 24) {
|
||||
if (id === "vp") return scoreToken(1, size);
|
||||
return `<svg class="icon icon-${id}" width="${size}" height="${size}" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${paths[id] ?? paths.building}</svg>`;
|
||||
const crop = id.split("-")[1];
|
||||
let drawing = paths[id] ?? paths.building;
|
||||
if (id === "crate")
|
||||
drawing = `<g transform="translate(0 1) scale(.65)">${paths.corn}</g><g transform="translate(10 2) scale(.58)">${paths.coffee}</g><g transform="translate(7 10) scale(.6)">${paths.fruit}</g>`;
|
||||
if (["corn", "fruit", "sugar", "tobacco", "coffee"].includes(crop)) {
|
||||
if (id.startsWith("field-"))
|
||||
drawing = `<path fill="#78965c" d="m1 15 11-7 11 7-11 8Z"/><path stroke="#d7e2ad" d="m5 15 7 5m-4-7 7 5m-4-7 7 5"/><g transform="translate(6 0) scale(.5)">${paths[crop]}</g>`;
|
||||
if (id.startsWith("workshop-"))
|
||||
drawing = `<path fill="#d6b994" d="M3 10h18v12H3Z"/><path fill="#b16b4e" d="m1 10 11-8 11 8Z"/><g transform="translate(7 10) scale(.42)">${paths[crop]}</g>`;
|
||||
}
|
||||
return `<svg class="icon icon-${id}" width="${size}" height="${size}" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${drawing}</svg>`;
|
||||
}
|
||||
|
|
|
|||
44
viewer/production.js
Normal file
44
viewer/production.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { BUILDINGS, GOODS } from "../engine/catalog.js";
|
||||
import { production } from "../engine/index.js";
|
||||
|
||||
// Explain the engine's capacity without simulating a production action.
|
||||
export function productionLines(player, supply) {
|
||||
if (player.puertoma) return [];
|
||||
const capacity = production(player);
|
||||
return GOODS.flatMap((good) => {
|
||||
const estates = player.estates.filter((e) => e.id === good);
|
||||
const buildings = player.buildings.filter(
|
||||
(b) => BUILDINGS[b.id].good === good,
|
||||
);
|
||||
if (!estates.length && !buildings.length) return [];
|
||||
const farms = estates.reduce((n, e) => n + e.w + e.c, 0);
|
||||
const workshops = buildings.reduce((n, b) => n + b.w + b.c, 0);
|
||||
const available = Math.min(capacity[good], supply[good]);
|
||||
const issue = !estates.length
|
||||
? "needPlantation"
|
||||
: !farms
|
||||
? "staffPlantation"
|
||||
: good !== "corn" && !buildings.length
|
||||
? "needWorkshop"
|
||||
: good !== "corn" && !workshops
|
||||
? "staffWorkshop"
|
||||
: available < capacity[good]
|
||||
? "limitedSupply"
|
||||
: "productionReady";
|
||||
return [
|
||||
{
|
||||
good,
|
||||
farms,
|
||||
farmCount: estates.length,
|
||||
workshops,
|
||||
workshopCount: buildings.reduce(
|
||||
(n, b) => n + BUILDINGS[b.id].workers,
|
||||
0,
|
||||
),
|
||||
capacity: capacity[good],
|
||||
available,
|
||||
issue,
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ const symbols = {
|
|||
["point de victoire", "points de victoire"],
|
||||
],
|
||||
coin: ["coin", ["coin", "coins"], ["pièce", "pièces"]],
|
||||
crate: ["crate", ["crate", "crates"], ["caisse", "caisses"]],
|
||||
crate: ["crate", ["good", "goods"], ["marchandise", "marchandises"]],
|
||||
worker: ["worker", ["worker", "workers"], ["ouvrier", "ouvriers"]],
|
||||
citizen: ["citizen", ["citizen", "citizens"], ["citoyen", "citoyens"]],
|
||||
estate: ["estate", ["estate", "estates"], ["domaine", "domaines"]],
|
||||
|
|
@ -77,7 +77,7 @@ function format(message, fr, html) {
|
|||
.split("/")
|
||||
.map((n) => scoreToken(n, 24))
|
||||
.join('<span class="symbol-separator">/</span>')
|
||||
: `${amount === undefined ? "" : `<b>${escape(amount)}</b>`}${icon(id, 22)}`;
|
||||
: `${amount === undefined ? "" : `<b>${escape(amount)}</b>`}${icon(id, 22)}${id === "crate" ? `<span class="symbol-word">${escape((fr ? french : en)[plural ? 1 : 0])}</span>` : ""}`;
|
||||
result += `<span class="inline-symbol${amount?.includes("/") ? " symbol-range" : ""}" role="img" aria-label="${escape(label)}" title="${escape(label)}"><span aria-hidden="true">${visual}</span></span>`;
|
||||
} else result += label;
|
||||
end = match.index + marker.length;
|
||||
|
|
|
|||
237
viewer/style.css
237
viewer/style.css
|
|
@ -1803,3 +1803,240 @@
|
|||
height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
/* A field tile, a workshop and a loose product have distinct silhouettes. */
|
||||
.pr-game .plantation-supply {
|
||||
margin-top: 12px;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-left: 3px solid var(--foliage);
|
||||
background: var(--panel);
|
||||
}
|
||||
.pr-game .plantation-supply > header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
}
|
||||
.pr-game .plantation-supply h3 {
|
||||
margin: 0;
|
||||
}
|
||||
.pr-game .plantation-supply .estate-offer {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.pr-game .plantation-supply .offer {
|
||||
width: auto;
|
||||
min-width: 48px;
|
||||
min-height: 62px;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
padding: 5px;
|
||||
background: var(--selected);
|
||||
font-size: 10px;
|
||||
}
|
||||
.pr-game .estate-name {
|
||||
font-size: 10px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.pr-game .building-kind {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
font: 600 10px system-ui;
|
||||
color: var(--muted);
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.pr-game .staffed-icon {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
padding-right: 8px;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
.pr-game .staffed-icon > .icon-worker {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: var(--card);
|
||||
border-radius: 50%;
|
||||
}
|
||||
.pr-game .stock-label {
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.pr-game .inline-symbol .symbol-word {
|
||||
font-size: 0.9em;
|
||||
line-height: 1;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.pr-game .inline-symbol:has(.symbol-word) {
|
||||
height: auto;
|
||||
}
|
||||
.pr-game .production-overview {
|
||||
margin: 10px 0 16px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: var(--card);
|
||||
}
|
||||
.pr-game .production-overview > header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
.pr-game .player-board .production-overview h3 {
|
||||
margin: 0 0 3px;
|
||||
color: var(--ink);
|
||||
}
|
||||
.pr-game .production-overview header small {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.pr-game .production-help {
|
||||
min-height: 26px;
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
padding: 4px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.pr-game .production-line + .production-line {
|
||||
border-top: 1px solid var(--line);
|
||||
padding-top: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.pr-game .production-good {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-size: 12px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.pr-game .production-flow {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 18px auto;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
.pr-game .production-step {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-height: 46px;
|
||||
padding: 5px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.pr-game .production-step > .icon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.pr-game .production-step small {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.pr-game .production-step > span > small:first-child {
|
||||
display: block;
|
||||
}
|
||||
.pr-game .production-step.not-needed {
|
||||
background: transparent;
|
||||
border-style: dashed;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
.pr-game .production-join {
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
.pr-game .production-output {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
padding: 5px;
|
||||
min-width: 42px;
|
||||
text-align: center;
|
||||
}
|
||||
.pr-game .production-line.blocked .production-output {
|
||||
color: var(--muted);
|
||||
}
|
||||
.pr-game .production-line.ready .production-output {
|
||||
background: var(--selected);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pr-game .production-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.pr-game .production-destination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
border-top: 1px solid var(--line);
|
||||
margin-top: 10px;
|
||||
padding-top: 8px;
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.pr-game .production-destination > span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
}
|
||||
.pr-game .production-or {
|
||||
margin: 0 3px;
|
||||
}
|
||||
.pr-game .production-guide-flow {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
.pr-game .production-guide-flow > span {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
}
|
||||
.pr-game .production-guide p + p {
|
||||
margin-top: 12px;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.pr-game .production-overview {
|
||||
padding: 9px;
|
||||
}
|
||||
.pr-game .production-flow {
|
||||
grid-template-columns: minmax(0, 1fr) 9px minmax(0, 1fr) 14px auto;
|
||||
gap: 3px;
|
||||
}
|
||||
.pr-game .production-step {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
gap: 2px;
|
||||
}
|
||||
.pr-game .production-step > .icon {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
}
|
||||
.pr-game .production-output {
|
||||
font-size: 16px;
|
||||
min-width: 36px;
|
||||
padding: 3px;
|
||||
}
|
||||
.pr-game .production-guide-flow {
|
||||
gap: 5px;
|
||||
}
|
||||
.pr-game .production-guide-flow > span > .icon {
|
||||
max-width: 38px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
72
viewer/ui.js
72
viewer/ui.js
|
|
@ -9,7 +9,6 @@ import {
|
|||
autoAssignment,
|
||||
autoStorage,
|
||||
cost,
|
||||
production,
|
||||
citySize,
|
||||
} from "../engine/index.js";
|
||||
import { translator } from "./i18n.js";
|
||||
|
|
@ -20,6 +19,7 @@ import { richText } from "./rich-text.js";
|
|||
import { town } from "./town.js";
|
||||
import css from "./style.css";
|
||||
import { achievementText, abilityTexts } from "./achievement-text.js";
|
||||
import { productionLines } from "./production.js";
|
||||
import { estateCapacity } from "../engine/puertoma.js";
|
||||
|
||||
const esc = (x) =>
|
||||
|
|
@ -43,7 +43,11 @@ const playerShapes = [
|
|||
'<path d="M8 2h8v6h6v8h-6v6H8v-6H2V8h6Z"/>',
|
||||
];
|
||||
const spriteFor = (id) =>
|
||||
B[id]?.good && B[id].good !== "tailor" ? B[id].good : "building";
|
||||
B[id]?.good && B[id].good !== "tailor"
|
||||
? `workshop-${B[id].good}`
|
||||
: ["smallWarehouse", "largeWarehouse", "storehouse"].includes(id)
|
||||
? "storage"
|
||||
: "building";
|
||||
export function mountGame(
|
||||
target,
|
||||
{ onMove, chat, onOpenPlayer, localControls, automatedSetup = false } = {},
|
||||
|
|
@ -397,9 +401,34 @@ export function mountGame(
|
|||
: `<span class="worker-slot ${k ?? ""}">${k ? icon(k === "c" ? "citizen" : "worker", 20) : "·"}</span>`;
|
||||
}).join("")}</div>`;
|
||||
}
|
||||
function productionOverview(a) {
|
||||
if (a.puertoma) return "";
|
||||
const preview =
|
||||
draft &&
|
||||
state.tasks[0]?.kind === "assign" &&
|
||||
view === seat &&
|
||||
state.tasks[0]?.p === seat
|
||||
? {
|
||||
...a,
|
||||
estates: a.estates.map((x, i) => ({ ...x, ...draft.estates[i] })),
|
||||
buildings: a.buildings.map((x, i) => ({
|
||||
...x,
|
||||
...draft.buildings[i],
|
||||
})),
|
||||
}
|
||||
: a;
|
||||
const lines = productionLines(preview, state.supply);
|
||||
return `<section class="production-overview"><header><div><h3>${t(view === seat ? "productionTitle" : "otherProduction")}</h3><small>${t("productionTiming")}</small></div><button type="button" class="production-help" data-production-help title="${esc(t("productionHelp"))}" aria-label="${esc(t("productionHelp"))}">${icon("help", 16)}</button></header>${lines.length ? lines.map((line) => `<div class="production-line ${line.available ? "ready" : "blocked"}" data-production-good="${line.good}"><strong class="production-good">${icon(line.good, 20)}${t(line.good)}</strong><div class="production-flow"><span class="production-step">${icon(`field-${line.good}`, 30)}<span><small>${t("plantationLabel")}</small><b>${line.farms} / ${line.farmCount}</b> <small>${t("occupiedLabel")}</small></span></span><span class="production-join">${line.good === "corn" ? "" : "+"}</span><span class="production-step ${line.good === "corn" ? "not-needed" : ""}">${line.good === "corn" ? `<small>${t("noWorkshopNeeded")}</small>` : `${icon(`workshop-${line.good}`, 30)}<span><small>${t("workSlots")}</small>${line.workshopCount ? `<b>${line.workshops} / ${line.workshopCount}</b> <small>${t("occupiedSlots")}</small>` : `<b>${t("toBuild")}</b>`}</span>`}</span>${icon("arrow", 18)}<span class="production-output" aria-label="${esc(`${t(line.good)} : ${line.available}`)}">${metric(line.good, line.available)}</span></div><small class="production-status">${line.available ? icon("check", 13) : ""}${t(line.issue)}${line.capacity > (line.good === "corn" ? line.farms : Math.min(line.farms, line.workshops)) ? ` · ${t("canal")} +1` : ""}</small></div>`).join("") : `<p>${t("noProductionYet")}</p>`}<div class="production-destination"><span>${t("stockLabel")}</span>${icon("arrow", 14)}<span>${icon("trader", 18)}${t("trader")} ${icon("arrow", 12)}${icon("coin", 18)}</span><span class="production-or">/</span><span>${icon("captain", 18)}${t("captain")} ${icon("arrow", 12)}${scoreToken(1, 18)}</span></div></section>`;
|
||||
}
|
||||
function productionHelp() {
|
||||
show(
|
||||
t("productionHelp"),
|
||||
`<div class="production-guide"><div class="production-guide-flow"><span>${icon("field-fruit", 48)}<b>${t("plantationLabel")}</b>${icon("worker", 20)}</span><b>+</b><span>${icon("workshop-fruit", 48)}<b>${t("productionBuilding")}</b>${icon("worker", 20)}</span>${icon("arrow", 24)}<span>${icon("fruit", 42)}<b>1 ${t("fruit")}</b></span></div><p>${t("productionPair")}</p><p>${t("productionIntro")}</p><p>${t("goodsMeaning")}</p><p>${t("useStock")}</p><p>${t("storageMeaning")}</p></div>`,
|
||||
);
|
||||
}
|
||||
function playerBoard() {
|
||||
const a = state.players[view];
|
||||
return `<section class="player-board panel" id="own-board"><header><h2>${playerMarker(view, true)}${esc(a.name)}</h2></header><h3>${t("countryside")} <small>${a.estates.filter((x) => (!x.vpArea && x.id !== "quarry") || !a.puertoma).length}/${a.puertoma ? 10 : 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, a.puertoma ? (x.vpArea ? 0 : estateCapacity(x.id)) : 1) : ""}</article>`).join("")}${Array.from({ length: Math.max(0, (a.puertoma ? 10 : 12) - a.estates.length) }, () => '<span class="estate empty-estate"></span>').join("")}</div><h3>${t("city")} <small>${a.puertoma ? a.buildings.length : citySize(a)}/${a.puertoma ? 8 : 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>${pointsBadge(B[x.id].vp)}</button>${a.puertoma ? `<small>${t.fr ? "Niveau" : "Level"} ${x.level}</small>` : peopleSlots(`b${i}`, x, B[x.id].workers)}</article>`).join("")}${a.buildings.length ? "" : `<div class="empty-city">${town}<span>${t("emptyCity")}</span></div>`}</div>${achievements(a)}${puertomaBoard(a)}<button class="mobile-market-launch" data-market>${icon("building")} ${t("market")}</button></section>`;
|
||||
return `<section class="player-board panel" id="own-board"><header><h2>${playerMarker(view, true)}${esc(a.name)}</h2></header>${productionOverview(a)}<h3>${t("countryside")} <small>${a.estates.filter((x) => (!x.vpArea && x.id !== "quarry") || !a.puertoma).length}/${a.puertoma ? 10 : 12}</small></h3><div class="estates">${a.estates.map((x, i) => `<article class="estate ${x.id}" title="${esc(t(x.id))}">${icon(GOODS.includes(x.id) ? `field-${x.id}` : x.id, 36)}<span class="estate-name">${t(x.id)}</span>${x.id !== "forest" ? peopleSlots(`e${i}`, x, a.puertoma ? (x.vpArea ? 0 : estateCapacity(x.id)) : 1) : ""}</article>`).join("")}${Array.from({ length: Math.max(0, (a.puertoma ? 10 : 12) - a.estates.length) }, () => '<span class="estate empty-estate"></span>').join("")}</div><h3>${t("city")} <small>${a.puertoma ? a.buildings.length : citySize(a)}/${a.puertoma ? 8 : 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)}${B[x.id].good && B[x.id].good !== "tailor" ? `<small class="building-kind">${t("productionBuilding")}</small>` : ""}</span>${pointsBadge(B[x.id].vp)}</button>${a.puertoma ? `<small>${t.fr ? "Niveau" : "Level"} ${x.level}</small>` : peopleSlots(`b${i}`, x, B[x.id].workers)}</article>`).join("")}${a.buildings.length ? "" : `<div class="empty-city">${town}<span>${t("emptyCity")}</span></div>`}</div>${achievements(a)}${puertomaBoard(a)}<button class="mobile-market-launch" data-market>${icon("building")} ${t("market")}</button></section>`;
|
||||
}
|
||||
function achievements(a) {
|
||||
if (!a.achievements) return "";
|
||||
|
|
@ -429,36 +458,36 @@ export function mountGame(
|
|||
})
|
||||
.join(
|
||||
"",
|
||||
)}<button type="button" class="role role-help" data-roles-help title="${esc(t("rolesHelp"))}" aria-label="${esc(t("rolesHelp"))}">${icon("help", 32)}</button></div><div class="port panel"><header><h2>${t("harborTitle")}</h2><div>${metric("vp", Math.max(0, state.vpSupply))}${metric("worker", state.register.w)}${state.register.c ? metric("citizen", state.register.c) : ""}</div></header><div class="ships">${state.ships.map((sh, i) => `<article class="ship ${sh.amount === sh.capacity ? "full" : ""}">${shipGraphic(sh)}<div>${sh.good ? icon(sh.good, 25) : icon("ship", 25)}<b>${sh.amount}<small> / ${sh.capacity}</small></b></div></article>`).join("")}</div><div class="trade-row"><span>${t("tradingHouse")}</span>${Array.from({ length: 4 }, (_, i) => `<span class="trade-slot">${state.trade[i] ? icon(state.trade[i], 26) : "·"}</span>`).join("")}</div><div class="estate-offer">${state.offer
|
||||
)}<button type="button" class="role role-help" data-roles-help title="${esc(t("rolesHelp"))}" aria-label="${esc(t("rolesHelp"))}">${icon("help", 32)}</button></div><div class="port panel"><header><h2>${t("harborTitle")}</h2><div>${metric("vp", Math.max(0, state.vpSupply))}${metric("worker", state.register.w)}${state.register.c ? metric("citizen", state.register.c) : ""}</div></header><div class="ships">${state.ships.map((sh, i) => `<article class="ship ${sh.amount === sh.capacity ? "full" : ""}">${shipGraphic(sh)}<div>${sh.good ? icon(sh.good, 25) : icon("ship", 25)}<b>${sh.amount}<small> / ${sh.capacity}</small></b></div></article>`).join("")}</div><div class="trade-row"><span>${icon("trader", 18)} ${t("tradingHouse")}</span>${Array.from({ length: 4 }, (_, i) => `<span class="trade-slot">${state.trade[i] ? icon(state.trade[i], 26) : "·"}</span>`).join("")}</div></div><section class="plantation-supply"><header>${icon("planter", 20)}<h3>${t("plantedOffer")}</h3></header><div class="estate-offer">${state.offer
|
||||
.map((id, i) => {
|
||||
const m = state.legal.find(
|
||||
(m) => m.type === "plant" && m.id === id && !m.forest,
|
||||
);
|
||||
return `<button class="offer ${id}" ${m && acting ? `data-move="${encode(m)}"` : "disabled"} title="${esc(t(id))}">${icon(id, 28)}</button>`;
|
||||
return `<button class="offer ${id}" ${m && acting ? `data-move="${encode(m)}"` : "disabled"} title="${esc(t(id))}">${icon(GOODS.includes(id) ? `field-${id}` : id, 32)}<span>${t(id)}</span></button>`;
|
||||
})
|
||||
.join("")}${(() => {
|
||||
const m = state.legal.find(
|
||||
(m) => m.type === "plant" && m.id === "quarry",
|
||||
);
|
||||
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" aria-label="${t("festival")}">${state.festivals.map((f, i) => `<button data-festival="${i}" class="festival ${f.claimed !== undefined ? "claimed" : ""}"><span class="festival-heading">${icon("festival", 22)}<span><small>${t("sharedObjective")}</small><strong>${t(f.id)}</strong></span></span><span class="festival-condition">${festivalCondition(f)}</span><span class="festival-reward"><small>${t("reward")}</small><span>${festivalReward(f)}</span></span>${f.claimed !== undefined ? `<span class="festival-claimed">${icon("check", 16)}${t("claimed")} ${esc(state.players[f.claimed].name)}</span>` : ""}</button>`).join("")}</section>` : ""}</section>`;
|
||||
return `<button class="offer quarry" ${m && acting ? `data-move="${encode(m)}"` : "disabled"} title="${esc(t("quarry"))}">${icon("quarry", 28)}<span>${t("quarry")}</span><small>${state.quarries}</small></button>`;
|
||||
})()}${acting && task.kind === "plant" && state.legal.some((m) => m.forest) ? `<button data-forests>${icon("forest")} ${t("forest")}</button>` : ""}</div></section>${state.festivals.length ? `<section class="festival-strip" aria-label="${t("festival")}">${state.festivals.map((f, i) => `<button data-festival="${i}" class="festival ${f.claimed !== undefined ? "claimed" : ""}"><span class="festival-heading">${icon("festival", 22)}<span><small>${t("sharedObjective")}</small><strong>${t(f.id)}</strong></span></span><span class="festival-condition">${festivalCondition(f)}</span><span class="festival-reward"><small>${t("reward")}</small><span>${festivalReward(f)}</span></span>${f.claimed !== undefined ? `<span class="festival-claimed">${icon("check", 16)}${t("claimed")} ${esc(state.players[f.claimed].name)}</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, html = false) {
|
||||
const b = B[id];
|
||||
return b.good && b.good !== "tailor"
|
||||
? html
|
||||
? richText(`${t("produce")} : {${b.good}}.`, t.fr)
|
||||
: `${t("produce")} : ${t(b.good)}.`
|
||||
: html
|
||||
? t.effectHtml(id)
|
||||
: t.effect(id);
|
||||
if (b.good && b.good !== "tailor") {
|
||||
const message = `${t("productionCapacity")} : ${b.workers} ${t(b.good)}. ${t("matchingWorkers")}`;
|
||||
return html
|
||||
? `${richText(`${t("productionCapacity")} : {${b.good}:${b.workers}}.`, t.fr)} ${esc(t("matchingWorkers"))}`
|
||||
: message;
|
||||
}
|
||||
return html ? t.effectHtml(id) : t.effect(id);
|
||||
}
|
||||
function playerCard(p, i) {
|
||||
const goods = GOODS.filter((g) => p.goods[g] > 0);
|
||||
return `<button data-player="${i}" class="player-tab ${i === view ? "selected" : ""} ${i === state.tasks[0]?.p ? "turn" : ""}"><span class="player-card-top"><span class="player-name">${playerMarker(i, true)}${i === state.governor ? icon("governor", 18) : ""}${esc(p.name)}${playerBadge(i)}</span><span class="player-card-score">${metric("coin", p.coins)}${metric("vp", p.vp ?? "?")}</span></span>${goods.length ? `<span class="player-card-goods">${goods.map((g) => `<span title="${esc(`${t(g)} : ${p.goods[g]}`)}" aria-label="${esc(`${t(g)} : ${p.goods[g]}`)}">${metric(g, p.goods[g])}</span>`).join("")}</span>` : ""}</button>`;
|
||||
return `<button data-player="${i}" class="player-tab ${i === view ? "selected" : ""} ${i === state.tasks[0]?.p ? "turn" : ""}"><span class="player-card-top"><span class="player-name">${playerMarker(i, true)}${i === state.governor ? icon("governor", 18) : ""}${esc(p.name)}${playerBadge(i)}</span><span class="player-card-score">${metric("coin", p.coins)}${metric("vp", p.vp ?? "?")}</span></span>${goods.length ? `<span class="player-card-goods"><small class="stock-label">${t("stockLabel")}</small>${goods.map((g) => `<span title="${esc(`${t(g)} : ${p.goods[g]}`)}" aria-label="${esc(`${t(g)} : ${p.goods[g]}`)}">${metric(g, p.goods[g])}</span>`).join("")}</span>` : ""}</button>`;
|
||||
}
|
||||
function playerSummary() {
|
||||
const a = state.players[seat];
|
||||
|
|
@ -501,7 +530,7 @@ export function mountGame(
|
|||
? t("soldOut")
|
||||
: `${n} ${t(n === 1 ? "stockAvailableOne" : "stockAvailable")}`;
|
||||
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-title">${icon(spriteFor(id), 30)}<strong>${t(id)}</strong></span>
|
||||
<span class="bcard-title">${icon(spriteFor(id), 30)}<strong>${t(id)}${b.good && b.good !== "tailor" ? `<small class="building-kind">${t("productionBuilding")}</small>` : ["smallWarehouse", "largeWarehouse", "storehouse"].includes(id) ? `<small class="building-kind">${t("storageBuilding")}</small>` : ""}</strong></span>
|
||||
<span class="bcard-cost" title="${esc(`${t("cost")} : ${price}`)}" aria-label="${esc(`${t("cost")} : ${price}`)}">${metric("coin", price)}</span>
|
||||
<span class="bcard-effect">${buildingSymbols(id, t)}</span>
|
||||
<span class="bcard-stats">${pointsBadge(b.vp)}${buildingSlots(b)}</span>
|
||||
|
|
@ -639,19 +668,20 @@ export function mountGame(
|
|||
);
|
||||
}
|
||||
function festivalCondition(f) {
|
||||
const targets = (ids, amounts) => {
|
||||
const targets = (ids, amounts, fields = false) => {
|
||||
const counts = {};
|
||||
ids.forEach((id, i) => {
|
||||
counts[id] = (counts[id] ?? 0) + (amounts?.[i] ?? f.amount ?? 1);
|
||||
});
|
||||
return `<span class="festival-targets">${Object.entries(counts)
|
||||
.map(
|
||||
([id, n]) => `<span>${icon(id, 20)}<b>${n}</b> ${esc(t(id))}</span>`,
|
||||
([id, n]) =>
|
||||
`<span>${icon(fields ? `field-${id}` : id, 20)}<b>${n}</b> ${esc(t(id))}</span>`,
|
||||
)
|
||||
.join("")}</span>`;
|
||||
};
|
||||
const goods = targets(f.targets.goods, f.amounts);
|
||||
const estates = targets(f.targets.estates);
|
||||
const estates = targets(f.targets.estates, null, true);
|
||||
const row = (label, content) =>
|
||||
`<span class="festival-requirement"><span>${t.html(label)}</span>${content}</span>`;
|
||||
if (f.goal === "estates") return row("festivalEstates", estates);
|
||||
|
|
@ -801,6 +831,10 @@ export function mountGame(
|
|||
show(t("rules"), howToPlay(), "rules");
|
||||
return;
|
||||
}
|
||||
if (el.hasAttribute("data-production-help")) {
|
||||
productionHelp();
|
||||
return;
|
||||
}
|
||||
if (el.hasAttribute("data-achievements-help")) {
|
||||
show(
|
||||
t("achievementHelpTitle"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue