Bugfixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Security } from "../../utils/security.js";
|
import { Security } from "../../utils/security.js";
|
||||||
import { Config } from "../../config.js";
|
import { Config } from "../../config.js";
|
||||||
import { GameScene } from "../gameLoop/gameScene.js";
|
import { GameScene } from "../gameLoop/gameScene.js";
|
||||||
import { PlayerCreationScene } from "../playerCreation/playerCreationSene.js";
|
import { PlayerCreationScene } from "../playerCreation/playerCreationScene.js";
|
||||||
import { Prompt } from "../prompt.js";
|
import { Prompt } from "../prompt.js";
|
||||||
import { Scene } from "../scene.js";
|
import { Scene } from "../scene.js";
|
||||||
import { gGame } from "../../models/globals.js";
|
import { gGame } from "../../models/globals.js";
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class PlayerCreationScene extends Scene {
|
|||||||
onReady() {
|
onReady() {
|
||||||
//
|
//
|
||||||
// If there are too many players, stop allowing new players in.
|
// If there are too many players, stop allowing new players in.
|
||||||
if (gGame._players.size >= Config.maxPlayers) {
|
if (gGame.players.size >= Config.maxPlayers) {
|
||||||
this.session.calamity("Server is full, no more players can be created");
|
this.session.calamity("Server is full, no more players can be created");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import { Config } from "../../config.js";
|
|
||||||
import { gGame } from "../../models/globals.js";
|
|
||||||
import { Security } from "../../utils/security.js";
|
|
||||||
import { Scene } from "../scene.js";
|
|
||||||
import { CreateUsernamePrompt } from "./createUsernamePrompt.js";
|
|
||||||
|
|
||||||
export class PlayerCreationScene extends Scene {
|
|
||||||
intro = "= Create Player";
|
|
||||||
|
|
||||||
/** @protected @type {Player} */
|
|
||||||
player;
|
|
||||||
|
|
||||||
/** @protected @type {string} */
|
|
||||||
password;
|
|
||||||
|
|
||||||
onReady() {
|
|
||||||
//
|
|
||||||
// If there are too many players, stop allowing new players in.
|
|
||||||
if (gGame._players.size >= Config.maxPlayers) {
|
|
||||||
this.session.calamity("Server is full, no more players can be created");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.showPrompt(new CreateUsernamePrompt(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the player has entered a valid and available username.
|
|
||||||
*
|
|
||||||
* @param {string} username
|
|
||||||
*/
|
|
||||||
usernameAccepted(username) {
|
|
||||||
const player = gGame.createPlayer(username);
|
|
||||||
this.player = player;
|
|
||||||
|
|
||||||
this.session.sendSystemMessage("salt", player.salt);
|
|
||||||
this.session.sendText(`Username _*${username}*_ is available, and I've reserved it for you :)`);
|
|
||||||
|
|
||||||
//
|
|
||||||
this.session.sendError("TODO: create a createPasswordPrompt and display it.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Called when the player has entered a password and confirmed it.
|
|
||||||
*
|
|
||||||
* @param {string} password
|
|
||||||
*/
|
|
||||||
passwordAccepted(password) {
|
|
||||||
this.password = password;
|
|
||||||
this.session.sendText("*_Success_* ✅ You will now be asked to log in again, sorry for that ;)");
|
|
||||||
this.player.setPasswordHash(Security.generateHash(this.password));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user