Make sure keys are always only integers

This commit is contained in:
Sasha 2018-04-13 10:43:11 +02:00
parent a8f951fad4
commit e929920677

View file

@ -45,7 +45,7 @@ function Room(domElem, lib) {
session.key = sessionKey; session.key = sessionKey;
lib.clearElement(playersList); lib.clearElement(playersList);
for(var key in playersHash) { for(var key in playersHash) {
enter(key, playersHash[key] || "anon"); enter(parseInt(key), playersHash[key] || "anon");
} }
} }
@ -60,9 +60,9 @@ function Room(domElem, lib) {
function leave(key) { function leave(key) {
var player = players[key]; var player = players[key];
if(key == session.key) { if(key === session.key) {
off(); off();
} else if(key == session.selected) { } else if(key === session.selected) {
reset(); reset();
} }
if(player != undefined) { if(player != undefined) {