Fix verifySet, give msg syntax

This commit is contained in:
Charsy89 2019-11-20 16:11:11 -07:00
parent ae93af2143
commit e27484a039
1 changed files with 6 additions and 7 deletions

View File

@ -11,7 +11,7 @@ class Room extends EventEmitter {
this.server = server;
this.crown = null;
this.crowndropped = false;
this.settings = this.verifySet(this._id,settings);
this.settings = this.verifySet(this._id,{set:settings});
this.chatmsgs = [];
this.ppl = new Map();
this.connections = [];
@ -102,7 +102,6 @@ class Room extends EventEmitter {
options.name ? this.ppl.get(pid).user.name = options.name : {};
options._id ? this.ppl.get(pid).user._id = options._id : {};
options.color ? this.ppl.get(pid).user.color = options.color : {};
options.name ? this.ppl.get(pid).user.name = options.name : {};
this.connections.filter((ofo) => ofo.participantId == p.participantId).forEach((usr) => {
options.name ? usr.user.name = options.name : {};
options._id ? usr.user._id = options._id : {};
@ -394,21 +393,21 @@ class Room extends EventEmitter {
if(this.isLobby(_id)) msg.set = {visible:true,color:this.server.defaultLobbyColor,color2:this.server.defaultLobbyColor2,chat:true,crownsolo:false,lobby:true};
}
if(!isBool(msg.set.visible)){
if(msg.set.visible == undefined) msg.set.visible = (room.settings.visible || true);
if(msg.set.visible == undefined) msg.set.visible = (!isObj(this.settings) ? true : this.settings.visible);
else msg.set.visible = true;
};
if(!isBool(msg.set.chat)){
if(msg.set.chat == undefined) msg.set.chat = (room.settings.chat || true);
if(msg.set.chat == undefined) msg.set.chat = (!isObj(this.settings) ? true : this.settings.chat);
else msg.set.chat = true;
};
if(!isBool(msg.set.crownsolo)){
if(msg.set.crownsolo == undefined) msg.set.crownsolo = (room.settings.crownsolo || false);
if(msg.set.crownsolo == undefined) msg.set.crownsolo = (!isObj(this.settings) ? false : this.settings.crownsolo);
else msg.set.crownsolo = false;
};
if(!isString(msg.set.color) || !/^#[0-9a-f]{6}$/i.test(msg.set.color)) msg.set.color = (room.settings.color || this.server.defaultRoomColor);
if(!isString(msg.set.color) || !/^#[0-9a-f]{6}$/i.test(msg.set.color)) msg.set.color = (!isObj(this.settings) ? this.server.defaultRoomColor : this.settings.color);
if(isString(msg.set.color2)){
if(!/^#[0-9a-f]{6}$/i.test(msg.set.color2)){
if(room.settings.color2) msg.set.color2 = room.settings.color2;
if(this.settings.color2) msg.set.color2 = this.settings.color2;
else delete msg.set.color2; // keep it nice and clean
}
};