mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:00:44 +00:00
Replace literals by enums in 4 files
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { virtualize } from "@lit-labs/virtualizer/virtualize.js";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, query, state } from "lit/decorators.js";
|
||||
import { RankedType } from "src/core/game/Game";
|
||||
import { PlayerLeaderboardEntry } from "../../../core/ApiSchemas";
|
||||
import { fetchPlayerLeaderboard, getUserMe } from "../../Api";
|
||||
import { translateText } from "../../Utils";
|
||||
@@ -68,19 +69,19 @@ export class LeaderboardPlayerList extends LitElement {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextPlayers: PlayerLeaderboardEntry[] = result["1v1"].map(
|
||||
(entry) => ({
|
||||
rank: entry.rank,
|
||||
playerId: entry.public_id,
|
||||
username: entry.username,
|
||||
clanTag: entry.clanTag ?? undefined,
|
||||
elo: entry.elo,
|
||||
games: entry.total,
|
||||
wins: entry.wins,
|
||||
losses: entry.losses,
|
||||
winRate: entry.total > 0 ? entry.wins / entry.total : 0,
|
||||
}),
|
||||
);
|
||||
const nextPlayers: PlayerLeaderboardEntry[] = result[
|
||||
RankedType.OneVOne
|
||||
].map((entry) => ({
|
||||
rank: entry.rank,
|
||||
playerId: entry.public_id,
|
||||
username: entry.username,
|
||||
clanTag: entry.clanTag ?? undefined,
|
||||
elo: entry.elo,
|
||||
games: entry.total,
|
||||
wins: entry.wins,
|
||||
losses: entry.losses,
|
||||
winRate: entry.total > 0 ? entry.wins / entry.total : 0,
|
||||
}));
|
||||
|
||||
const receivedCount = nextPlayers.length;
|
||||
if (reset) {
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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,
|
||||
@@ -294,7 +294,7 @@ export function createRandomName(
|
||||
playerType: string,
|
||||
): 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 =
|
||||
|
||||
@@ -185,7 +185,7 @@ export async function startWorker() {
|
||||
const game = gm.createGame(id, gc, creatorPersistentID);
|
||||
|
||||
log.info(
|
||||
`Worker ${workerId}: IP ${ipAnonymize(clientIP)} creating ${game.isPublic() ? "Public" : "Private"}${gc?.gameMode ? ` ${gc.gameMode}` : ""} game with id ${id}${creatorPersistentID ? `, creator: ${creatorPersistentID.substring(0, 8)}...` : ""}`,
|
||||
`Worker ${workerId}: IP ${ipAnonymize(clientIP)} creating ${game.isPublic() ? GameType.Public : GameType.Private}${gc?.gameMode ? ` ${gc.gameMode}` : ""} game with id ${id}${creatorPersistentID ? `, creator: ${creatorPersistentID.substring(0, 8)}...` : ""}`,
|
||||
);
|
||||
res.json(game.gameInfo());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user