diff --git a/game/scripts/interface/calendar.rpy b/game/scripts/interface/calendar.rpy index 6a1e3f08..bd5a436a 100644 --- a/game/scripts/interface/calendar.rpy +++ b/game/scripts/interface/calendar.rpy @@ -1,9 +1,11 @@ init python: - class Calendar(object): - def __init__(self): - pass + class Calendar(): + periods = ("Janemar", "Aprimju", "Juliasep", "Octobrinde") + weekdays = ("Monday", "Tuesday", "Wednsday", "Thursday", "Friday", "Saturday", "Sunday") + _day = 0 - def get_schedule(self, span=35): + @staticmethod + def get_schedule(span=35): contents = {i: "" for i in range(span)} # Add moon cycles @@ -14,31 +16,60 @@ init python: contents[i] += "🌓" # elif (game.day % 60 == 30) # Blood moon + forecast = Weather.forecast(span) + for i, v in forecast.items(): + if v == "clear": + contents[i] += "☀ī¸" + elif v == "cloudy": + contents[i] += "⛅" + elif v == "overcast": + contents[i] += "☁ī¸" + elif v in ("blizzard", "snow"): + contents[i] += "🌨ī¸" + elif v == "rain": + contents[i] += "🌧ī¸" + elif v == "storm": + contents[i] += "🌩ī¸" + # Add letters letters = mailbox.get_letters(True) for i in letters: - contents[game.day+i.wait] += "✉ī¸" + if (day := game.day+i.wait) < span+1: + contents[day] += "✉ī¸" # Add parcels parcels = mailbox.get_parcels(True) for i in parcels: - contents[game.day+i.wait] += "đŸ“Ļ" + if (day := game.day+i.wait) < span+1: + contents[day] += "đŸ“Ļ" + return contents - def get_weekday(self, n): - weekdays = ("Monday", "Tuesday", "Wednsday", "Thursday", "Friday", "Saturday", "Sunday") + @staticmethod + def get_weekday(n=None): + if n is None: + n = game.day - return weekdays[n % 7] + return Calendar.weekdays[n % 7] -default calendar = Calendar() + @staticmethod + def get_period(n=None): + + if n is None: + n = game.day + + return Calendar.periods[(n // 30) % 4] label calendar: call screen calendar jump main_room_menu screen calendar: - default contents = calendar.get_schedule().items() + default contents = Calendar.get_schedule().items() + default period = Calendar.get_period() + + text "[period]" align (0.5, 0.1) color "#fff" size 24 grid 7 6: style "empty" align (0.5, 0.5) diff --git a/game/scripts/interface/weather.rpy b/game/scripts/interface/weather.rpy new file mode 100644 index 00000000..dec95ca2 --- /dev/null +++ b/game/scripts/interface/weather.rpy @@ -0,0 +1,65 @@ +init python: + class Weather(): + weather_types = ("clear", "cloudy", "overcast", "blizzard", "snow", "storm", "rain") + weather_weights = { + "Janemar": (8, 9, 10, 3, 4, 7, 7), + "Aprimju": (9, 10, 9, 2, 3, 8, 8), + "Juliasep": (10, 10, 8, 1, 2, 6, 9), + "Octobrinde": (6, 7, 9, 9, 10, 6, 6), + } + _weather = None + + @staticmethod + def _interpolate_weights(day, period): + current_weights = Weather.weather_weights[period] + current_index = Calendar.periods.index(period) + + next_index = (current_index + 1) % len(Calendar.periods) + next_weights = Weather.weather_weights[Calendar.periods[next_index]] + + interpolation_factor = (day / 30) * 0.25 + + # Interpolate between current season and next season + adjusted_weights = tuple( + max(0.01, (1 - interpolation_factor) * current_weight + interpolation_factor * next_weights[i]) + for i, current_weight in enumerate(current_weights) + ) + + return adjusted_weights + + @staticmethod + def get_weather(): + return Weather._weather + + @staticmethod + def set_weather(value=None): + if value is None or value == "random": + period = Calendar.get_period() + weights = Weather._interpolate_weights(game.day, period) + rand = renpy.random.Random(seed=game.day) + value = rand.choices(Weather.weather_types, weights=weights)[0] + + elif value not in Weather.weather_types: + raise ValueError(f"Unsupported weather type: {value!r}") + + Weather._weather = value + return value + + weather = property(get_weather, set_weather) + + @staticmethod + def forecast(span=35): + forecast = {} + start_day = game.day - (game.day % 30) + period = Calendar.get_period() + + for i in range(span): + day = start_day + i + weights = Weather._interpolate_weights(day, period) + rand = renpy.random.Random(seed=day) + value = rand.choices(Weather.weather_types, weights=weights)[0] + + forecast[i] = value + + return forecast + diff --git a/game/scripts/inventory/game.rpy b/game/scripts/inventory/game.rpy index d7a512b8..906a9301 100644 --- a/game/scripts/inventory/game.rpy +++ b/game/scripts/inventory/game.rpy @@ -54,17 +54,11 @@ init -100 python: @property def weather(self): - return self._weather + return Weather.get_weather() @weather.setter def weather(self, value): - if value == "random": - value = renpy.random.choices(self.weather_types, weights=self.weather_weights)[0] - - if not value in self.weather_types: - raise ValueError(f"Unsupported weather type: {value!r}") - - self._weather = value + Weather.set_weather(value) self.moon = (self.day % 7 == 0) screen gold(old, new):