[PR #8362] [MERGED] Let characters and personas choose their fight token picture #8318

Closed
opened 2026-10-27 06:07:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8362
Author: @kolacheee
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @kolacheee

Base: staging ← Head: claude/project-thread-0zjeto


📝 Commits (7)

  • 51b63d2 Let characters and personas choose their fight token picture
  • ea353ef Merge remote-tracking branch 'origin/staging' into claude/project-thread-0zjeto
  • 2187d82 Call the token picture block Game Mode Icon
  • f59e7b3 Merge remote-tracking branch 'origin/staging' into claude/project-thread-0zjeto
  • 0261d78 Keep the gallery upload check inside the gallery folder
  • 9cb0cc5 Merge remote-tracking branch 'origin/staging' into claude/project-thread-0zjeto
  • 2a52986 Show initials when a token picture fails to load; keep a fresh upload selected

📊 Changes

20 files changed (+742 additions, -32 deletions)

View changed files

📝 docs/characters/colors-and-stats.md (+10 -0)
📝 docs/characters/personas.md (+2 -0)
➕ e2e/game-mode-icon.e2e.ts (+201 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+20 -1)
➕ packages/client/src/components/characters/GameModeIconSection.tsx (+259 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+9 -1)
📝 packages/client/src/components/chat/chat-area.types.ts (+9 -1)
📝 packages/client/src/components/game/GameCombatUI.tsx (+13 -11)
📝 packages/client/src/components/game/GameSurface.tsx (+28 -7)
📝 packages/client/src/components/game/RulesetCombatBoard.tsx (+15 -7)
📝 packages/client/src/components/game/TacticalCombatUI.tsx (+7 -1)
➕ packages/client/src/components/game/TokenPicture.tsx (+19 -0)
📝 packages/client/src/components/personas/PersonaEditor.tsx (+22 -1)
📝 packages/client/src/localization/locales/en.json (+15 -0)
📝 packages/server/src/routes/characters.routes.ts (+22 -1)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/character.ts (+6 -0)
📝 packages/shared/src/types/persona.ts (+3 -1)
➕ packages/shared/src/utils/combat-icon.ts (+33 -0)
➕ scripts/regressions/game-mode-icon.regression.ts (+48 -0)

📄 Description

Linked issue

Closes #8360

Why this change

A fight token draws the character's avatar, or the initials when there is none. There was no way to give the token a different picture (a face crop, a token-sized drawing) or to keep the initials when the card has an avatar.

What changed

  • New Game Mode Icon block on the character and persona Stats tabs, with a token-shaped preview and three choices: Avatar (default, today's behaviour), Custom image (pick a picture from the card's own gallery or upload one into it), and Initials. It applies in every Game Mode fight style.
  • Stored as extensions.combatIcon on a character and personaStats.combatIcon on a persona. Shared parseCombatIconChoice / resolveCombatIconUrl accept only pictures from the app's own character/persona gallery routes, so a card can never point a token at an outside URL; anything else falls back to the avatar.
  • Game Mode builds party combatants (generated party, ruleset/director party, allies, the persona) with the chosen picture, and re-hydration drops an older snapshot's picture when the card is set to initials.
  • Fight tokens (ruleset board, tactical board, classic fights) now show the initials, or the classic portrait, when their picture fails to load, for example after the chosen gallery picture was deleted.
  • Character and persona gallery uploads now run the same image byte check as card imports and refuse (and delete) a file that is not the image its name claims. Before, such a file was stored and only refused when served.
  • Docs: Game Mode Icon section in docs/characters/colors-and-stats.md, pointer in personas.md.

Validation

  • pnpm check passes locally (one pre-existing lint warning in HomeProfessorMariChat.tsx, unrelated)
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • New e2e/game-mode-icon.e2e.ts, 10/10 green on desktop-chromium and mobile-chromium (the browser drives the real editors): a character switches to Initials (preview shows them, saved on the card), then uploads a picture (selected, previewed, saved), then back to Avatar (choice cleared); a persona with no avatar sees the "no avatar" note and saves Initials into its stats; a non-image upload to both gallery routes is refused with 400 and nothing is added; generatedPartyMemberToCombatant draws the avatar, nothing for initials, the gallery picture, and ignores an off-site URL; a token whose picture returns 404 shows its initials.
  • New scripts/regressions/game-mode-icon.regression.ts covers the parser and resolver.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation): noted on #7512
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

