[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
+1 -1
View File
@@ -3,7 +3,7 @@ export {
careEvent, careIdentity, judgeCare, newCare, OWN_TRACE, petalsOn, pour, ROSE, roseAt, seeded, stageFor, weedsOn, windOn,
type Judged, type Mood, type Needs, type RoseKeys, type RoseNow, type Stage, type Trend
} from './rose/rose.js';
export { invitation, nextInvitation, sunDay, type NamedPlace, type Place, type SunDay } from './sun/sun.js';
export { invitation, nextInvitation, nextSunEvent, sunDay, type NamedPlace, type Place, type SunDay } from './sun/sun.js';
export {
goodMoment, newOpened, openedIdentity, PETAL, petalAt, petalOrder, sentenceOpened, type PetalNow, type PetalSentence
} from './petal/petal.js';
+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