five-on-it / packages/shared/src/weather
packages/shared/src/weather
The room's weather (GAME_DESIGN §5.7): like the clock (clock.ts), a pure function of what the room was given once (a seed and a climate, RoomWeather) and the game minutes since its first midnight (gameMinutesAt), so the server, every client and the AI agree on it with a few numbers sent once, again only when a game or a mission scripts it.
- Fronts: the weather changes every WEATHER
.frontgame minutes. A front's kind (clear, overcast, rain, storm, fog, snow) and intensity are drawn from the seed and its number alone, never from the ones before it: a front mostly follows its regime (the kind of a longer stretch,regimeminutes), sometimes not, by the climate's odds (CLIMATE_ODDS: alpine snows, the desert hardly rains, the coast is foggy). Each front comes in overblendminutes. So the weather at any time is known at once, whatever the time, and a skip of hours ("3 hours later") lands in the weather of then. - Script: a game's rules or a mission (
setWeather) set a kind and an intensity from a time, coming in overrampminutes, held until a time or for good. - What it leaves: the roads' wetness, which comes with the rain in about ten minutes and dries in about forty, and the snow on the ground, settling in about half an hour and melting in about two, worked out over the last fronts.
The climate none (the test levels') is always clear. The daylight of a time of day (daylightAt: dawn and dusk an hour each) is here too: the AI's sight and the picture's light both read it.