[ui] PlanetGarden: Her round planet, the player's gardener, the ring of care, and care by gesture

This commit is contained in:
2026-11-17 19:07:57 +01:00
parent 9eef8a3bf7
commit 5576af4fac
18 changed files with 1268 additions and 79 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, nextSunEvent, sunDay, type NamedPlace, type Place, type SunDay } from './sun/sun.js';
export { invitation, lightAt, nextInvitation, nextSunEvent, sunDay, type Light, 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';
+21
View File
@@ -159,6 +159,27 @@ export function nextInvitation(now: number, place: Place): { readonly sun: SunDa
throw new Error(`nextInvitation: no invitation within two days of ${today}`);
}
/** The light over her planet now (planet-garden.md): the scene's sky follows the real sun. */
export type Light = 'day' | 'golden' | 'night';
/**
* Golden within 45 minutes before and 30 after the sunset or sunrise (in polar day, around the
* lowest light; in polar night, around the brightest twilight at noon); day between, night outside.
*/
export function lightAt(now: number, place: Place): Light {
const sun = sunDay(localDay(now, place.timeZone), place);
const near = (at: number, before: number, after: number): boolean => now >= at - before * MINUTE && now <= at + after * MINUTE;
switch (sun.kind) {
case 'polar-day':
return near(sun.lowestLight, 60, 60) ? 'golden' : 'day';
case 'polar-night':
return near(sun.solarNoon, 90, 90) ? 'golden' : 'night';
case 'sun-sets':
if (near(sun.sunset, 45, 30) || near(sun.sunrise, 30, 30)) return 'golden';
return now > sun.sunrise && now < sun.sunset ? 'day' : 'night';
}
}
/**
* 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