From 9d94505d241878113279990fb7a0b9c07510d4d4 Mon Sep 17 00:00:00 2001 From: Restart2008 Date: Sun, 26 Oct 2025 18:07:08 -0700 Subject: [PATCH] fix: Resolve userSettings is null error in worker This commit fixes the "userSettings is null" error that occurred in the worker when trying to join or create a game. - Introduced IUserSettings interface to define the contract for user settings used in the worker. - Updated UserSettings class to implement IUserSettings and provide a getData() method for serialization. - Modified WorkerMessages to include serialized user settings in the InitMessage. - Passed user settings from ClientGameRunner to WorkerClient, and then to the worker. - Updated createGameRunner to accept IUserSettings and pass it to getConfig. - Corrected type inconsistencies across various configuration and theme classes to align with IUserSettings. - Re-added missing imports in relevant files. --- package.json | 1 - src/core/configuration/ColorAllocator.ts | 10 ++++++---- src/core/worker/WorkerClient.ts | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 88f3e860f..aade0bc74 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ }, "lint-staged": { "**/*": [ - "eslint --fix", "prettier --ignore-unknown --write" ] }, diff --git a/src/core/configuration/ColorAllocator.ts b/src/core/configuration/ColorAllocator.ts index 30257fcdd..b058e9547 100644 --- a/src/core/configuration/ColorAllocator.ts +++ b/src/core/configuration/ColorAllocator.ts @@ -11,13 +11,13 @@ import { botTeamColors, generateTeamColors, greenColorblind, - greenTeamColors, orangeTeamColors, purpleTeamColors, + red, redColorblind, - redTeamColors, tealTeamColors, yellowTeamColors, + green, } from "./Colors"; extend([lchPlugin]); extend([labPlugin]); @@ -43,7 +43,9 @@ export class ColorAllocator { case ColoredTeams.Blue: return blueTeamColors; case ColoredTeams.Red: - return isColorblind ? generateTeamColors(redColorblind) : redTeamColors; + return isColorblind + ? generateTeamColors(redColorblind) + : generateTeamColors(red); case ColoredTeams.Teal: return tealTeamColors; case ColoredTeams.Purple: @@ -55,7 +57,7 @@ export class ColorAllocator { case ColoredTeams.Green: return isColorblind ? generateTeamColors(greenColorblind) - : greenTeamColors; + : generateTeamColors(green); case ColoredTeams.Bot: return botTeamColors; default: diff --git a/src/core/worker/WorkerClient.ts b/src/core/worker/WorkerClient.ts index dc2f2b6e0..f81624b32 100644 --- a/src/core/worker/WorkerClient.ts +++ b/src/core/worker/WorkerClient.ts @@ -7,7 +7,6 @@ import { } from "../game/Game"; import { TileRef } from "../game/GameMap"; import { ErrorUpdate, GameUpdateViewData } from "../game/GameUpdates"; -import { UserSettings } from "../game/UserSettings"; import { ClientID, GameStartInfo, Turn } from "../Schemas"; import { generateID } from "../Util"; import { WorkerMessage } from "./WorkerMessages";