mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-03 12:50:50 +00:00
websocket reconnect on failure
This commit is contained in:
+4
-9
@@ -1,13 +1,8 @@
|
||||
import {GameEvent} from "./EventBus"
|
||||
|
||||
export type ClientID = string
|
||||
import {GameID} from "./Schemas"
|
||||
|
||||
export type PlayerID = number // TODO: make string?
|
||||
|
||||
export type GameID = string
|
||||
|
||||
export type LobbyID = string
|
||||
|
||||
export class Cell {
|
||||
|
||||
private strRepr: string
|
||||
@@ -38,7 +33,7 @@ export class PlayerInfo {
|
||||
public readonly name: string,
|
||||
public readonly isBot: boolean,
|
||||
// null if bot.
|
||||
public readonly clientID: ClientID | null
|
||||
public readonly gameID: GameID | null
|
||||
) { }
|
||||
}
|
||||
|
||||
@@ -133,8 +128,8 @@ export interface Game {
|
||||
forEachTile(fn: (tile: Tile) => void): void
|
||||
executions(): ExecutionView[]
|
||||
terraNullius(): TerraNullius
|
||||
tick()
|
||||
addExecution(...exec: Execution[])
|
||||
tick(): void
|
||||
addExecution(...exec: Execution[]): void
|
||||
}
|
||||
|
||||
export interface MutableGame extends Game {
|
||||
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
import {z} from 'zod';
|
||||
|
||||
export type GameID = string
|
||||
export type ClientID = string
|
||||
|
||||
export type Intent = SpawnIntent | AttackIntent | BoatAttackIntent
|
||||
|
||||
export type AttackIntent = z.infer<typeof AttackIntentSchema>
|
||||
@@ -96,7 +99,7 @@ export const ClientIntentMessageSchema = ClientBaseMessageSchema.extend({
|
||||
export const ClientJoinMessageSchema = ClientBaseMessageSchema.extend({
|
||||
type: z.literal('join'),
|
||||
clientID: z.string(),
|
||||
lobbyID: z.string()
|
||||
gameID: z.string()
|
||||
})
|
||||
|
||||
export const ClientMessageSchema = z.union([ClientIntentMessageSchema, ClientJoinMessageSchema]);
|
||||
@@ -6,7 +6,7 @@ export interface Config {
|
||||
theme(): Theme;
|
||||
player(): PlayerConfig
|
||||
turnIntervalMs(): number
|
||||
lobbyCreationRate(): number
|
||||
gameCreationRate(): number
|
||||
lobbyLifetime(): number
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export const defaultConfig = new class implements Config {
|
||||
turnIntervalMs(): number {
|
||||
return 100
|
||||
}
|
||||
lobbyCreationRate(): number {
|
||||
gameCreationRate(): number {
|
||||
return 2 * 1000
|
||||
}
|
||||
lobbyLifetime(): number {
|
||||
|
||||
@@ -26,7 +26,6 @@ export class SpawnExecution implements Execution {
|
||||
}
|
||||
const player = this.gs.addPlayer(this.playerInfo, this.playerConfig.startTroops(this.playerInfo))
|
||||
getSpawnCells(this.gs, this.cell).forEach(c => {
|
||||
console.log('conquering cell')
|
||||
player.conquer(this.gs.tile(c))
|
||||
})
|
||||
this.gs.addExecution(new PlayerExecution(player.id(), this.playerConfig))
|
||||
|
||||
Reference in New Issue
Block a user