The block sits on the Stats tab above Ruleset sheets: a round token preview beside an Avatar / Custom image / Initials switch; Custom image shows the gallery pictures as round thumbnails and an upload dropzone.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8362 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `claude/project-thread-0zjeto` --- ### 📝 Commits (7) - [`51b63d2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/51b63d2bee8fe063590c070c37d6f3ca948a45e5) Let characters and personas choose their fight token picture - [`ea353ef`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ea353efa0547f853713243ec8a1abe034701e14c) Merge remote-tracking branch 'origin/staging' into claude/project-thread-0zjeto - [`2187d82`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2187d8216129737805003370475397eb18dc6eaa) Call the token picture block Game Mode Icon - [`f59e7b3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f59e7b3dc64cded671ebb52c73f7f85bfa6ef296) Merge remote-tracking branch 'origin/staging' into claude/project-thread-0zjeto - [`0261d78`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0261d78cba20c74c96e103b81094aaefc5733f7f) Keep the gallery upload check inside the gallery folder - [`9cb0cc5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9cb0cc538397ede0992e53fa44518801b16d7f42) Merge remote-tracking branch 'origin/staging' into claude/project-thread-0zjeto - [`2a52986`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2a52986fcb87bc005a269b3b36be5c698840cd2b) Show initials when a token picture fails to load; keep a fresh upload selected ### 📊 Changes **20 files changed** (+742 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `docs/characters/colors-and-stats.md` (+10 -0) 📝 `docs/characters/personas.md` (+2 -0) ➕ `e2e/game-mode-icon.e2e.ts` (+201 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+20 -1) ➕ `packages/client/src/components/characters/GameModeIconSection.tsx` (+259 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+9 -1) 📝 `packages/client/src/components/chat/chat-area.types.ts` (+9 -1) 📝 `packages/client/src/components/game/GameCombatUI.tsx` (+13 -11) 📝 `packages/client/src/components/game/GameSurface.tsx` (+28 -7) 📝 `packages/client/src/components/game/RulesetCombatBoard.tsx` (+15 -7) 📝 `packages/client/src/components/game/TacticalCombatUI.tsx` (+7 -1) ➕ `packages/client/src/components/game/TokenPicture.tsx` (+19 -0) 📝 `packages/client/src/components/personas/PersonaEditor.tsx` (+22 -1) 📝 `packages/client/src/localization/locales/en.json` (+15 -0) 📝 `packages/server/src/routes/characters.routes.ts` (+22 -1) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/character.ts` (+6 -0) 📝 `packages/shared/src/types/persona.ts` (+3 -1) ➕ `packages/shared/src/utils/combat-icon.ts` (+33 -0) ➕ `scripts/regressions/game-mode-icon.regression.ts` (+48 -0) </details> ### 📄 Description ## Linked issue Closes #8360 ## Why this change A fight token draws the character's avatar, or the initials when there is none. There was no way to give the token a different picture (a face crop, a token-sized drawing) or to keep the initials when the card has an avatar. ## What changed - New **Game Mode Icon** block on the character and persona **Stats** tabs, with a token-shaped preview and three choices: **Avatar** (default, today's behaviour), **Custom image** (pick a picture from the card's own gallery or upload one into it), and **Initials**. It applies in every Game Mode fight style. - Stored as `extensions.combatIcon` on a character and `personaStats.combatIcon` on a persona. Shared `parseCombatIconChoice` / `resolveCombatIconUrl` accept only pictures from the app's own character/persona gallery routes, so a card can never point a token at an outside URL; anything else falls back to the avatar. - Game Mode builds party combatants (generated party, ruleset/director party, allies, the persona) with the chosen picture, and re-hydration drops an older snapshot's picture when the card is set to initials. - Fight tokens (ruleset board, tactical board, classic fights) now show the initials, or the classic portrait, when their picture fails to load, for example after the chosen gallery picture was deleted. - Character and persona gallery uploads now run the same image byte check as card imports and refuse (and delete) a file that is not the image its name claims. Before, such a file was stored and only refused when served. - Docs: Game Mode Icon section in `docs/characters/colors-and-stats.md`, pointer in `personas.md`. ## Validation - [x] `pnpm check` passes locally (one pre-existing lint warning in `HomeProfessorMariChat.tsx`, unrelated) - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - New `e2e/game-mode-icon.e2e.ts`, 10/10 green on desktop-chromium and mobile-chromium (the browser drives the real editors): a character switches to Initials (preview shows them, saved on the card), then uploads a picture (selected, previewed, saved), then back to Avatar (choice cleared); a persona with no avatar sees the "no avatar" note and saves Initials into its stats; a non-image upload to both gallery routes is refused with 400 and nothing is added; `generatedPartyMemberToCombatant` draws the avatar, nothing for initials, the gallery picture, and ignores an off-site URL; a token whose picture returns 404 shows its initials. - New `scripts/regressions/game-mode-icon.regression.ts` covers the parser and resolver. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation): noted on #7512 - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) The block sits on the Stats tab above Ruleset sheets: a round token preview beside an Avatar / Custom image / Initials switch; Custom image shows the gallery pictures as round thumbnails and an upload dropzone. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-27 06:07:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8318
No description provided.