This commit is contained in:
33333-33333 2026-07-05 18:01:36 +09:00
commit 8f9f5b5100
108 changed files with 2139 additions and 1500 deletions

View file

@ -1,10 +1,18 @@
"use strict";
(function (global) {
const DomainIds = global.TarinaiDomainIds;
if (!DomainIds) throw new Error("TarinaiDomainIds must be loaded before weather_system.js");
const WEATHER_IDS = DomainIds.WEATHER_IDS;
function canonicalWeather(value = "sunny") {
return DomainIds.canonicalWeatherId(value);
}
function chooseNext(current = "sunny") {
const choices = current === "light_rain"
? ["sunny", "cloudy"]
: ["sunny", "cloudy", "light_rain"];
const id = canonicalWeather(current);
const choices = id === "light_rain"
? WEATHER_IDS.filter(weather => weather !== "light_rain")
: WEATHER_IDS;
return pick(choices);
}
@ -20,12 +28,11 @@
function enforceFixedWeather(worldRef) {
const fixed = fixedWeatherFor(worldRef);
if (!fixed || !worldRef) return false;
const previous = worldRef.weather || "sunny";
worldRef.weather = fixed;
const previous = canonicalWeather(worldRef.weather || "sunny");
worldRef.weather = canonicalWeather(fixed);
worldRef.nextWeatherChange = resetTimer();
if (previous !== fixed) {
worldRef.emit?.("weather:changed", { previous, next: fixed });
worldRef.log?.(`\u5929\u6C17: ${weatherLabel(fixed)}`);
if (previous !== worldRef.weather) {
worldRef.log?.(`\u5929\u6C17: ${weatherLabel(worldRef.weather)}`);
}
return true;
}
@ -33,7 +40,7 @@
function shouldDropRainWater(worldRef, dt = 0) {
return Boolean(
worldRef?.weather === "light_rain" &&
Math.random() < Math.max(0, Number(dt) || 0) * 0.12
Math.random() < Math.max(0, Number(dt) || 0) * 0.24
);
}
@ -66,12 +73,11 @@
function applyNextWeather(worldRef) {
if (!worldRef) return null;
if (enforceFixedWeather(worldRef)) return worldRef.weather || "sunny";
const previous = worldRef.weather || "sunny";
const previous = canonicalWeather(worldRef.weather || "sunny");
const next = chooseNext(previous);
worldRef.weather = next;
worldRef.weather = canonicalWeather(next);
worldRef.nextWeatherChange = resetTimer();
if (next !== previous) {
worldRef.emit?.("weather:changed", { previous, next });
worldRef.log?.(`\u5929\u6C17: ${weatherLabel(next)}`);
}
return next;