Things and støff

This commit is contained in:
Kim Ravn Hansen
2025-09-14 20:43:06 +02:00
parent ed91a7f2f7
commit aeb9d776fc
25 changed files with 688 additions and 591 deletions

View File

@@ -2,12 +2,12 @@ import WebSocket, { WebSocketServer } from "ws";
import http from "http";
import path from "path";
import fs from "fs";
import * as msg from "./utils/messages.js";
import { Session } from "./models/session.js";
import { GameSeeder } from "./seeders/gameSeeder.js";
import { Config } from "./config.js";
import { gGame } from "./models/globals.js";
import { AuthenticationScene } from "./scenes/authentication/authenticationScene.js";
import { MessageType, WebsocketMessage, formatMessage } from "./utils/messages.js";
// __ __ _ _ ____ ____
// | \/ | | | | _ \ / ___| ___ _ ____ _____ _ __
@@ -32,7 +32,7 @@ class MudServer {
console.info("New connection established");
const session = new Session(websocket, gGame);
if (Config.dev) {
websocket.send(msg.prepareToSend(msg.SYSTEM, "dev", true));
websocket.send(formatMessage(MessageType.SYSTEM, "dev", true));
}
// ____ _ ___ ____ _____
@@ -56,7 +56,7 @@ class MudServer {
this.onMessage(session, data);
} catch (error) {
console.error(error, data.toString(), data);
websocket.send(msg.prepareToSend(msg.CALAMITY, error));
websocket.send(formatMessage(MessageType.CALAMITY, error));
session.close();
}
});
@@ -159,7 +159,7 @@ class MudServer {
return;
}
const msgObj = new msg.WebsocketMessage(data.toString());
const msgObj = new WebsocketMessage(data.toString());
//
// Handle replies to prompts. The main workhorse of the game.
@@ -174,7 +174,7 @@ class MudServer {
}
//
// Handle QUIT messages. When the player types :quit
// Handle MessageType.QUIT messages. When the player types :quit
if (msgObj.isQuit()) {
session.scene.onQuit();
session.close(0, "Closing the socket, graceful goodbye!");
@@ -184,7 +184,7 @@ class MudServer {
//
// Handle any text that starts with ":" that isn't :help or :quit
if (msgObj.isColon()) {
return session.scene.prompt.onColon(msgObj.command, msgObj.argLine);
return session.scene.prompt.onColon(msgObj.command, msgObj.args);
}
//