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

center score screen, fix player sync issue

parent 8032fc17
No related branches found
No related tags found
No related merge requests found
......@@ -12,13 +12,13 @@ function playGame(profile,game) {
/* directional constants */
direction = {UP:0,DOWN:1,LEFT:2,RIGHT:3};
client.subscribe(game_id,"metadata." + game.gameNumber);
last_update=Date.now();
gameFrame=new Frame(undefined,undefined,undefined,undefined,undefined,frame);
gameFrame.open();
initPlayers();
pause = settings.pause;
queue = client.read(game_id,"metadata." + game.gameNumber + ".queue",1);
client.subscribe(game_id,"metadata." + game.gameNumber);
drawScore(localPlayer);
}
function close() {
......@@ -192,6 +192,13 @@ function playGame(profile,game) {
players[p].open();
index++;
}
var online = onlinePlayers();
for each(var p in online) {
if(p.nick == profile.name)
continue;
if(players[p.nick])
players[p.nick].ready = true;
}
}
function getMatrix(h,w) {
var grid=new Array(h);
......@@ -298,18 +305,16 @@ function playGame(profile,game) {
drawBoard(p);
break;
default:
log(LOG_WARNING,"Unknown tetris data type received");
log(LOG_WARNING,"packet: " + data.toSource());
break;
}
}
else if(packet.oper == "SUBSCRIBE") {
if(players[packet.nick])
players[packet.nick].ready = true;
if(players[packet.data.nick])
players[packet.data.nick].ready = true;
}
else if(packet.oper == "UNSUBSCRIBE") {
if(players[packet.nick])
players[packet.nick].ready = false;
if(players[packet.data.nick])
players[packet.data.nick].ready = false;
}
}
......@@ -951,6 +956,11 @@ function playGame(profile,game) {
}
/* other shit */
function onlinePlayers() {
var online = client.who(game_id,"metadata." + game.gameNumber);
log(online.toSource());
return online;
}
function handleExit() {
if(game.status == status.PLAYING) {
var f = showMessage("\1c\1hQuit game? \1n\1c[\1hN\1n\1c,\1hy\1n\1c]");
......
......@@ -271,7 +271,7 @@ var lobby=(function() {
/* show rankings */
function showScores() {
var scoreFrame = new Frame(16,6,57,14,BG_BLUE + YELLOW,frame);
var scoreFrame = new Frame(12,6,57,14,BG_BLUE + YELLOW,frame);
var count = 0;
var scores_per_page = 10;
var list = sortScores("score");
......
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