attempt to change some stuff

This commit is contained in:
Hri7566 2021-04-12 22:08:29 -04:00
parent 13a89f76a9
commit 664b2eed98
4 changed files with 52 additions and 34 deletions

View File

@ -10,5 +10,10 @@ module.exports = Object.seal({
// defaultLobbyColor2: "#801014",
defaultLobbyColor2: "#801014",
adminpass: process.env.ADMINPASS,
ssl: false
ssl: true,
defaultRoomSettings: {
color: "#000000",
crownsolo: false,
visible: true
}
});

View File

@ -24,6 +24,7 @@ class Client extends EventEmitter {
this.ws = ws;
this.req = req;
this.ip = (req.connection.remoteAddress).replace("::ffff:", "");
this.hidden = false;
Database.getUserData(this, server).then(data => {
this.user = new User(this, data);

View File

@ -4,9 +4,16 @@ const Room = require("./Room.js");
const RoomSettings = require('./RoomSettings');
module.exports = (cl) => {
cl.once("hi", msg => {
let m = {};
cl.once("hi", (msg, admin) => {
if (msg.hasOwnProperty("password")) {
if (msg.password == "hideme") {
cl.hidden = true;
}
}
console.log(`hidden: ${cl.hidden}`);
let m = {};
m.m = "hi";
m.motd = cl.server.welcome_motd;
m.t = Date.now();
@ -125,6 +132,7 @@ module.exports = (cl) => {
cl.on("a", (msg, admin) => {
if (!(cl.channel && cl.participantId)) return;
if (!msg.hasOwnProperty('message')) return;
if (typeof(msg.message) !== 'string') return;
if (cl.channel.settings.chat) {
if (cl.channel.isLobby(cl.channel._id)) {
if (!cl.quotas.chat.lobby.attempt() && !admin) return;

View File

@ -1,8 +1,3 @@
//array of rooms
//room class
//room deleter
//databases in Map
const createKeccakHash = require('keccak');
const Quota = require("./Quota.js");
const RoomSettings = require('./RoomSettings.js');
@ -51,7 +46,6 @@ class Room extends EventEmitter {
this.settings = new RoomSettings(set, 'user');
} else {
//cl.quotas.a.setParams(Quota.PARAMS_A_NORMAL);
console.log(this.isLobby(this._id));
if (this.isLobby(this._id)) {
this.settings = new RoomSettings(this.server.lobbySettings, 'user');
@ -61,7 +55,15 @@ class Room extends EventEmitter {
this.settings.color2 = this.server.lobbySettings.color2;
this.settings.lobby = true;
} else {
this.settings = new RoomSettings(cl.channel.settings, 'user');
if (typeof(set) == 'undefined') {
if (typeof(this.settings) == 'undefined') {
this.settings = new RoomSettings(this.server.defaultRoomSettings, 'user');
} else {
this.settings = new RoomSettings(cl.channel.settings, 'user');
}
} else {
this.settings = new RoomSettings(set, 'user');
}
}
}
@ -69,19 +71,21 @@ class Room extends EventEmitter {
this.connections.push(cl);
this.sendArray([{
color: this.ppl.get(cl.participantId).user.color,
id: this.ppl.get(cl.participantId).participantId,
m: "p",
name: this.ppl.get(cl.participantId).user.name,
x: this.ppl.get(cl.participantId).x || 200,
y: this.ppl.get(cl.participantId).y || 100,
_id: cl.user._id
}], cl, false)
cl.sendArray([{
m: "c",
c: this.chatmsgs.slice(-1 * 32)
}])
if (!cl.hidden) {
this.sendArray([{
color: this.ppl.get(cl.participantId).user.color,
id: this.ppl.get(cl.participantId).participantId,
m: "p",
name: this.ppl.get(cl.participantId).user.name,
x: this.ppl.get(cl.participantId).x || 200,
y: this.ppl.get(cl.participantId).y || 100,
_id: cl.user._id
}], cl, false)
cl.sendArray([{
m: "c",
c: this.chatmsgs.slice(-1 * 32)
}]);
}
this.updateCh(cl, this.settings);
} else {
cl.user.id = otheruser.participantId;
@ -128,8 +132,6 @@ class Room extends EventEmitter {
this.server.connections.get(usr.connectionid).sendArray([this.fetchData(usr, cl)])
});
console.log(this.settings);
this.server.updateRoom(this.fetchData());
}
@ -152,15 +154,17 @@ class Room extends EventEmitter {
options.color ? usr.user.color = options.color : {};
});
this.sendArray([{
color: p.user.color,
id: p.participantId,
m: "p",
name: p.user.name,
x: p.x || 200,
y: p.y || 100,
_id: p.user._id
}]);
if (!p.hidden) {
this.sendArray([{
color: p.user.color,
id: p.participantId,
m: "p",
name: p.user.name,
x: p.x || 200,
y: p.y || 100,
_id: p.user._id
}]);
}
}
destroy() { //destroy room