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

fix high score comparison, some other stuff

parent d6d0c3f4
No related branches found
No related tags found
No related merge requests found
...@@ -11,15 +11,9 @@ load("graphic.js"); ...@@ -11,15 +11,9 @@ load("graphic.js");
load("sbbsdefs.js") load("sbbsdefs.js")
load("funclib.js"); load("funclib.js");
splashStart();
client.subscribe("uberblox","players");
client.subscribe("uberblox","alltime");
var oldpass = console.ctrl_key_passthru; var oldpass = console.ctrl_key_passthru;
var data = new GameData(); var data = new GameData();
/* assign callback method to client object */
client.callback=processUpdates;
/* cycle client and check for updates */ /* cycle client and check for updates */
function cycle() { function cycle() {
client.cycle(); client.cycle();
...@@ -52,8 +46,9 @@ function gotoxy(x,y) ...@@ -52,8 +46,9 @@ function gotoxy(x,y)
var posy=22-(y*2); var posy=22-(y*2);
console.gotoxy(posx,posy); console.gotoxy(posx,posy);
} }
function splashStart() function open()
{ {
client.callback=processUpdates;
console.ctrlkey_passthru="+ACGKLOPQRTUVWXYZ"; console.ctrlkey_passthru="+ACGKLOPQRTUVWXYZ";
bbs.sys_status|=SS_MOFF; bbs.sys_status|=SS_MOFF;
bbs.sys_status|=SS_PAUSEOFF; bbs.sys_status|=SS_PAUSEOFF;
...@@ -67,27 +62,29 @@ function splashStart() ...@@ -67,27 +62,29 @@ function splashStart()
while(console.inkey(K_NOECHO|K_NOSPIN)===""); while(console.inkey(K_NOECHO|K_NOSPIN)==="");
} }
console.clear(); console.clear();
client.subscribe("uberblox","players");
client.subscribe("uberblox","alltime");
} }
function splashExit() function close()
{ {
client.unsubscribe("uberblox","players");
client.unsubscribe("uberblox","alltime");
data.storePlayer();
console.ctrlkey_passthru=oldpass; console.ctrlkey_passthru=oldpass;
bbs.sys_status&=~SS_MOFF; bbs.sys_status&=~SS_MOFF;
bbs.sys_status&=~SS_PAUSEOFF; bbs.sys_status&=~SS_PAUSEOFF;
console.clear(ANSI_NORMAL); console.clear();
var splash_filename=root + "exit.bin"; var splash_filename=root + "exit.bin";
if(!file_exists(splash_filename)) exit(); if(file_exists(splash_filename)) {
var splash=new Graphic(80,21);
var splash_size=file_size(splash_filename); splash.load(splash_filename);
splash_size/=2; splash.draw();
splash_size/=80;
var splash=new Graphic(80,splash_size); console.gotoxy(1,23);
splash.load(splash_filename); console.center("\1n\1c[\1hPress any key to continue\1n\1c]");
splash.draw(); while(console.inkey(K_NOECHO|K_NOSPIN)==="");
}
console.gotoxy(1,23); console.clear();
console.center("\1n\1c[\1hPress any key to continue\1n\1c]");
while(console.inkey(K_NOECHO|K_NOSPIN)==="");
console.clear(ANSI_NORMAL);
} }
function blox() function blox()
{ {
...@@ -219,10 +216,12 @@ function blox() ...@@ -219,10 +216,12 @@ function blox()
} }
function endGame() function endGame()
{ {
if(data.players[user.alias].score<points) { if(data.players[user.alias].score == undefined || data.players[user.alias].score < points) {
data.players[user.alias].score=points; data.players[user.alias].score = points;
data.storePlayer(); data.storePlayer();
data.allTime();
} }
console.clear(); console.clear();
gameend.draw(); gameend.draw();
console.gotoxy(52,5); console.gotoxy(52,5);
...@@ -232,7 +231,7 @@ function blox() ...@@ -232,7 +231,7 @@ function blox()
} }
function init() function init()
{ {
client.write("uberblox","players." + user.alias + ".laston",time(),2); data.players[user.alias].laston = time();
logo=new Graphic(18,22); logo=new Graphic(18,22);
logo.load(root + "blox.bin"); logo.load(root + "blox.bin");
lobby=new Graphic(80,23); lobby=new Graphic(80,23);
...@@ -610,6 +609,9 @@ function GameData() ...@@ -610,6 +609,9 @@ function GameData()
this.storePlayer=function() this.storePlayer=function()
{ {
client.write("uberblox","players." + user.alias,this.players[user.alias],2); client.write("uberblox","players." + user.alias,this.players[user.alias],2);
}
this.allTime=function()
{
client.lock("uberblox","alltime",2); client.lock("uberblox","alltime",2);
if(this.players[user.alias].score > this.alltime.score) { if(this.players[user.alias].score > this.alltime.score) {
this.alltime=client.read("uberblox","alltime"); this.alltime=client.read("uberblox","alltime");
...@@ -661,7 +663,6 @@ function Tile(bg,fg) ...@@ -661,7 +663,6 @@ function Tile(bg,fg)
} }
} }
open();
blox(); blox();
client.unsubscribe("uberblox","players"); close();
client.unsubscribe("uberblox","alltime");
splashExit();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment