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

added date of players' last visit to score list,

stretched calendar to fit 6 line months,
fixed monthly reset functions.
parent 8e0a1fd9
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,7 @@ function Boggle() ...@@ -75,6 +75,7 @@ function Boggle()
bbs.sys_status&=~SS_MOFF; bbs.sys_status&=~SS_MOFF;
bbs.sys_status&=~SS_PAUSEOFF; bbs.sys_status&=~SS_PAUSEOFF;
console.attributes=ANSI_NORMAL; console.attributes=ANSI_NORMAL;
players.StorePlayer();
exit(0); exit(0);
} }
function UpdateCalendar() function UpdateCalendar()
...@@ -119,7 +120,7 @@ function Boggle() ...@@ -119,7 +120,7 @@ function Boggle()
} }
function ShowMessage(txt) function ShowMessage(txt)
{ {
console.gotoxy(26,20); console.gotoxy(26,21);
console.putmsg("\1-" + (txt?txt:""),P_SAVEATR); console.putmsg("\1-" + (txt?txt:""),P_SAVEATR);
console.cleartoeol(ANSI_NORMAL); console.cleartoeol(ANSI_NORMAL);
} }
...@@ -435,7 +436,7 @@ function Boggle() ...@@ -435,7 +436,7 @@ function Boggle()
//GAME OBJECTS //GAME OBJECTS
function Lobby(x,y) function Lobby(x,y)
{ {
this.graphic=new Graphic(80,23); this.graphic=new Graphic(80,24);
this.graphic.load(gameroot + "lobby.bin"); this.graphic.load(gameroot + "lobby.bin");
this.x=x; this.x=x;
this.y=y; this.y=y;
...@@ -474,20 +475,39 @@ function Boggle() ...@@ -474,20 +475,39 @@ function Boggle()
} }
} }
} }
var name=plyr.name; if(plyr.name==user.alias) plyr.laston=time();
var laston=plyr.laston; Log("Loading player data: " + plyr.name);
var points=plyr.points; this.players[plyr.name]=new Player(plyr.name,plyr.points,days,plyr.laston);
Log("Loading player data: " + name);
this.players[plyr.name]=new Player(name,points,days,laston);
} }
} }
this.FormatDate=function(timet)
{
var date=new Date(timet*1000);
var m=date.getMonth()+1;
var d=date.getDate();
var y=date.getFullYear()-2000; //assuming no one goes back in time to 1999 to play this
if(m<10) m="0"+m;
if(d<10) d="0"+d;
if(y<10) y="0"+y;
return (m + "/" + d + "/" + y);
}
this.Reset=function()
{
file_remove(this.file.name);
this.Init();
}
this.GetAverage=function(alias) this.GetAverage=function(alias)
{ {
var p=this.FindUser(alias); var p=this.FindUser(alias);
var count=this.GetDayCount(alias); var count=this.GetDayCount(alias);
var avg=p.points/count; var avg=p.points/count;
if(avg>0) return avg; if(avg>0)
{
if(avg<10) return("0"+avg.toFixed(1));
return avg.toFixed(1);
}
return 0; return 0;
} }
this.GetDayCount=function(alias) this.GetDayCount=function(alias)
...@@ -521,6 +541,7 @@ function Boggle() ...@@ -521,6 +541,7 @@ function Boggle()
this.currentdate=new Date(); this.currentdate=new Date();
this.currentmonth=this.currentdate.getMonth(); this.currentmonth=this.currentdate.getMonth();
this.games=[]; this.games=[];
this.winner=false;
this.datafile=new File(gameroot + "month.ini"); this.datafile=new File(gameroot + "month.ini");
this.Init=function() this.Init=function()
...@@ -542,6 +563,17 @@ function Boggle() ...@@ -542,6 +563,17 @@ function Boggle()
this.FindRoundWinner(); this.FindRoundWinner();
this.NewMonth(); this.NewMonth();
} }
else
{
this.datafile.open('r',true);
var name=this.datafile.iniGetValue(null,"winner");
var points=this.datafile.iniGetValue(null,"points");
this.datafile.close();
if(points>0)
{
this.winner={"name":name,"points":points};
}
}
} }
else else
{ {
...@@ -561,12 +593,24 @@ function Boggle() ...@@ -561,12 +593,24 @@ function Boggle()
} }
this.FindRoundWinner=function() this.FindRoundWinner=function()
{ {
for(p in players.players)
{
if(!this.winner) this.winner=players.players[p];
else
{
if(players.players[p].points>this.winner.points) this.winner=players.players[p];
}
}
this.datafile.open('w+',true);
this.datafile.iniSetValue(null,"winner",this.winner.name);
this.datafile.iniSetValue(null,"points",this.winner.points);
this.datafile.close();
players.Reset();
} }
this.NewMonth=function() this.NewMonth=function()
{ {
this.games=[]; this.games=[];
this.datafile.open('w+'); file_touch(this.datafile.name);
this.datafile.close();
var numdays=this.currentdate.daysInMonth(); var numdays=this.currentdate.daysInMonth();
for(var dn=1;dn<=numdays;dn++) for(var dn=1;dn<=numdays;dn++)
{ {
...@@ -854,12 +898,21 @@ function Boggle() ...@@ -854,12 +898,21 @@ function Boggle()
console.right(23-score.name.length); console.right(23-score.name.length);
console.putmsg(PrintPadded(score.points,5,undefined,"right"),P_SAVEATR); console.putmsg(PrintPadded(score.points,5,undefined,"right"),P_SAVEATR);
console.right(3); console.right(3);
console.putmsg(players.GetAverage(score.name).toFixed(1),P_SAVEATR); console.putmsg(players.GetAverage(score.name),P_SAVEATR);
console.right(3); console.right(3);
console.putmsg(PrintPadded(plays,4,undefined,"right"),P_SAVEATR); console.putmsg(PrintPadded(plays,4,undefined,"right"),P_SAVEATR);
console.right(3);
console.putmsg(PrintPadded(players.FormatDate(score.laston),8,undefined,"right"),P_SAVEATR);
index++; index++;
} }
} }
if(month.winner)
{
console.gotoxy(48,18);
console.putmsg("\1c\1h" + month.winner.name);
console.gotoxy(75,18);
console.putmsg("\1c\1h" + month.winner.points);
}
} }
function SortScores() function SortScores()
{ {
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
                  Player Name            Pts   Avg  Plays  Last On                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Lobby Menu Commands:    Last Month's Winner:                    Points:                               [    ] Browse Calendar                                                             [P ] Play Game                                                                   [C ] Change Date                                                                 [R ] Refresh Screen                                                              [Q ] Quit Game                                                                                  Player Name            Pts   Avg  Plays  Last On                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Last Month's Winner:                    Points:       [P ] Play Game           [C ] Change Date                                                                 [R ] Refresh Screen                                                              [Q ] Quit Game                                                                                                                                                   [U p ,D o w n ,L e f t ,R i g h t ] Browse calendar                                           
\ No newline at end of file \ No newline at end of file
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