Skip to content
Snippets Groups Projects
Commit 510fee8b authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Revert back to using system.datestr() for preferred short date display output

Stripped trailing whitespace
parent 0cdae92f
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ const char_flag = '\x01r\x9f'; ...@@ -24,7 +24,7 @@ const char_flag = '\x01r\x9f';
const char_badflag = '\x01r\x01h!'; const char_badflag = '\x01r\x01h!';
const char_unsure = '\x01r?'; const char_unsure = '\x01r?';
const attr_empty = '\x01b'; //\x01h'; const attr_empty = '\x01b'; //\x01h';
const char_empty = attr_empty + '\xFA'; const char_empty = attr_empty + '\xFA';
const char_covered = attr_empty +'\xFE'; const char_covered = attr_empty +'\xFE';
const char_mine = '\x01r\x01h\xEB'; const char_mine = '\x01r\x01h\xEB';
const char_detonated_mine = '\x01r\x01h\x01i\*'; const char_detonated_mine = '\x01r\x01h\x01i\*';
...@@ -158,7 +158,7 @@ function show_image(filename, fx, delay) ...@@ -158,7 +158,7 @@ function show_image(filename, fx, delay)
function countmines(x, y) function countmines(x, y)
{ {
var count = 0; var count = 0;
for(var yi = y - 1; yi <= y + 1; yi++) for(var yi = y - 1; yi <= y + 1; yi++)
for(var xi = x - 1; xi <= x + 1; xi++) for(var xi = x - 1; xi <= x + 1; xi++)
if((yi != y || xi != x) && mined(xi, yi)) if((yi != y || xi != x) && mined(xi, yi))
...@@ -181,7 +181,7 @@ function place_mines() ...@@ -181,7 +181,7 @@ function place_mines()
mined[i] = mined[r]; mined[i] = mined[r];
mined[r] = tmp; mined[r] = tmp;
} }
for(var y = 0; y < game.height; y++) { for(var y = 0; y < game.height; y++) {
for(var x = 0; x < game.width; x++) { for(var x = 0; x < game.width; x++) {
if(mined[(y * game.width) + x]) if(mined[(y * game.width) + x])
...@@ -268,7 +268,7 @@ function lostgame(cause) ...@@ -268,7 +268,7 @@ function lostgame(cause)
show_image(boom_image, false, options.boom_delay); show_image(boom_image, false, options.boom_delay);
show_image(loser_image, true); show_image(loser_image, true);
} }
function calc_difficulty(game) function calc_difficulty(game)
{ {
const game_cells = game.height * game.width; const game_cells = game.height * game.width;
...@@ -388,15 +388,10 @@ function get_winners(level) ...@@ -388,15 +388,10 @@ function get_winners(level)
if(level) if(level)
list = list.filter(function (obj) { var difficulty = calc_difficulty(obj); list = list.filter(function (obj) { var difficulty = calc_difficulty(obj);
return (difficulty <= level && difficulty > level - 1); }); return (difficulty <= level && difficulty > level - 1); });
list.sort(compare_won_game); list.sort(compare_won_game);
return list;
}
function datestr(t) return list;
{
return strftime("%b%m-%y", t);
} }
function show_winners(level) function show_winners(level)
...@@ -445,7 +440,7 @@ function show_winners(level) ...@@ -445,7 +440,7 @@ function show_winners(level)
,game.width ,game.width
,game.height ,game.height
,game.mines ,game.mines
,datestr(game.end) ,system.datestr(game.end)
)); ));
count++; count++;
displayed++; displayed++;
...@@ -464,26 +459,26 @@ function show_log() ...@@ -464,26 +459,26 @@ function show_log()
console.attributes = YELLOW|BG_BLUE|BG_HIGH; console.attributes = YELLOW|BG_BLUE|BG_HIGH;
console_center(" " + title + " Log "); console_center(" " + title + " Log ");
console.attributes = LIGHTGRAY; console.attributes = LIGHTGRAY;
var winners = json_lines.get(winners_list); var winners = json_lines.get(winners_list);
if(typeof winners != 'object') if(typeof winners != 'object')
winners = []; winners = [];
var losers = json_lines.get(losers_list); var losers = json_lines.get(losers_list);
if(typeof losers != 'object') if(typeof losers != 'object')
losers = []; losers = [];
var list = losers.concat(winners); var list = losers.concat(winners);
if(!list.length) { if(!list.length) {
alert("No winners or losers yet!"); alert("No winners or losers yet!");
return; return;
} }
console.attributes = WHITE; console.attributes = WHITE;
console.print(format("Date %-25s Lvl Time WxHxMines Rev Result\r\n", "User", "")); console.print(format("Date %-25s Lvl Time WxHxMines Rev Result\r\n", "User", ""));
list.sort(compare_game); list.sort(compare_game);
for(var i = 0; i < list.length && !console.aborted; i++) { for(var i = 0; i < list.length && !console.aborted; i++) {
var game = list[i]; var game = list[i];
if(i&1) if(i&1)
...@@ -491,7 +486,7 @@ function show_log() ...@@ -491,7 +486,7 @@ function show_log()
else else
console.attributes = BG_CYAN; console.attributes = BG_CYAN;
console.print(format("%s %-25s %1.2f %s %3ux%2ux%-3u %3s %s\x01>\x01n\r\n" console.print(format("%s %-25s %1.2f %s %3ux%2ux%-3u %3s %s\x01>\x01n\r\n"
,datestr(game.end) ,system.datestr(game.end)
,game.name ,game.name
,calc_difficulty(game) ,calc_difficulty(game)
,secondstr(calc_time(game), true) ,secondstr(calc_time(game), true)
...@@ -511,15 +506,15 @@ function show_best() ...@@ -511,15 +506,15 @@ function show_best()
console.attributes = YELLOW|BG_BLUE|BG_HIGH; console.attributes = YELLOW|BG_BLUE|BG_HIGH;
console_center(" Your " + title + " Personal Best Wins "); console_center(" Your " + title + " Personal Best Wins ");
console.attributes = LIGHTGRAY; console.attributes = LIGHTGRAY;
var wins = []; var wins = [];
for(var i in best) for(var i in best)
wins.push(best[i]); wins.push(best[i]);
wins.reverse(); // Display newest first wins.reverse(); // Display newest first
console.attributes = WHITE; console.attributes = WHITE;
console.print("Date Lvl Time WxHxMines Rev\r\n"); console.print("Date Lvl Time WxHxMines Rev\r\n");
for(var i in wins) { for(var i in wins) {
var game = wins[i]; var game = wins[i];
if(i&1) if(i&1)
...@@ -527,7 +522,7 @@ function show_best() ...@@ -527,7 +522,7 @@ function show_best()
else else
console.attributes = BG_CYAN; console.attributes = BG_CYAN;
console.print(format("%s %1.2f %s %3ux%2ux%-3u %s\x01>\x01n\r\n" console.print(format("%s %1.2f %s %3ux%2ux%-3u %s\x01>\x01n\r\n"
,datestr(game.end) ,system.datestr(game.end)
,calc_difficulty(game) ,calc_difficulty(game)
,secondstr(calc_time(game), true) ,secondstr(calc_time(game), true)
,game.width, game.height, game.mines ,game.width, game.height, game.mines
...@@ -652,12 +647,12 @@ function draw_cell(x, y) ...@@ -652,12 +647,12 @@ function draw_cell(x, y)
function countflagged(x, y) function countflagged(x, y)
{ {
var count = 0; var count = 0;
for(var yi = y - 1; yi <= y + 1; yi++) for(var yi = y - 1; yi <= y + 1; yi++)
for(var xi = x - 1; xi <= x + 1; xi++) for(var xi = x - 1; xi <= x + 1; xi++)
if((yi != y || xi != x) && flagged(xi, yi)) if((yi != y || xi != x) && flagged(xi, yi))
count++; count++;
return count; return count;
} }
...@@ -665,12 +660,12 @@ function countflagged(x, y) ...@@ -665,12 +660,12 @@ function countflagged(x, y)
function countunflagged(x, y) function countunflagged(x, y)
{ {
var count = 0; var count = 0;
for(var yi = y - 1; yi <= y + 1; yi++) for(var yi = y - 1; yi <= y + 1; yi++)
for(var xi = x - 1; xi <= x + 1; xi++) for(var xi = x - 1; xi <= x + 1; xi++)
if((yi != y || xi != x) && unflagged(xi, yi)) if((yi != y || xi != x) && unflagged(xi, yi))
count++; count++;
return count; return count;
} }
...@@ -692,12 +687,12 @@ function show_title() ...@@ -692,12 +687,12 @@ function show_title()
{ {
console.attributes = YELLOW|BG_BLUE|BG_HIGH; console.attributes = YELLOW|BG_BLUE|BG_HIGH;
console_center(title + " " + REVISION); console_center(title + " " + REVISION);
} }
function draw_border() function draw_border()
{ {
const margin = get_margin(); const margin = get_margin();
console.creturn(); console.creturn();
console.attributes = LIGHTGRAY; console.attributes = LIGHTGRAY;
console.cleartoeol(); console.cleartoeol();
...@@ -788,7 +783,7 @@ function draw_board(full) ...@@ -788,7 +783,7 @@ function draw_board(full)
else else
cmds += "\x01h\x01k\x01~Dig Flag "; cmds += "\x01h\x01k\x01~Dig Flag ";
} }
else else
cmds += "\x01h\x01~D\x01nig \x01h\x01~F\x01nlag "; cmds += "\x01h\x01~D\x01nig \x01h\x01~F\x01nlag ";
} }
cmds += "\x01n\x01h\x01~N\x01new \x01h\x01~Q\x01nuit"; cmds += "\x01n\x01h\x01~N\x01new \x01h\x01~Q\x01nuit";
...@@ -885,7 +880,7 @@ function uncover_cell(x, y) ...@@ -885,7 +880,7 @@ function uncover_cell(x, y)
board[y][x].covered = false; board[y][x].covered = false;
board[y][x].unsure = false; board[y][x].unsure = false;
board[y][x].changed = true; board[y][x].changed = true;
if(!mined(x, y)) if(!mined(x, y))
return false; return false;
board[y][x].detonated = true; board[y][x].detonated = true;
...@@ -907,7 +902,7 @@ function uncover(x, y) ...@@ -907,7 +902,7 @@ function uncover(x, y)
{ {
if(!game.start) if(!game.start)
start_game(); start_game();
if(!board[y] || !board[y][x] || board[y][x].flagged || !board[y][x].covered) if(!board[y] || !board[y][x] || board[y][x].flagged || !board[y][x].covered)
return; return;
if(uncover_cell(x, y)) if(uncover_cell(x, y))
...@@ -923,7 +918,7 @@ function uncover(x, y) ...@@ -923,7 +918,7 @@ function uncover(x, y)
function can_chord(x, y) function can_chord(x, y)
{ {
return !board[y][x].covered return !board[y][x].covered
&& board[y][x].count && board[y][x].count
&& board[y][x].count == countflagged(x, y) && board[y][x].count == countflagged(x, y)
&& countunflagged(x, y); && countunflagged(x, y);
...@@ -1571,23 +1566,23 @@ try { ...@@ -1571,23 +1566,23 @@ try {
if(!difficulty) if(!difficulty)
difficulty = 1; difficulty = 1;
play(); play();
userprops.set(ini_section, "selector", selector%selectors.length); userprops.set(ini_section, "selector", selector%selectors.length);
userprops.set(ini_section, "highlight", highlight); userprops.set(ini_section, "highlight", highlight);
userprops.set(ini_section, "difficulty", difficulty); userprops.set(ini_section, "difficulty", difficulty);
} catch(e) { } catch(e) {
var msg = file_getname(e.fileName) + var msg = file_getname(e.fileName) +
" line " + e.lineNumber + " line " + e.lineNumber +
": " + e.message; ": " + e.message;
if(js.global.console) if(js.global.console)
console.crlf(); console.crlf();
alert(msg); alert(msg);
if(options.sub && user.alias != author) { if(options.sub && user.alias != author) {
var msgbase = new MsgBase(options.sub); var msgbase = new MsgBase(options.sub);
var hdr = { var hdr = {
to: author, to: author,
from: user.alias || system.operator, from: user.alias || system.operator,
subject: title subject: title
......
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