From 842ceaa10e335a05d9f0a8b396ca935c8109ab2e Mon Sep 17 00:00:00 2001 From: rope Date: Wed, 4 Nov 2026 18:07:03 +0000 Subject: [PATCH] Icons: emoji become glyphs wherever the page draws, board text stays as typed Co-Authored-By: Claude Opus 5.5 --- game.py | 44 ++++++++++++++++++++++++++++++++-- static/app.js | 25 ++++++++++++++----- static/icons.svg | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 8 deletions(-) diff --git a/game.py b/game.py index a6d24a1..03f7dff 100644 --- a/game.py +++ b/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, } diff --git a/static/app.js b/static/app.js index 5f010cd..1d34c04 100644 --- a/static/app.js +++ b/static/app.js @@ -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]*?|
[\\s\\S]*?
|<(?:[^>"']|"[^"]*"|'[^']*')*>)|(${ + 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) => ``; 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 ? `
  • Victory!
  • ` : `
  • The line breaks.
  • `); - 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 = ``; + modal.innerHTML = iconed(``); 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 ? `

    ${k.cities.length} / ${k.max} towns

    ` : `

    ${cost}

    ${S.city.next_tier ? `

    ${esc(k.short)}

    ` : `
    - +
    `}`; return `
    ${towns}
    @@ -2802,7 +2815,7 @@ function orderPicker(list) { }).join(""); return `
    ${skills.map((k) => ``).join("")} -
    +
    ${groups.length && !q ? `
    ${groups.map((g) => ``).join("")}
    ` : ""}
    ${tiles || `β€”`}
    `; } diff --git a/static/icons.svg b/static/icons.svg index 15a769f..2ac92f0 100644 --- a/static/icons.svg +++ b/static/icons.svg @@ -6,6 +6,7 @@ + @@ -15,15 +16,20 @@ + + + + + @@ -34,20 +40,25 @@ + + + + + @@ -67,14 +78,19 @@ + + + + + @@ -87,9 +103,11 @@ + + @@ -100,9 +118,11 @@ + + @@ -116,37 +136,45 @@ + + + + + + + + @@ -165,22 +193,32 @@ + + + + + + + + + + @@ -188,18 +226,23 @@ + + + + + @@ -214,6 +257,7 @@ + @@ -221,6 +265,7 @@ + @@ -234,9 +279,14 @@ + + + + + @@ -246,11 +296,13 @@ + + @@ -258,12 +310,15 @@ + + + @@ -271,14 +326,20 @@ + + + + + + @@ -289,6 +350,7 @@ +