[ui] Sunrise: The garden names the real sunrise from sunset until it comes

This commit is contained in:
2026-11-17 18:52:56 +01:00
parent e0a3b66dc8
commit 0c4f5bb556
9 changed files with 137 additions and 16 deletions
+11
View File
@@ -159,6 +159,17 @@ export function nextInvitation(now: number, place: Place): { readonly sun: SunDa
throw new Error(`nextInvitation: no invitation within two days of ${today}`);
}
/**
* The next thing to look up for (sunrise.md R1): the sunrise of the next invitation's
* day while it is still ahead, otherwise the invitation itself. Built on
* `nextInvitation`, so Reykjavík's after-midnight sunset stays tonight's (D2).
*/
export function nextSunEvent(now: number, place: Place): { readonly sun: SunDay; readonly at: number; readonly kind: 'sunrise' | 'invitation' } {
const next = nextInvitation(now, place);
if (next.sun.kind === 'sun-sets' && next.sun.sunrise >= now) return { sun: next.sun, at: next.sun.sunrise, kind: 'sunrise' };
return { ...next, kind: 'invitation' };
}
/**
* When the game invites the player outside: the sunset; in polar day the lowest
* light; in polar night noon, when the twilight is brightest (D4; decided by the