Finish implementing the create lobby event
This commit is contained in:
parent
1b01ef971d
commit
96d6e0b503
1 changed files with 12 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import { Status, ICreateLobby, colours, spaceships } from "common";
|
|||
import { WebsocketEvent } from "@/types/WebsocketEvent";
|
||||
import { Player } from "@/objects/Player";
|
||||
import { Game } from "@/objects/Game";
|
||||
import { games } from "@/main";
|
||||
|
||||
const data: WebsocketEvent = {
|
||||
name: "req:lobby.create",
|
||||
|
|
@ -24,7 +25,17 @@ const data: WebsocketEvent = {
|
|||
ship: spaceships[0],
|
||||
});
|
||||
let game = new Game(host);
|
||||
game.log.info(`New game created by ${data.name}`)
|
||||
game.log.info(`New game created by ${data.name}`);
|
||||
|
||||
socket.join(game.id);
|
||||
socket.emit(`res:lobby.create`, {
|
||||
status: Status.Success,
|
||||
game_code: game.id,
|
||||
players: [],
|
||||
});
|
||||
|
||||
games.set(game);
|
||||
games.cleanup();
|
||||
},
|
||||
};
|
||||
export default data;
|
||||
Loading…
Add table
Add a link
Reference in a new issue