Skip to content
Snippets Groups Projects
Commit 148cc622 authored by mcmlxxix's avatar mcmlxxix
Browse files

remove debugging win location, clear player avatar on quit/disconnect...

remove debugging win location, clear player avatar on quit/disconnect mid-race. join the first existing open game or first available game number instead of just the first available game number.
parent cf31a5e2
No related branches found
No related tags found
No related merge requests found
......@@ -332,13 +332,7 @@ function lobby() {
}
function joinMaze() {
/* find the first open game number */
gnum=1;
for each(var g in data.games) {
if(g.status == status.RACING)
gnum++;
else if(countMembers(g.players) >= settings.max_players)
gnum++;
}
gnum=getOpenGame();
client.lock("mazerace","games." + gnum,2);
var player = new Player(profile.name,profile.avatar,profile.color);
......@@ -359,6 +353,19 @@ function lobby() {
menu.disable("J");
data.updated=true;
}
function getOpenGame() {
for each(var g in data.games) {
if(g.status == status.RACING)
continue;
else if(countMembers(g.players) >= settings.max_players)
continue;
return g.gameNumber;
}
var g=1;
while(data.games[g])
g++;
return g;
}
function leaveMaze() {
delete data.games[gnum].players[profile.name];
client.remove("mazerace","games."+gnum+".players."+profile.name,2);
......@@ -485,8 +492,12 @@ function race(gameNumber) {
obj[p.shift()] = update.data;
break;
case "SUBSCRIBE":
data.online=client.who(game_id,"games");
break;
case "UNSUBSCRIBE":
data.online=client.who(game_id,"games");
if(maze.players[update.data.nick])
maze.players[update.data.nick].frame.delete();
break;
}
} catch(e) {
......@@ -671,8 +682,6 @@ function race(gameNumber) {
function playerAtFinish() {
if(player.coords.x == (maze.finish.x*3+1) && player.coords.y == (maze.finish.y*2+1))
return true;
else if(player.coords.x == 1 && player.coords.y == 1)
return true;
return false;
}
function movePosition(k) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment