mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-17 00:10:54 +00:00
created prestart message: add 2 second delay before starting public games to allow all players to connect
This commit is contained in:
+10
-3
@@ -64,7 +64,8 @@ export type ServerMessage =
|
||||
| ServerSyncMessage
|
||||
| ServerStartGameMessage
|
||||
| ServerPingMessage
|
||||
| ServerDesyncMessage;
|
||||
| ServerDesyncMessage
|
||||
| ServerPrestartMessage;
|
||||
|
||||
export type ServerSyncMessage = z.infer<typeof ServerTurnMessageSchema>;
|
||||
export type ServerStartGameMessage = z.infer<
|
||||
@@ -72,7 +73,7 @@ export type ServerStartGameMessage = z.infer<
|
||||
>;
|
||||
export type ServerPingMessage = z.infer<typeof ServerPingMessageSchema>;
|
||||
export type ServerDesyncMessage = z.infer<typeof ServerDesyncSchema>;
|
||||
|
||||
export type ServerPrestartMessage = z.infer<typeof ServerPrestartMessageSchema>;
|
||||
export type ClientSendWinnerMessage = z.infer<typeof ClientSendWinnerSchema>;
|
||||
export type ClientPingMessage = z.infer<typeof ClientPingMessageSchema>;
|
||||
export type ClientIntentMessage = z.infer<typeof ClientIntentMessageSchema>;
|
||||
@@ -298,7 +299,7 @@ export const TurnSchema = z.object({
|
||||
// Server
|
||||
|
||||
const ServerBaseMessageSchema = z.object({
|
||||
type: z.enum(["turn", "ping", "start", "desync"]),
|
||||
type: z.enum(["turn", "ping", "prestart", "start", "desync"]),
|
||||
});
|
||||
|
||||
export const ServerTurnMessageSchema = ServerBaseMessageSchema.extend({
|
||||
@@ -310,6 +311,11 @@ export const ServerPingMessageSchema = ServerBaseMessageSchema.extend({
|
||||
type: z.literal("ping"),
|
||||
});
|
||||
|
||||
export const ServerPrestartMessageSchema = ServerBaseMessageSchema.extend({
|
||||
type: z.literal("prestart"),
|
||||
gameMap: z.nativeEnum(GameMapType),
|
||||
});
|
||||
|
||||
export const PlayerSchema = z.object({
|
||||
playerID: ID,
|
||||
clientID: ID,
|
||||
@@ -341,6 +347,7 @@ export const ServerDesyncSchema = ServerBaseMessageSchema.extend({
|
||||
|
||||
export const ServerMessageSchema = z.union([
|
||||
ServerTurnMessageSchema,
|
||||
ServerPrestartMessageSchema,
|
||||
ServerStartGameMessageSchema,
|
||||
ServerPingMessageSchema,
|
||||
ServerDesyncSchema,
|
||||
|
||||
@@ -3,10 +3,13 @@ import { GameMapType } from "./Game";
|
||||
import { GameMap, GameMapImpl } from "./GameMap";
|
||||
import { terrainMapFileLoader } from "./TerrainMapFileLoader";
|
||||
|
||||
const loadedMaps = new Map<
|
||||
GameMapType,
|
||||
{ nationMap: NationMap; gameMap: GameMap; miniGameMap: GameMap }
|
||||
>();
|
||||
export type TerrainMapData = {
|
||||
nationMap: NationMap;
|
||||
gameMap: GameMap;
|
||||
miniGameMap: GameMap;
|
||||
};
|
||||
|
||||
const loadedMaps = new Map<GameMapType, TerrainMapData>();
|
||||
|
||||
export interface NationMap {
|
||||
nations: Nation[];
|
||||
@@ -21,7 +24,7 @@ export interface Nation {
|
||||
|
||||
export async function loadTerrainMap(
|
||||
map: GameMapType,
|
||||
): Promise<{ nationMap: NationMap; gameMap: GameMap; miniGameMap: GameMap }> {
|
||||
): Promise<TerrainMapData> {
|
||||
if (loadedMaps.has(map)) {
|
||||
return loadedMaps.get(map);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user