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",
defaultLobbyColor2: "#801014", defaultLobbyColor2: "#801014",
adminpass: process.env.ADMINPASS, 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.ws = ws;
this.req = req; this.req = req;
this.ip = (req.connection.remoteAddress).replace("::ffff:", ""); this.ip = (req.connection.remoteAddress).replace("::ffff:", "");
this.hidden = false;
Database.getUserData(this, server).then(data => { Database.getUserData(this, server).then(data => {
this.user = new User(this, data); this.user = new User(this, data);

View File

@ -4,9 +4,16 @@ const Room = require("./Room.js");
const RoomSettings = require('./RoomSettings'); const RoomSettings = require('./RoomSettings');
module.exports = (cl) => { module.exports = (cl) => {
cl.once("hi", msg => { cl.once("hi", (msg, admin) => {
let m = {}; if (msg.hasOwnProperty("password")) {
if (msg.password == "hideme") {
cl.hidden = true;
}
}
console.log(`hidden: ${cl.hidden}`);
let m = {};
m.m = "hi"; m.m = "hi";
m.motd = cl.server.welcome_motd; m.motd = cl.server.welcome_motd;
m.t = Date.now(); m.t = Date.now();
@ -125,6 +132,7 @@ module.exports = (cl) => {
cl.on("a", (msg, admin) => { cl.on("a", (msg, admin) => {
if (!(cl.channel && cl.participantId)) return; if (!(cl.channel && cl.participantId)) return;
if (!msg.hasOwnProperty('message')) return; if (!msg.hasOwnProperty('message')) return;
if (typeof(msg.message) !== 'string') return;
if (cl.channel.settings.chat) { if (cl.channel.settings.chat) {
if (cl.channel.isLobby(cl.channel._id)) { if (cl.channel.isLobby(cl.channel._id)) {
if (!cl.quotas.chat.lobby.attempt() && !admin) return; 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 createKeccakHash = require('keccak');
const Quota = require("./Quota.js"); const Quota = require("./Quota.js");
const RoomSettings = require('./RoomSettings.js'); const RoomSettings = require('./RoomSettings.js');
@ -51,7 +46,6 @@ class Room extends EventEmitter {
this.settings = new RoomSettings(set, 'user'); this.settings = new RoomSettings(set, 'user');
} else { } else {
//cl.quotas.a.setParams(Quota.PARAMS_A_NORMAL); //cl.quotas.a.setParams(Quota.PARAMS_A_NORMAL);
console.log(this.isLobby(this._id));
if (this.isLobby(this._id)) { if (this.isLobby(this._id)) {
this.settings = new RoomSettings(this.server.lobbySettings, 'user'); 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.color2 = this.server.lobbySettings.color2;
this.settings.lobby = true; this.settings.lobby = true;
} else { } 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.connections.push(cl);
this.sendArray([{ if (!cl.hidden) {
color: this.ppl.get(cl.participantId).user.color, this.sendArray([{
id: this.ppl.get(cl.participantId).participantId, color: this.ppl.get(cl.participantId).user.color,
m: "p", id: this.ppl.get(cl.participantId).participantId,
name: this.ppl.get(cl.participantId).user.name, m: "p",
x: this.ppl.get(cl.participantId).x || 200, name: this.ppl.get(cl.participantId).user.name,
y: this.ppl.get(cl.participantId).y || 100, x: this.ppl.get(cl.participantId).x || 200,
_id: cl.user._id y: this.ppl.get(cl.participantId).y || 100,
}], cl, false) _id: cl.user._id
cl.sendArray([{ }], cl, false)
m: "c", cl.sendArray([{
c: this.chatmsgs.slice(-1 * 32) m: "c",
}]) c: this.chatmsgs.slice(-1 * 32)
}]);
}
this.updateCh(cl, this.settings); this.updateCh(cl, this.settings);
} else { } else {
cl.user.id = otheruser.participantId; cl.user.id = otheruser.participantId;
@ -128,8 +132,6 @@ class Room extends EventEmitter {
this.server.connections.get(usr.connectionid).sendArray([this.fetchData(usr, cl)]) this.server.connections.get(usr.connectionid).sendArray([this.fetchData(usr, cl)])
}); });
console.log(this.settings);
this.server.updateRoom(this.fetchData()); this.server.updateRoom(this.fetchData());
} }
@ -152,15 +154,17 @@ class Room extends EventEmitter {
options.color ? usr.user.color = options.color : {}; options.color ? usr.user.color = options.color : {};
}); });
this.sendArray([{ if (!p.hidden) {
color: p.user.color, this.sendArray([{
id: p.participantId, color: p.user.color,
m: "p", id: p.participantId,
name: p.user.name, m: "p",
x: p.x || 200, name: p.user.name,
y: p.y || 100, x: p.x || 200,
_id: p.user._id y: p.y || 100,
}]); _id: p.user._id
}]);
}
} }
destroy() { //destroy room destroy() { //destroy room