Rename object 'keys' to fix bug (there's already a function named that way)

This commit is contained in:
Sasha 2018-04-13 09:11:35 +02:00
parent 1d7a680d48
commit 315db97abb

View file

@ -1,6 +1,6 @@
function Room(domElem, lib) {
var players = {};
var keys = {};
var keysByName = {};
var logins = [];
var session = {
key: null,
@ -51,10 +51,10 @@ function Room(domElem, lib) {
function enter(key, name) {
var player = Player(key, name);
keys[key] = name;
keysByName[name] = key;
players[key] = player;
player.position = lib.insert(name, logins);
beforePlayer = players[keys[logins[player.position]]];
beforePlayer = players[keysByName[logins[player.position]]];
playersList.insertBefore(player.dom, beforePlayer && beforePlayer.dom);
logins.splice(player.position, 0, name);
}
@ -67,7 +67,7 @@ function Room(domElem, lib) {
if(player != undefined) {
playersList.removeChild(player.dom);
logins.splice(player.position, 1);
delete keys[player.name]
delete keysByName[player.name]
delete players[key];
}
}