Unify expanded building icons across cards and achievements

This commit is contained in:
coyotte508 2026-10-07 01:33:46 +02:00
commit 2de6743864
9 changed files with 67 additions and 27 deletions

View file

@ -41,7 +41,7 @@ export function achievementText(id, t) {
html: "",
};
const english = {
spendAll: "Build an expanded Building by paying all your {coins}.",
spendAll: "Build an {expanded} by paying all your {coins}.",
goodsPair: `Have at least ${c.amount} ${(c.goods ?? []).map((g) => `{${g}}`).join(" / ")} combined, including at least one of each.`,
dispatch: `Place the last {crate} of {${c.good}} on a cargo ship to fill it.`,
closeTrade: "Sell the fourth Good to the Trading House as the {trader}.",
@ -54,7 +54,8 @@ export function achievementText(id, t) {
produce: "Produce at least {crate:7} during one {craftsman} phase.",
productionSet:
"Have at least 1 {sugar}, 1 {tobacco}, and 1 {coffee} Production Building.",
cheapExpanded: "Build an expanded Building paying a maximum of {coin:6}.",
expanded: "Have at least {expanded:2}.",
cheapExpanded: "Build an {expanded} paying a maximum of {coin:6}.",
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 type at once.",
@ -64,7 +65,7 @@ export function achievementText(id, t) {
"Have at least 3 {fruit} and/or {sugar} Production Buildings.",
};
const objectives = {
spendAll: "Construire un bâtiment étendu en dépensant toutes vos {coins}.",
spendAll: "Construire un {expanded} en dépensant toutes vos {coins}.",
goodsPair: `Posséder au moins ${c.amount} ${(c.goods ?? []).map((g) => `{${g}}`).join(" / ")} au total, dont au moins une de chaque.`,
dispatch: `Placer la dernière {crate} de {${c.good}} sur un navire de charge et le remplir.`,
closeTrade:
@ -79,12 +80,11 @@ export function achievementText(id, t) {
produce: "Produire au moins {crate:7} durant une même phase {craftsman}.",
productionSet:
"Posséder au moins un bâtiment de production de {sugar}, de {tobacco} et de {coffee}.",
expanded: "Posséder au moins 2 bâtiments étendus.",
expanded: "Posséder au moins {expanded:2}.",
developed:
"Avoir au maximum 2 espaces libres dans la campagne et 2 espaces libres dans la ville.",
estates: "Posséder 12 tuiles de campagne.",
cheapExpanded:
"Construire un bâtiment étendu en payant au maximum {coin:6}.",
cheapExpanded: "Construire un {expanded} en payant au maximum {coin:6}.",
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}.",

View file

@ -17,6 +17,15 @@ 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 const buildingSprite = (id) =>
B[id]?.size === 2
? "expandedBuilding"
: B[id]?.good && B[id].good !== "tailor"
? `workshop-${B[id].good}`
: ["smallWarehouse", "largeWarehouse", "storehouse"].includes(id)
? "storage"
: "building";
export function buildingSymbols(id, t) {
const caption = (key) =>
`<small class="effect-caption">${t.html(key)}</small>`;
@ -165,7 +174,11 @@ export function buildingSymbols(id, t) {
case "notary":
visual =
row(icon("worker"), icon("building"), quantity("coin", "−1")) +
row(icon("citizen"), icon("citySpace"), quantity("coin", "−2"));
row(
icon("citizen"),
icon("expandedBuilding"),
quantity("coin", "−2"),
);
break;
case "villa":
visual =

View file

@ -627,6 +627,7 @@ const labels = {
workerSpaces: ["Worker slots", "Places d’ouvriers"],
citySpaces: ["City spaces", "Cases de ville"],
twoCitySpaces: ["2 city spaces", "2 cases de ville"],
expandedBuilding: ["Expanded building", "Bâtiment étendu"],
printedPoints: ["Points at game end", "Points en fin de partie"],
journalSetup: ["Setup", "Mise en place"],
journalPreviewSetup: [
@ -779,8 +780,8 @@ const effects = {
"Vendez directement à la réserve, sans bonus des marchés.",
],
church: [
"Build a {vp:2/3} building: {vp:+1}. Expanded building: {vp:+2}.",
"Bâtiment de {vp:2/3} construit : {vp:+1}. Grand bâtiment : {vp:+2}.",
"Build a {vp:2/3} building: {vp:+1}. Build an {expanded}: {vp:+2}.",
"Bâtiment de {vp:2/3} construit : {vp:+1}. Un {expanded} : {vp:+2}.",
],
smallWharf: [
"Once per {captain}: ship any mixed cargo, for {vp:1} per {crate:2}.",
@ -823,8 +824,8 @@ const effects = {
"{planter} : l’{worker} peut retirer un domaine/{forest} ; le {citizen} gagne {vp:2} si vous avez strictement le moins de tuiles de campagne.",
],
notary: [
"{worker}: regular buildings cost {coin:1} less. {citizen}: expanded buildings cost {coin:2} less.",
"{worker} : {coin:−1} sur les bâtiments simples. {citizen} : {coin:−2} sur les grands bâtiments.",
"{worker}: regular buildings cost {coin:1} less. {citizen}: {expandedbuildings} cost {coin:2} less.",
"{worker} : {coin:−1} sur les bâtiments simples. {citizen} : {coin:−2} sur les {expandedbuildings}.",
],
pensionOffice: [
"Before shipping, exchange distinct goods for {vp:1} each, up to your {citizen} count.",

View file

@ -19,6 +19,8 @@ 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"/>',
expandedBuilding:
'<path fill="#c7b3cf" d="M2 9h20v8H2Z"/><path fill="#947aa5" d="m1 9 11-7 11 7Z"/><path d="M6 12v2m12-2v2m-8 3v-5h4v5"/><rect x="1" y="19" width="10" height="4" rx=".5" fill="#d8c8de"/><rect x="13" y="19" width="10" height="4" rx=".5" fill="#d8c8de"/>',
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:

View file

@ -1,6 +1,7 @@
import { achievementText, abilityTexts } from "./achievement-text.js";
import { GOODS } from "../engine/catalog.js";
import { icon, scoreToken } from "./icons.js";
import { buildingSprite } from "./building-symbols.js";
const esc = (value) =>
String(value ?? "").replace(
/[&<>"']/g,
@ -76,7 +77,7 @@ export function journalContent(state, t, { automatedSetup = false } = {}) {
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)}` : ""}`;
text = `${t("journalBuild")} <button class="journal-building" data-building="${e.id}">${icon(buildingSprite(e.id), 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)

View file

@ -20,6 +20,11 @@ const symbols = {
worker: ["worker", ["worker", "workers"], ["ouvrier", "ouvriers"]],
citizen: ["citizen", ["citizen", "citizens"], ["citoyen", "citoyens"]],
estate: ["estate", ["estate", "estates"], ["domaine", "domaines"]],
expanded: [
"expandedBuilding",
["expanded building", "expanded buildings"],
["bâtiment étendu", "bâtiments étendus"],
],
quarry: ["quarry", ["quarry", "quarries"], ["carrière", "carrières"]],
forest: ["forest", ["forest", "forests"], ["forêt", "forêts"]],
corn: ["corn", ["corn", "corn"], ["maïs", "maïs"]],
@ -46,6 +51,7 @@ const plurals = {
workers: "worker",
citizens: "citizen",
estates: "estate",
expandedbuildings: "expanded",
quarries: "quarry",
forests: "forest",
ships: "ship",
@ -68,6 +74,10 @@ function format(message, fr, html) {
? !!plurals[key]
: Math.abs(Number(amount.replace("−", "-"))) !== 1;
const label = `${amount === undefined ? "" : `${amount} `}${(fr ? french : en)[plural ? 1 : 0]}`;
const hint =
id === "expandedBuilding"
? `${label} · ${fr ? "2 cases de ville par bâtiment" : "2 city spaces per building"}`
: label;
const before = text.slice(end, match.index);
result += html ? escape(before) : before;
if (html) {
@ -77,8 +87,8 @@ 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)}${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>`;
: `${amount === undefined ? "" : `<b>${escape(amount)}</b>`}${icon(id, 22)}${["crate", "expandedBuilding"].includes(id) ? `<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(hint)}" title="${escape(hint)}"><span aria-hidden="true">${visual}</span></span>`;
} else result += label;
end = match.index + marker.length;
}

View file

@ -3,6 +3,7 @@ import { BUILDINGS as B } from "../engine/catalog.js";
import { achievementText, abilityTexts } from "./achievement-text.js";
import { journalContent } from "./journal.js";
import { icon, scoreToken } from "./icons.js";
import { buildingSprite } from "./building-symbols.js";
const esc = (value) =>
String(value ?? "").replace(
@ -74,7 +75,9 @@ export function scoreContent(state, player, t) {
history.push(e);
}
const buildings = a.buildings
.map((b) => row(`${icon("building", 16)} ${esc(t(b.id))}`, B[b.id].vp))
.map((b) =>
row(`${icon(buildingSprite(b.id), 16)} ${esc(t(b.id))}`, B[b.id].vp),
)
.join("");
const completed = (a.achievements ?? []).filter((c) => c.completed);
const bonuses = Object.entries(score.bonus)

View file

@ -812,6 +812,12 @@
.pr-game .building-face .metric {
font-size: 10px;
}
.pr-game .building-type-icon {
display: inline-flex;
flex-shrink: 0;
align-items: center;
vertical-align: middle;
}
.pr-game .building-face .metric .icon {
width: 14px;
height: 14px;

View file

@ -15,7 +15,10 @@ import { translator } from "./i18n.js";
import { icon, scoreToken } from "./icons.js";
import { journalContent } from "./journal.js";
import { scoreContent } from "./score.js";
import { buildingSymbols } from "./building-symbols.js";
import {
buildingSymbols,
buildingSprite as spriteFor,
} from "./building-symbols.js";
import { richText } from "./rich-text.js";
import { town } from "./town.js";
import css from "./style.css";
@ -43,12 +46,6 @@ const playerShapes = [
'<path d="m12 1 11 11-11 11L1 12Z"/>',
'<path d="M8 2h8v6h6v8h-6v6H8v-6H2V8h6Z"/>',
];
const spriteFor = (id) =>
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 } = {},
@ -114,6 +111,13 @@ export function mountGame(
};
const pointsBadge = (n) =>
`<span class="points-badge" role="img" title="${esc(t("printedPoints"))} : ${n}" aria-label="${esc(t("printedPoints"))} : ${n}">${scoreToken(n, 28)}</span>`;
const buildingPictogram = (id, size) => {
const drawing = icon(spriteFor(id), size);
const label = esc(`${t("expandedBuilding")} · ${t("twoCitySpaces")}`);
return B[id]?.size === 2
? `<span class="building-type-icon" role="img" title="${label}" aria-label="${label}">${drawing}</span>`
: drawing;
};
const scoreButton = (i, n = state.players[i].vp) =>
Number.isFinite(n)
? `<button type="button" class="score-button" data-score="${i}" title="${esc(t("scoreDetails"))}" aria-label="${esc(`${t("scoreDetails")} · ${state.players[i].name} : ${n}`)}">${scoreToken(n)}</button>`
@ -465,7 +469,7 @@ export function mountGame(
);
}
function playerAreas(a) {
return `<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>`;
return `<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))}">${buildingPictogram(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>`;
}
function playerBoard() {
const a = state.players[view];
@ -591,11 +595,11 @@ 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)}${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-title">${buildingPictogram(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>
<span class="bcard-stock">${b.size === 2 ? `<span class="city-footprint" title="${esc(t("twoCitySpaces"))}" aria-label="${esc(t("twoCitySpaces"))}">${icon("citySpace", 22)}</span>` : ""}<span>${stock}</span></span>
<span class="bcard-stock">${b.size === 2 ? `<span class="city-footprint" title="${esc(t("twoCitySpaces"))}" aria-label="${esc(t("twoCitySpaces"))}">${t("twoCitySpaces")}</span>` : ""}<span>${stock}</span></span>
</button>`;
})
.join("")}</div></section>`;
@ -804,7 +808,7 @@ export function mountGame(
);
show(
t(id),
`<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>${buildingEffect(id, true)}</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))}${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">${buildingPictogram(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>${buildingEffect(id, true)}</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))}${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 festivalCondition(f) {
@ -831,7 +835,7 @@ export function mountGame(
if (f.goal === "build")
return row(
"festivalBuild",
`<span class="festival-targets"><span>${icon(spriteFor(f.targets.building), 24)}<b>${esc(t(f.targets.building))}</b></span></span>`,
`<span class="festival-targets"><span>${buildingPictogram(f.targets.building, 24)}<b>${esc(t(f.targets.building))}</b></span></span>`,
);
if (f.goal === "ship") return row("festivalShip", goods);
if (f.goal === "tradeFull") return row("festivalTrade", goods);