Cleanup: Replace literals by enums (#3252)

## Description:

Some literals were present that could/should have been enums. Replaced
them.

For Util.ts > createRandomName, also changed type of parameter
playerType from string to PlayerType. All callers already send it this
type.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

tryout33
This commit is contained in:
VariableVince
2026-02-19 16:58:07 -06:00
committed by GitHub
parent fcf45db672
commit c235debb57
4 changed files with 26 additions and 19 deletions
+8 -2
View File
@@ -1,7 +1,13 @@
import { z } from "zod";
import { base64urlToUuid } from "./Base64";
import { BigIntStringSchema, PlayerStatsSchema } from "./StatsSchemas";
import { Difficulty, GameMapType, GameMode, GameType } from "./game/Game";
import {
Difficulty,
GameMapType,
GameMode,
GameType,
RankedType,
} from "./game/Game";
export const RefreshResponseSchema = z.object({
token: z.string(),
@@ -176,7 +182,7 @@ export type RankedLeaderboardEntry = z.infer<
>;
export const RankedLeaderboardResponseSchema = z.object({
"1v1": RankedLeaderboardEntrySchema.array(),
[RankedType.OneVOne]: RankedLeaderboardEntrySchema.array(),
});
export type RankedLeaderboardResponse = z.infer<
typeof RankedLeaderboardResponseSchema
+3 -3
View File
@@ -1,6 +1,6 @@
import DOMPurify from "dompurify";
import { customAlphabet } from "nanoid";
import { Cell, Unit } from "./game/Game";
import { Cell, PlayerType, Unit } from "./game/Game";
import { GameMap, TileRef } from "./game/GameMap";
import {
GameConfig,
@@ -291,10 +291,10 @@ export function withinInt(num: bigint, min: bigint, max: bigint): bigint {
export function createRandomName(
name: string,
playerType: string,
playerType: PlayerType,
): string | null {
let randomName: string | null = null;
if (playerType === "HUMAN") {
if (playerType === PlayerType.Human) {
const hash = simpleHash(name);
const prefixIndex = hash % BOT_NAME_PREFIXES.length;
const suffixIndex =