mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 16:25:25 +00:00
undefined
This commit is contained in:
@@ -442,7 +442,7 @@ export class SinglePlayerModal extends LitElement {
|
||||
flagInput.getCurrentFlag() === "xx"
|
||||
? ""
|
||||
: flagInput.getCurrentFlag(),
|
||||
pattern: localStorage.getItem("territoryPattern") ?? null,
|
||||
pattern: localStorage.getItem("territoryPattern") ?? undefined,
|
||||
},
|
||||
],
|
||||
config: {
|
||||
|
||||
@@ -61,7 +61,7 @@ export async function createGameRunner(
|
||||
new Cell(n.coordinates[0], n.coordinates[1]),
|
||||
n.strength,
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
n.flag || "",
|
||||
n.name,
|
||||
PlayerType.FakeHuman,
|
||||
|
||||
+2
-2
@@ -361,7 +361,7 @@ export const PlayerSchema = z.object({
|
||||
clientID: ID,
|
||||
username: SafeString,
|
||||
flag: SafeString.optional(),
|
||||
pattern: SafeString.nullable(),
|
||||
pattern: SafeString.optional(),
|
||||
});
|
||||
|
||||
export const GameStartInfoSchema = z.object({
|
||||
@@ -433,7 +433,7 @@ export const ClientJoinMessageSchema = z.object({
|
||||
lastTurn: z.number(), // The last turn the client saw.
|
||||
username: SafeString,
|
||||
flag: SafeString.optional(),
|
||||
pattern: SafeString.nullable(),
|
||||
pattern: SafeString.optional(),
|
||||
});
|
||||
|
||||
export const ClientMessageSchema = z.union([
|
||||
|
||||
@@ -48,7 +48,7 @@ export class BotSpawner {
|
||||
}
|
||||
return new SpawnExecution(
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"",
|
||||
botName,
|
||||
PlayerType.Bot,
|
||||
|
||||
@@ -302,7 +302,7 @@ export class PlayerInfo {
|
||||
public readonly clan: string | null;
|
||||
|
||||
constructor(
|
||||
public readonly pattern: string | null,
|
||||
public readonly pattern: string | undefined,
|
||||
public readonly flag: string | undefined,
|
||||
public readonly name: string,
|
||||
public readonly playerType: PlayerType,
|
||||
|
||||
@@ -93,7 +93,7 @@ export interface PlayerUpdate {
|
||||
type: GameUpdateType.Player;
|
||||
nameViewData?: NameViewData;
|
||||
clientID: ClientID | null;
|
||||
pattern: string | null;
|
||||
pattern: string | undefined;
|
||||
flag: string | undefined;
|
||||
name: string;
|
||||
displayName: string;
|
||||
|
||||
@@ -172,7 +172,7 @@ export class PlayerView {
|
||||
return this.data.flag;
|
||||
}
|
||||
|
||||
pattern(): string | null {
|
||||
pattern(): string | undefined {
|
||||
return this.data.pattern;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ export class PlayerImpl implements Player {
|
||||
return this._smallID;
|
||||
}
|
||||
|
||||
pattern(): string | null {
|
||||
pattern(): string | undefined {
|
||||
return this.playerInfo.pattern;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,6 @@ export class Client {
|
||||
public readonly username: string,
|
||||
public readonly ws: WebSocket,
|
||||
public readonly flag: string | undefined,
|
||||
public readonly pattern: string | null,
|
||||
public readonly pattern: string | undefined,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
GameStartInfo,
|
||||
GameStartInfoSchema,
|
||||
Intent,
|
||||
Player,
|
||||
PlayerRecord,
|
||||
ServerDesyncSchema,
|
||||
ServerPrestartMessageSchema,
|
||||
@@ -291,16 +290,13 @@ export class GameServer {
|
||||
this.gameStartInfo = GameStartInfoSchema.parse({
|
||||
gameID: this.id,
|
||||
config: this.gameConfig,
|
||||
players: this.activeClients.map(
|
||||
(c) =>
|
||||
({
|
||||
playerID: c.playerID,
|
||||
username: c.username,
|
||||
clientID: c.clientID,
|
||||
pattern: c.pattern,
|
||||
flag: c.flag,
|
||||
}) satisfies Player,
|
||||
),
|
||||
players: this.activeClients.map((c) => ({
|
||||
playerID: c.playerID,
|
||||
username: c.username,
|
||||
clientID: c.clientID,
|
||||
pattern: c.pattern,
|
||||
flag: c.flag,
|
||||
})),
|
||||
} satisfies GameStartInfo);
|
||||
|
||||
this.endTurnIntervalID = setInterval(
|
||||
|
||||
@@ -33,7 +33,7 @@ describe("Attack", () => {
|
||||
infiniteTroops: true,
|
||||
});
|
||||
const attackerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"attacker dude",
|
||||
PlayerType.Human,
|
||||
@@ -42,7 +42,7 @@ describe("Attack", () => {
|
||||
);
|
||||
game.addPlayer(attackerInfo);
|
||||
const defenderInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"defender dude",
|
||||
PlayerType.Human,
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("MissileSilo", () => {
|
||||
beforeEach(async () => {
|
||||
game = await setup("Plains", { infiniteGold: true, instantBuild: true });
|
||||
const attacker_info = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"attacker_id",
|
||||
PlayerType.Human,
|
||||
|
||||
@@ -4,7 +4,7 @@ describe("PlayerInfo", () => {
|
||||
describe("clan", () => {
|
||||
test("should extract clan from name when format is [XX]Name", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[CL]PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -16,7 +16,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should extract clan from name when format is [XXX]Name", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[ABC]PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -28,7 +28,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should extract clan from name when format is [XXXX]Name", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[ABCD]PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -40,7 +40,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should extract clan from name when format is [XXXXX]Name", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[ABCDE]PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -52,7 +52,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should return null when name doesn't start with [", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -64,7 +64,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should return null when name doesn't contain ]", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[ABCPlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -76,7 +76,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should return null when clan tag is not 2-5 uppercase letters", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[A]PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -88,7 +88,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should return null when clan tag contains non-uppercase letters", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[Abc]PlayerName",
|
||||
PlayerType.Human,
|
||||
@@ -100,7 +100,7 @@ describe("PlayerInfo", () => {
|
||||
|
||||
test("should return null when clan tag is too long", () => {
|
||||
const playerInfo = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"[ABCDEF]PlayerName",
|
||||
PlayerType.Human,
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ describe("SAM", () => {
|
||||
beforeEach(async () => {
|
||||
game = await setup("Plains", { infiniteGold: true, instantBuild: true });
|
||||
const defender_info = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"defender_id",
|
||||
PlayerType.Human,
|
||||
@@ -26,7 +26,7 @@ describe("SAM", () => {
|
||||
"defender_id",
|
||||
);
|
||||
const attacker_info = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"fr",
|
||||
"attacker_id",
|
||||
PlayerType.Human,
|
||||
|
||||
@@ -7,7 +7,7 @@ describe("assignTeams", () => {
|
||||
const createPlayer = (id: string, clan?: string): PlayerInfo => {
|
||||
const name = clan ? `[${clan}]Player ${id}` : `Player ${id}`;
|
||||
return new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"🏳️", // flag
|
||||
name,
|
||||
PlayerType.Human,
|
||||
|
||||
@@ -7,7 +7,7 @@ describe("Territory management", () => {
|
||||
const game = await setup("Plains");
|
||||
game.addPlayer(
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"test_player",
|
||||
PlayerType.Human,
|
||||
|
||||
@@ -12,7 +12,7 @@ async function checkRange(
|
||||
const grid = new UnitGrid(game.map());
|
||||
const player = game.addPlayer(
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"test_player",
|
||||
PlayerType.Human,
|
||||
@@ -42,7 +42,7 @@ async function nearbyUnits(
|
||||
const grid = new UnitGrid(game.map());
|
||||
const player = game.addPlayer(
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"test_player",
|
||||
PlayerType.Human,
|
||||
@@ -123,7 +123,7 @@ describe("Unit Grid range tests", () => {
|
||||
const grid = new UnitGrid(game.map());
|
||||
const player = game.addPlayer(
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"test_player",
|
||||
PlayerType.Human,
|
||||
@@ -147,7 +147,7 @@ describe("Unit Grid range tests", () => {
|
||||
const grid = new UnitGrid(game.map());
|
||||
const player = game.addPlayer(
|
||||
new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"test_player",
|
||||
PlayerType.Human,
|
||||
|
||||
@@ -21,7 +21,7 @@ describe("Warship", () => {
|
||||
instantBuild: true,
|
||||
});
|
||||
const player_1_info = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"boat dude",
|
||||
PlayerType.Human,
|
||||
@@ -30,7 +30,7 @@ describe("Warship", () => {
|
||||
);
|
||||
game.addPlayer(player_1_info);
|
||||
const player_2_info = new PlayerInfo(
|
||||
null,
|
||||
undefined,
|
||||
"us",
|
||||
"boat dude",
|
||||
PlayerType.Human,
|
||||
|
||||
+1
-1
@@ -60,5 +60,5 @@ export async function setup(
|
||||
}
|
||||
|
||||
export function playerInfo(name: string, type: PlayerType): PlayerInfo {
|
||||
return new PlayerInfo(null, "fr", name, type, null, name);
|
||||
return new PlayerInfo(undefined, "fr", name, type, null, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user