fix: unresolved comments

This commit is contained in:
Trajkov Dimitar
2025-12-25 12:02:01 +01:00
parent 0cb0f2c118
commit 9150a1f820
7 changed files with 50 additions and 29 deletions
-10
View File
@@ -292,14 +292,4 @@ export class TerritoryPatternsModal extends LitElement {
render(preview, this.previewButton);
this.requestUpdate();
}
private isLoggedIn(): boolean {
if (this.userMeResponse === false) {
return false;
}
return (
this.userMeResponse.user.discord !== undefined ||
this.userMeResponse.user.email !== undefined
);
}
}
+1 -1
View File
@@ -152,7 +152,7 @@ export enum LogSeverity {
// Utility types
//
const TeamCountConfigSchema = z.union([
export const TeamCountConfigSchema = z.union([
z.number(),
z.literal(Duos),
z.literal(Trios),
+2
View File
@@ -115,6 +115,8 @@ export class PlayerExecution implements Execution {
}
}
}
this.mg.stats().updateMaxTiles(this.player);
}
private removeClusters() {
+4 -1
View File
@@ -31,7 +31,10 @@ export class SurrenderExecution implements Execution {
// Find the opponent (the other human player in duel)
const players = mg
.players()
.filter((p) => p.type() === PlayerType.Human && p !== this.player);
.filter(
(p) =>
p.type() === PlayerType.Human && p !== this.player && p.isAlive(),
);
if (players.length !== 1) {
console.warn("Cannot surrender: expected exactly one opponent");
return;
-3
View File
@@ -562,12 +562,10 @@ export class GameImpl implements Game {
previousOwner._lastTileChange = this._ticks;
previousOwner._tiles.delete(tile);
previousOwner._borderTiles.delete(tile);
this._stats.updateMaxTiles(previousOwner);
}
this._map.setOwnerID(tile, owner.smallID());
owner._tiles.add(tile);
owner._lastTileChange = this._ticks;
this._stats.updateMaxTiles(owner);
this.updateBorders(tile);
this._map.setFallout(tile, false);
this.addUpdate({
@@ -588,7 +586,6 @@ export class GameImpl implements Game {
previousOwner._lastTileChange = this._ticks;
previousOwner._tiles.delete(tile);
previousOwner._borderTiles.delete(tile);
this._stats.updateMaxTiles(previousOwner);
this._map.setOwnerID(tile, 0);
this.updateBorders(tile);
+35 -12
View File
@@ -1,17 +1,24 @@
import { Logger } from "winston";
import { z } from "zod";
import { ServerConfig } from "../core/configuration/Config";
import { TeamCountConfig } from "../core/Schemas";
import { TeamCountConfigSchema } from "../core/Schemas";
import { generateID, simpleHash } from "../core/Util";
export interface MatchAssignment {
players: string[]; // Player tokens
config: {
queueType: "ranked" | "unranked";
gameMode: "ffa" | "team" | "duel" | "duos" | "trios" | "quads";
playerCount: number;
teamConfig?: TeamCountConfig;
};
}
const MatchAssignmentSchema = z.object({
players: z.array(z.string()),
config: z.object({
queueType: z.enum(["ranked", "unranked"]),
gameMode: z.enum(["ffa", "team", "duel", "duos", "trios", "quads"]),
playerCount: z.number().int().positive(),
teamConfig: TeamCountConfigSchema.optional(),
}),
});
const MatchmakingResponseSchema = z.object({
assignment: MatchAssignmentSchema.optional(),
});
export type MatchAssignment = z.infer<typeof MatchAssignmentSchema>;
export class MatchmakingPoller {
private serverId: string;
@@ -74,6 +81,9 @@ export class MatchmakingPoller {
ccu: ccu,
});
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 20000);
const response = await fetch(
`${this.config.jwtIssuer()}/matchmaking/checkin`,
{
@@ -87,12 +97,25 @@ export class MatchmakingPoller {
ccu: ccu,
gameId: gameId,
}),
signal: controller.signal,
},
);
if (response.ok) {
const data = await response.json();
clearTimeout(timeoutId);
if (response.ok) {
const rawData = await response.json();
const result = MatchmakingResponseSchema.safeParse(rawData);
if (!result.success) {
this.log.error("Invalid matchmaking response", {
error: result.error.message,
});
await this.sleep(10000);
continue;
}
const data = result.data;
if (data.assignment) {
this.log.info("Received match assignment", {
gameId,
+8 -2
View File
@@ -84,7 +84,10 @@ export async function startWorker() {
const selectedMap = selectMapForRanked({
playerCount: assignment.config.playerCount,
gameMode:
assignment.config.gameMode === "ffa" ? GameMode.FFA : GameMode.Team,
assignment.config.gameMode === "ffa" ||
assignment.config.gameMode === "duel"
? GameMode.FFA
: GameMode.Team,
queueType: assignment.config.queueType,
matchMode: assignment.config.gameMode,
});
@@ -587,7 +590,10 @@ async function pollLobby(gm: GameManager) {
const selectedMap = selectMapForRanked({
playerCount: assignment.config.playerCount,
gameMode:
assignment.config.gameMode === "ffa" ? GameMode.FFA : GameMode.Team,
assignment.config.gameMode === "ffa" ||
assignment.config.gameMode === "duel"
? GameMode.FFA
: GameMode.Team,
queueType: assignment.config.queueType,
matchMode: assignment.config.gameMode,
});