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

minor fix related to json-db.js update

parent 6f5fc961
No related branches found
No related tags found
No related merge requests found
......@@ -555,7 +555,8 @@ function GameData() {
this.loadMonth();
client.unlock(game_id,"month");
this.players = client.read(game_id,"players",1);
if(!this.players)
this.players = {};
if(!this.players[user.alias]) {
this.players[user.alias] = new Player();
this.storePlayer();
......@@ -564,6 +565,7 @@ function GameData() {
/* load this month's boggle boards */
this.loadMonth=function() {
console.putmsg("\rPlease wait. Loading puzzles for this month...\r\n");
this.players=client.read(game_id,"players",1)
this.winner=client.read(game_id,"winner",1);
this.boards=client.read(game_id,"boards",1);
}
......@@ -589,12 +591,12 @@ function GameData() {
this.storeRoundWinner();
client.write(game_id,"month",this.month);
client.write(game_id,"players",{},2);
client.remove(game_id,"players",2);
console.putmsg("\rPlease wait. Creating puzzles for new month...\r\n");
client.lock(game_id,"boards",2);
client.write(game_id,"boards",{});
client.remove(game_id,"boards");
this.boards=[];
var numdays=date.daysInMonth();
for(var dn=1;dn<=numdays;dn++) {
......
......@@ -202,8 +202,7 @@ function blox()
}
function endGame()
{
if(data.players[user.alias].score<points)
{
if(data.players[user.alias].score<points) {
data.players[user.alias].score=points;
data.storePlayer();
}
......@@ -530,13 +529,11 @@ function blox()
index++;
}
}
if(data.alltime.score > 0) {
console.gotoxy(46,20);
console.putmsg("\1n\1yName \1h: " + data.alltime.name);
console.gotoxy(46,21);
console.putmsg("\1n\1yScore\1h: " + data.alltime.score,P_SAVEATR);
}
}
init();
mainLobby();
......@@ -552,8 +549,8 @@ function Grid(c,r)
}
function GameData()
{
this.players=[];
this.alltime=[];
this.players=client.read("uberblox","players",1);
this.alltime=client.read("uberblox","alltime",1);
this.update=false;
this.month=new Date().getMonth();
......@@ -565,16 +562,11 @@ function GameData()
this.reset();
client.unlock("uberblox","month");
this.alltime = client.read("uberblox","alltime",1);
if(!this.alltime.name) {
this.alltime={
name:"no one",
score:0
}
client.write("uberblox","alltime",this.alltime,2);
}
if(!this.alltime)
this.alltime={name:"none",score:0};
this.players = client.read("uberblox","players",1);
if(!this.players)
this.players = {};
if(!this.players[user.alias]) {
this.players[user.alias] = new Player();
client.write("uberblox","players." + user.alias,this.players[user.alias],2);
......@@ -596,15 +588,16 @@ function GameData()
this.reset=function()
{
client.write("uberblox","month",this.month);
client.write("uberblox","players",{},2);
client.remove("uberblox","players",2);
}
this.storePlayer=function()
{
client.write("uberblox","players." + user.alias,this.players[user.alias],2);
client.lock("uberblox","alltime",2);
if(this.players[user.alias].score > this.alltime.score) {
this.alltime=client.read("uberblox","alltime");
if(!this.alltime)
this.alltime={name:"none",score:0};
if(this.players[user.alias].score > this.alltime.score) {
this.alltime.score = this.players[user.alias].score;
this.alltime.name = user.alias;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment