mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 22:33:30 +00:00
fixed multiplayer
This commit is contained in:
+3
-1
@@ -36,7 +36,9 @@ export interface Execution extends ExecutionView {
|
||||
export class PlayerInfo {
|
||||
constructor(
|
||||
public readonly name: string,
|
||||
public readonly isBot: boolean
|
||||
public readonly isBot: boolean,
|
||||
// null if bot.
|
||||
public readonly clientID: ClientID | null
|
||||
) { }
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ export type ClientJoinMessage = z.infer<typeof ClientJoinMessageSchema>
|
||||
// Zod schemas
|
||||
const BaseIntentSchema = z.object({
|
||||
type: z.enum(['attack', 'spawn', 'boat']),
|
||||
clientID: z.string(),
|
||||
});
|
||||
|
||||
export const AttackIntentSchema = BaseIntentSchema.extend({
|
||||
|
||||
@@ -6,8 +6,6 @@ export interface Config {
|
||||
theme(): Theme;
|
||||
player(): PlayerConfig
|
||||
turnIntervalMs(): number
|
||||
tickIntervalMs(): number
|
||||
ticksPerTurn(): number
|
||||
lobbyCreationRate(): number
|
||||
lobbyLifetime(): number
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ export const defaultConfig = new class implements Config {
|
||||
player(): PlayerConfig {
|
||||
return defaultPlayerConfig
|
||||
}
|
||||
|
||||
ticksPerTurn(): number {
|
||||
return 1
|
||||
}
|
||||
turnIntervalMs(): number {
|
||||
return 100
|
||||
}
|
||||
@@ -17,13 +13,9 @@ export const defaultConfig = new class implements Config {
|
||||
return 2 * 1000
|
||||
}
|
||||
lobbyLifetime(): number {
|
||||
return 3 * 1000
|
||||
return 10 * 1000
|
||||
}
|
||||
theme(): Theme {return pastelTheme;}
|
||||
|
||||
tickIntervalMs(): number {
|
||||
return 1000 / 20; // 50ms
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultPlayerConfig = new class implements PlayerConfig {
|
||||
|
||||
@@ -31,7 +31,7 @@ export class Executor {
|
||||
} else if (intent.type == "spawn") {
|
||||
this.gs.addExecution(
|
||||
new SpawnExecution(
|
||||
new PlayerInfo(intent.name, intent.isBot),
|
||||
new PlayerInfo(intent.name, intent.isBot, intent.clientID),
|
||||
new Cell(intent.x, intent.y),
|
||||
this.playerConfig
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user