Make player character color and icon optional

Clicking an already-selected color or icon in the create/edit form now
deselects it. PCs without a color use the default combatant styling;
PCs without an icon show no icon. Domain, application, persistence,
and display layers all updated to handle the optional fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-13 18:01:20 +01:00
parent 07cdd4867a
commit b7406c4b54
15 changed files with 121 additions and 45 deletions

View File

@@ -20,8 +20,8 @@ export function createPlayerCharacter(
name: string,
ac: number,
maxHp: number,
color: string,
icon: string,
color: string | undefined,
icon: string | undefined,
): CreatePlayerCharacterSuccess | DomainError {
const trimmed = name.trim();
@@ -49,7 +49,7 @@ export function createPlayerCharacter(
};
}
if (!VALID_PLAYER_COLORS.has(color)) {
if (color !== undefined && !VALID_PLAYER_COLORS.has(color)) {
return {
kind: "domain-error",
code: "invalid-color",
@@ -57,7 +57,7 @@ export function createPlayerCharacter(
};
}
if (!VALID_PLAYER_ICONS.has(icon)) {
if (icon !== undefined && !VALID_PLAYER_ICONS.has(icon)) {
return {
kind: "domain-error",
code: "invalid-icon",