Seasons based on a calendar

This commit is contained in:
2026-10-09 22:09:21 -03:00
parent 4d5700f0bf
commit 7fe9c15b67
12 changed files with 88 additions and 33 deletions
+4 -3
View File
@@ -8,9 +8,10 @@ Deno.test("a day is 30 minutes and a night 10, tick 0 is 06:00 of day 1", () =>
assertEquals(format_clock(0), "Day 1, 06:00");
assertEquals(format_clock(DAY_TICKS / 2), "Day 1, 12:00");
assertEquals(format_clock(DAY_TICKS), "Day 1, 18:00");
// midnight is halfway through the night, and the day number goes up there
// midnight is halfway through the night, the day number goes up at 06:00 like the farming day
assertEquals(format_clock(DAY_TICKS + NIGHT_TICKS / 2 - 1), "Day 1, 23:59");
assertEquals(format_clock(DAY_TICKS + NIGHT_TICKS / 2), "Day 2, 00:00");
assertEquals(format_clock(DAY_TICKS + NIGHT_TICKS / 2), "Day 1, 00:00");
assertEquals(format_clock(CYCLE_TICKS - 1), "Day 1, 05:59");
assertEquals(format_clock(CYCLE_TICKS), "Day 2, 06:00");
assertEquals(clock(3 * CYCLE_TICKS + DAY_TICKS / 4), { day: 4, hour: 9, minute: 0 });
assert(is_day(DAY_TICKS - 1) && !is_day(DAY_TICKS) && is_day(CYCLE_TICKS));
@@ -40,7 +41,7 @@ Deno.test("the server keeps the time, tells players, saves it, and /time changes
send(1, { type: "chat", text: "/time set midnight" });
let messages = take(1);
assertEquals(messages.find((m) => m.type === "time").time, DAY_TICKS + NIGHT_TICKS / 2);
assert(messages.some((m) => m.text === "alice set the time to Day 2, 00:00"));
assert(messages.some((m) => m.text === "alice set the time to Day 1, 00:00"));
// named times are the next one, so time never goes backwards
send(1, { type: "chat", text: "/time set day" });