The clock beside the acting player told two lies, in opposite directions. Refresh mid-hand and it restarts at 0:00. The clock lives in memory, so a reload wipes it, and the bar then says the player has just started thinking when they might have been in the tank for two minutes. It is the one number in the bar whose whole job is to tell a dealer when to nudge somebody, and a refresh reset it to "no need". It cannot know that time -- the action moved before this session existed -- so it does not guess. It shows a dash until the action next moves, and says why if you hover: "The action was already on this seat when the page loaded, so there's nothing to time from yet. The clock starts when the action next moves." The moment the action moves it is measuring something it saw, and it counts from zero again. And past an hour it read "65:03". A table left open on a hand really does get there -- the state survives a refresh by design -- and sixty-five minutes written as though it were minutes and seconds is a number the eye gets wrong. It reads 1:05:03 now. Checked in the browser rather than reasoned about: dealt in this session it counts 0:00 then 0:02; refreshed mid-hand it shows the dash and keeps showing it rather than drifting up from an invented zero; one action later it is back to a real 0:00; and with the clock wound forward it reads 1:05:04 with the slow-tank styling still applied. 5 tests (283 total) on the formatting, including that minutes are padded once there are hours and not before, and that a day reads 25:00:00 rather than wrapping. Also checked and correct already: a backgrounded tab does not lose time -- four minutes away reads 4:01 on return, because the clock is a timestamp difference rather than a count of ticks -- and the timer disappears entirely once the hand is over. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
// How the think-clock reads.
|
|
const test = require("node:test");
|
|
const assert = require("node:assert");
|
|
const path = require("path");
|
|
|
|
const ActionBar = require(path.join(
|
|
__dirname, "..", "..", "JoshHeaps.Net", "wwwroot", "js", "casino", "holdem", "actionBar.js"));
|
|
|
|
test("seconds under a minute", () => {
|
|
assert.equal(ActionBar.formatTank(0), "0:00");
|
|
assert.equal(ActionBar.formatTank(7), "0:07");
|
|
assert.equal(ActionBar.formatTank(59), "0:59");
|
|
});
|
|
|
|
test("minutes and seconds", () => {
|
|
assert.equal(ActionBar.formatTank(60), "1:00");
|
|
assert.equal(ActionBar.formatTank(241), "4:01");
|
|
assert.equal(ActionBar.formatTank(3599), "59:59");
|
|
});
|
|
|
|
test("past the hour it says the hour", () => {
|
|
// A table left open on a hand reaches this, and "65:03" is a number the eye reads
|
|
// as minutes and seconds when it isn't.
|
|
assert.equal(ActionBar.formatTank(3600), "1:00:00");
|
|
assert.equal(ActionBar.formatTank(3903), "1:05:03");
|
|
assert.equal(ActionBar.formatTank(45296), "12:34:56");
|
|
});
|
|
|
|
test("the minutes are padded once there are hours, and not before", () => {
|
|
// "1:5:03" would be wrong; "05:03" on its own would be odd.
|
|
assert.equal(ActionBar.formatTank(3903), "1:05:03");
|
|
assert.equal(ActionBar.formatTank(303), "5:03");
|
|
});
|
|
|
|
test("a day is still a readable number rather than a wrapped one", () => {
|
|
assert.equal(ActionBar.formatTank(90000), "25:00:00");
|
|
});
|