Update app.js

master
Andy Smy 2025-05-13 07:59:06 +01:00 committed by GitHub
parent 5cdc232853
commit 63c05d9076
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 6 deletions

View File

@ -145,6 +145,9 @@ function countDown(dir) {
processing = false; processing = false;
return; return;
} }
// Suppress dir when play after time
if(timeCalled)
counter -= dir;
// Correction to last ball of over // Correction to last ball of over
if(counter<0) { if(counter<0) {
counter = BALLS_PER_OVER -1; counter = BALLS_PER_OVER -1;
@ -175,7 +178,7 @@ function countDown(dir) {
var timeDuration = new Date( var timeDuration = new Date(
timeSig.getTime() - lastTimeTime); timeSig.getTime() - lastTimeTime);
addLog(timeSig, over, counter, addLog(timeSig, over, counter,
"Play", /*LANG*/"Lost: " + formatDuration(timeDuration)); "Play", /*LANG*/"Lost:" + formatDuration(timeDuration));
} }
if(counter>0) // reset elapsed time if(counter>0) // reset elapsed time
@ -349,7 +352,7 @@ function showMainMenu() {
if(wickets>0) if(wickets>0)
scrollMenuItems.push(/*LANG*/"Recall Batter"); scrollMenuItems.push(/*LANG*/"Recall Batter");
scrollMenuItems.push("Call Time"); scrollMenuItems.push("Call Time");
scrollMenuItems.push("2nd Innings"); scrollMenuItems.push("New Innings");
if(!HRM) if(!HRM)
scrollMenuItems.push("Start HRM"); scrollMenuItems.push("Start HRM");
} }
@ -381,7 +384,7 @@ function showMainMenu() {
incrementWickets(1); incrementWickets(1);
if(scrollMenuItems[idx]==/*LANG*/"Recall Batter") if(scrollMenuItems[idx]==/*LANG*/"Recall Batter")
incrementWickets(-1); incrementWickets(-1);
if(scrollMenuItems[idx]=="2nd Innings") if(scrollMenuItems[idx]=="New Innings")
newInnings(); newInnings();
if(scrollMenuItems[idx]=="Start HRM" if(scrollMenuItems[idx]=="Start HRM"
|| scrollMenuItems[idx]=="Stop HRM") { || scrollMenuItems[idx]=="Stop HRM") {
@ -394,7 +397,7 @@ function showMainMenu() {
function newInnings() { function newInnings() {
var timeSig = new Date(); var timeSig = new Date();
if(over!=0) { // next innings if(over!=0) { // new innings
E.showPrompt(/*LANG*/"Start next innings?"). E.showPrompt(/*LANG*/"Start next innings?").
then(function(confirmed) { then(function(confirmed) {
if (confirmed) { if (confirmed) {
@ -416,7 +419,7 @@ function newInnings() {
menu = showMainMenu(); menu = showMainMenu();
} }
}); });
} else { // 1st innings } else { // resume innings or start app
addLog(timeSig, OVERS_PER_INNINGS + 1, BALLS_PER_OVER, addLog(timeSig, OVERS_PER_INNINGS + 1, BALLS_PER_OVER,
"New Innings", require("locale").date(new Date(), 1)); "New Innings", require("locale").date(new Date(), 1));
} }
@ -425,7 +428,7 @@ function newInnings() {
var file = require("Storage").open("matchlog.csv","a"); var file = require("Storage").open("matchlog.csv","a");
// save state on exit TODO WIP // save state on exit TODO WIP
E.on("kill", function() { E.on("kill", function() {
console.log("Umpire app closed"); console.log("Umpire app closed at " + (over-1) + "." + counter);
}); });
// start app // start app
newInnings(); // prepare 1st innings newInnings(); // prepare 1st innings