fixed multiplayer

This commit is contained in:
evanpelle
2024-08-14 08:12:29 -07:00
parent 001722bd59
commit a417a7b2a3
8 changed files with 15 additions and 23 deletions
+3 -1
View File
@@ -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
) { }
}
+1
View File
@@ -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({
-2
View File
@@ -6,8 +6,6 @@ export interface Config {
theme(): Theme;
player(): PlayerConfig
turnIntervalMs(): number
tickIntervalMs(): number
ticksPerTurn(): number
lobbyCreationRate(): number
lobbyLifetime(): number
}
+1 -9
View File
@@ -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 {
+1 -1
View File
@@ -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
)