Icons: emoji become glyphs wherever the page draws, board text stays as typed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3486897630
commit
842ceaa10e
3 changed files with 123 additions and 8 deletions
44
game.py
44
game.py
|
|
@ -7730,9 +7730,46 @@ def _assign_glyphs() -> None:
|
|||
action["glyph"], action["tint"] = SKILL_GLYPHS[action["skill"]]
|
||||
|
||||
|
||||
# Emoji in the UI and in what the server sends are drawn as these glyphs wherever the page renders, see iconed() in app.js.
|
||||
_EMOJI_GLYPHS = {
|
||||
# kingdom, roads and war
|
||||
"🗺️": ("treasure-map", "#d9c6a0"), "🛤️": ("stone-path", "#b6a587"), "🐎": ("horse-head", "#b9844e"), "🚶": ("walk", "#b6a587"),
|
||||
"📍": ("position-marker", "#e2645c"), "🏠": ("house", "#d0a060"), "🏰": ("castle", "#a8a29e"), "💂": ("guards", "#c06a4a"),
|
||||
"⚔️": ("crossed-swords", "#d8574c"), "🛡️": ("checked-shield", "#8fb8d0"), "🐉": ("dragon-head", "#e05a5a"), "💀": ("death-skull", "#d9c6a0"),
|
||||
"📦": ("cardboard-box", "#b9844e"), "👥": ("backup", "#a9b4c0"), "👤": ("person", "#a9b4c0"), "🏆": ("trophy", "#e3c060"),
|
||||
"✍️": ("quill-ink", "#d9c6a0"), "📜": ("scroll-unfurled", "#e3c060"), "⛰️": ("peaks", "#a8a29e"), "🌲": ("pine-tree", "#5fae5a"),
|
||||
"🌊": ("big-wave", "#5aa0d8"), "🌾": ("wheat", "#e3c060"),
|
||||
# verdicts
|
||||
"✅": ("check-mark", "#5fae5a"), "❌": ("cancel", "#d8574c"), "⚠️": ("hazard-sign", "#e3a043"), "❓": ("uncertainty", "#a9b4c0"),
|
||||
"❔": ("uncertainty", "#a9b4c0"), "❗": ("hazard-sign", "#e3a043"),
|
||||
# navigation and the page furniture
|
||||
"🏘️": ("village", "#d0a060"), "💬": ("talk", "#a9b4c0"), "📰": ("newspaper", "#d9c6a0"), "🏦": ("bank", "#e3c060"), "📌": ("pin", "#e2645c"),
|
||||
"⏳": ("hourglass", "#c9b58a"), "⏱": ("stopwatch", "#c9b58a"), "⏭": ("fast-forward-button", "#a9b4c0"), "🔒": ("padlock", "#a9b4c0"),
|
||||
"🔨": ("claw-hammer", "#b9844e"), "🔥": ("flame", "#f0903e"), "🪵": ("wood-pile", "#b9844e"), "🌱": ("sprout", "#5fae5a"),
|
||||
"⚖️": ("scales", "#e3c060"), "🔧": ("spanner", "#a9b4c0"), "✨": ("sparkles", "#e3c060"), "🎉": ("party-popper", "#e3c060"), "🏁": ("checkered-flag", "#d9c6a0"),
|
||||
"🧪": ("round-bottom-flask", "#b98ce8"), "🙏": ("prayer", "#e9dfc6"), "🌬️": ("windy-stripes", "#a9c8d8"), "🤝": ("shaking-hands", "#d9c6a0"), "✋": ("hand", "#d9c6a0"),
|
||||
"❤️": ("hearts", "#e2645c"), "🦴": ("crossed-bones", "#e9dfc6"), "🎁": ("present", "#e2645c"), "🍞": ("sliced-bread", "#d9a860"), "🍲": ("hot-meal", "#d9a860"),
|
||||
"👕": ("shirt", "#a9c8d8"), "🥶": ("snowflake-1", "#a9c8d8"), "🏗️": ("crane", "#e3a043"), "🕵️": ("hooded-figure", "#8a7fd0"), "📯": ("hunting-horn", "#e0a050"),
|
||||
"🎒": ("backpack", "#b9844e"), "🐪": ("camel-head", "#d9a860"), "🐫": ("camel-head", "#d9a860"), "🧳": ("suitcase", "#b9844e"),
|
||||
# moods
|
||||
"😠": ("enrage", "#e2645c"), "😟": ("despair", "#e3a043"), "😐": ("meditation", "#a9b4c0"), "🙂": ("smitten", "#a0c060"), "😄": ("laurel-crown", "#5fae5a"),
|
||||
# seasons and weather
|
||||
"☀️": ("sun", "#e3c060"), "🍂": ("falling-leaf", "#d07a3c"), "❄️": ("snowflake-1", "#a9c8d8"), "🌤️": ("sun-cloud", "#e3c060"), "🌧️": ("raining", "#5aa0d8"),
|
||||
"🥵": ("heat-haze", "#e2645c"), "⛈️": ("lightning-storm", "#b98ce8"), "🌫️": ("fog", "#a9b4c0"), "🌨️": ("snowing", "#a9c8d8"),
|
||||
# troubles, hardships and fortunes
|
||||
"🐺": ("wolf-head", "#a9b4c0"), "🐻": ("bear-head", "#b9844e"), "🐗": ("boar", "#b9844e"), "👺": ("goblin-head", "#5fae5a"), "🕷️": ("spider-alt", "#a9b4c0"),
|
||||
"🐝": ("bee", "#e3c060"), "🐀": ("rat", "#a9b4c0"), "🦗": ("ant", "#a0c060"), "🏴☠️": ("pirate-flag", "#d9c6a0"), "🌉": ("stone-bridge", "#a8a29e"),
|
||||
"🪨": ("stone-block", "#a8a29e"), "🛢️": ("barrel", "#b9844e"), "✊": ("fist", "#e3a043"), "🤒": ("vomiting", "#a0c060"), "🥀": ("dead-wood", "#b9844e"),
|
||||
"🫨": ("earth-crack", "#b9844e"), "🏜️": ("heat-haze", "#d9a860"), "🎓": ("graduate-cap", "#8a7fd0"), "🎨": ("palette", "#e2645c"), "🫳": ("robber-hand", "#e3a043"),
|
||||
"🍄": ("mushroom-gills", "#d07a3c"), "🌪️": ("tornado", "#a9b4c0"), "👑": ("crown", "#e3c060"), "🐟": ("double-fish", "#5aa0d8"), "💎": ("cut-diamond", "#8fd0e0"),
|
||||
"🗡️": ("broadsword", "#a9b4c0"), "🦌": ("deer", "#b9844e"),
|
||||
}
|
||||
EMOJI_GLYPHS = {emoji.replace("\ufe0f", ""): glyph for emoji, glyph in _EMOJI_GLYPHS.items()}
|
||||
|
||||
|
||||
def all_glyphs() -> set[str]:
|
||||
"""Every glyph the game draws, for building the sprite."""
|
||||
names = set(UI_GLYPHS)
|
||||
names = set(UI_GLYPHS) | {name for name, _tint in EMOJI_GLYPHS.values()}
|
||||
for collection in (ITEMS.values(), SKILLS, CLASSES.values(), BUILDINGS.values(), PRAYERS, ACTIONS,
|
||||
combat.ABILITIES.values(), combat.ENEMY_ABILITIES.values()):
|
||||
names.update(entry["glyph"] for entry in collection)
|
||||
|
|
@ -7750,6 +7787,9 @@ ORDER_RECIPES, ORDER_RAW = _order_sources()
|
|||
# What changed, shown on the Patch notes page. Newest first; every shipped change adds a
|
||||
# line here (new / balance / fix), and a new release a new entry on top.
|
||||
PATCH_NOTES = [
|
||||
{"date": "2026-11-04", "title": "Icons", "notes": [
|
||||
("new", "Icons replace emoji across the game. Your own board messages stay as typed."),
|
||||
]},
|
||||
{"date": "2026-11-04", "title": "Caravans", "notes": [
|
||||
("new", "Caravans: carry goods between towns. 1h, 1,000 items per crew member. Everyone aboard stops work until it arrives."),
|
||||
("new", "Town stock: war council vote, then a caravan carries it. Crew earn 5% of its worth in favour at the far end."),
|
||||
|
|
@ -7965,7 +8005,7 @@ def content() -> dict:
|
|||
"resistant": RESISTANT, "jewel_stats": JEWEL_STATS, "stations": list(STATIONS), "class_style": CLASS_STYLE, "block_chance": BLOCK_CHANCE,
|
||||
"regen_per_hour": REGEN_PER_HOUR,
|
||||
"fires": FIRES, "flames": FLAMES, "firewood": FIREWOOD, "tend_xp": TEND_XP, "fire_low": FIRE_LOW,
|
||||
"patch_notes": PATCH_NOTES,
|
||||
"patch_notes": PATCH_NOTES, "emoji_glyphs": EMOJI_GLYPHS,
|
||||
"wares": {key: {**spec, "glyph": WARE_GLYPHS[key]} for key, spec in WARES.items()}, "cosmetics": COSMETICS, "free_looks": FREE_LOOKS, "homes": HOMES, "monuments": MONUMENTS,
|
||||
"guard_wage": GUARD_WAGE,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,19 @@ function iconise(content) {
|
|||
for (const entry of entries) if (entry.glyph) entry.icon = glyph(entry.glyph, entry.tint);
|
||||
return content;
|
||||
}
|
||||
// Emoji become glyphs wherever the page is drawn. Not inside tags (a title can't hold an icon), a dropdown
|
||||
// (nor can an option), or what players typed on the board.
|
||||
let emojiPattern = null;
|
||||
function iconed(html) {
|
||||
if (!C?.emoji_glyphs) return html;
|
||||
emojiPattern ||= new RegExp(`(<(select|textarea)\\b[\\s\\S]*?</\\2>|<div class="text">[\\s\\S]*?</div>|<(?:[^>"']|"[^"]*"|'[^']*')*>)|(${
|
||||
Object.keys(C.emoji_glyphs).sort((a, b) => b.length - a.length).join("|")})\\uFE0F?`, "gu");
|
||||
return html.replace(emojiPattern, (match, keep, _tag, emoji) => {
|
||||
if (keep) return match;
|
||||
const [name, tint] = C.emoji_glyphs[emoji];
|
||||
return glyph(name, tint);
|
||||
});
|
||||
}
|
||||
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
||||
const fmt = (n) => Math.floor(n).toLocaleString("en-GB");
|
||||
const serverNow = () => Date.now() / 1000 + skew;
|
||||
|
|
@ -170,7 +183,7 @@ const countdown = (t) => `<span data-countdown="${t}"></span>`;
|
|||
function toast(text, kind = "") {
|
||||
const el = document.createElement("div");
|
||||
el.className = "toast " + kind;
|
||||
el.textContent = text;
|
||||
el.innerHTML = iconed(esc(text));
|
||||
$("#toasts").append(el);
|
||||
setTimeout(() => el.remove(), kind === "level" ? 6000 : 3500);
|
||||
const keep = matchMedia("(max-width: 900px)").matches ? 2 : 4;
|
||||
|
|
@ -618,7 +631,7 @@ function drawBattle(b, box, t) {
|
|||
log.dataset.key = `${told}:${t >= b.end}`;
|
||||
const lines = b.told.slice(Math.max(0, told - 7), told).reverse().map((e) => battleLine(e, b)).filter(Boolean);
|
||||
if (t >= b.end) lines.unshift(b.won ? `<li class="good"><b>Victory!</b></li>` : `<li class="bad"><b>The line breaks.</b></li>`);
|
||||
log.innerHTML = lines.slice(0, 7).join("");
|
||||
log.innerHTML = iconed(lines.slice(0, 7).join(""));
|
||||
}
|
||||
// The damage meter: what each of ours has dealt so far, best first.
|
||||
const meter = $("[data-b-dps]", box), secs = Math.max(1, Math.min(t, b.end) - BATTLE_LEAD);
|
||||
|
|
@ -646,7 +659,7 @@ function battleTold(e, b) {
|
|||
|
||||
function openModal(html) {
|
||||
const modal = $("#modal");
|
||||
modal.innerHTML = `<div class="modal-box">${html}</div>`;
|
||||
modal.innerHTML = iconed(`<div class="modal-box">${html}</div>`);
|
||||
modal.hidden = false;
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +699,7 @@ function render() {
|
|||
function setHtml(el, html) {
|
||||
if (el.dataset.html === html) return;
|
||||
const next = document.createElement("template");
|
||||
next.innerHTML = html;
|
||||
next.innerHTML = iconed(html);
|
||||
morphChildren(el, next.content);
|
||||
el.dataset.html = html;
|
||||
}
|
||||
|
|
@ -1087,7 +1100,7 @@ function kingdom() {
|
|||
: full ? `<p class="small muted">${k.cities.length} / ${k.max} towns</p>`
|
||||
: `<p class="small">${cost}</p>
|
||||
${S.city.next_tier ? `<p class="small muted">${esc(k.short)}</p>` : `<div class="pouch-row"><input type="text" maxlength="24" placeholder="Town name" data-keep="charter-name">
|
||||
<select data-keep="charter-region" class="wide">${open.map(([id, r]) => `<option value="${id}">${r.icon} ${esc(r.name)} · ${regionPerks(r, 0.5)}</option>`).join("")}</select>
|
||||
<select data-keep="charter-region" class="wide">${open.map(([id, r]) => `<option value="${id}">${esc(r.name)} · ${regionPerks(r, 0.5)}</option>`).join("")}</select>
|
||||
<button class="btn primary" data-charter-new ${k.short ? "disabled" : ""}>📜 Draw up</button></div>`}`;
|
||||
return `<div class="grid">${towns}</div>
|
||||
<div class="grid" style="margin-top:14px">
|
||||
|
|
@ -2802,7 +2815,7 @@ function orderPicker(list) {
|
|||
}).join("");
|
||||
return `<div class="picker">
|
||||
<div class="pick-skills">${skills.map((k) => `<button class="pick-skill ${!q && k === d.skill ? "on" : ""}" data-draft-skill="${k}" title="${esc(skillOf(k).name)}">${skillOf(k).icon}</button>`).join("")}
|
||||
<input type="text" data-keep="order-search" placeholder="🔍" value="${esc(d.search || "")}"></div>
|
||||
<input type="text" data-keep="order-search" placeholder="Search" value="${esc(d.search || "")}"></div>
|
||||
${groups.length && !q ? `<div class="tabs sm">${groups.map((g) => `<button class="tab ${g === d.group ? "on" : ""}" data-draft-group="${esc(g)}">${esc(g)}</button>`).join("")}</div>` : ""}
|
||||
<div class="swap-grid pick-grid">${tiles || `<span class="muted small">—</span>`}</div></div>`;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 469 KiB After Width: | Height: | Size: 556 KiB |
Loading…
Add table
Add a link
Reference in a new issue