fix invalid id reported on entities query

This commit is contained in:
2025-01-26 15:04:38 +09:00
parent 11ec464d27
commit 8ae113b2cf
2 changed files with 21 additions and 8 deletions
+4 -2
View File
@@ -1,4 +1,4 @@
import { Dungeon } from './level.js'
import * as LEVEL from './level.js'
import { WebSocketExpress } from 'websocket-express'
import express from 'express'
import Game from './game.js'
@@ -35,6 +35,7 @@ app.ws('/ws', async (req, res) => {
console.info(message)
if (message.action == 'entities') {
websocket.send(JSON.stringify({ entities: game.entities.map((it) => it.id) }))
return
}
if (message.action == 'join') {
@@ -64,5 +65,6 @@ app.ws('/ws', async (req, res) => {
app.listen(port, () => {
console.info({ event: 'startup', visit: `http://localhost:${port}/menu/` })
Dungeon.scenario(game)
LEVEL.Chase.scenario(game)
game.start()
})
+17 -6
View File
@@ -26,8 +26,24 @@ export class Dungeon {
game.spawnEntity(new Entity(Template.player({ id: '2', spawnPosition: new Vector2(1500, 700), team, dead: true })))
game.spawnEntity(new Entity(Template.basilisk({ id: 'boss', spawnPosition: new Vector2(2200, 750), team: Team.neutral })))
}
}
game.start()
export class Chase {
static scenario(game) {
game.width = 1000
game.height = 1000
const chaserTemplate = {
// TODO: TODO
}
const runnerTemplate = {
// TODO: TODO
}
game.spawnEntity(new Entity({ ...chaserTemplate }))
game.spawnEntity(new Entity({ ...runnerTemplate }))
}
}
@@ -47,9 +63,6 @@ export class Zigzag {
new Vector2(i + 100, game.height - lowest),
]))
}
game.start()
}
}
@@ -68,8 +81,6 @@ export class Ravine {
team,
})))
}
game.start()
}
static logic() {
const game = this