#TODO Move variable defaults to appropriate files, leave common ones here (and rename this file to _Variables_.rpy or something) init offset = -1 default current_payout = 0 # Used to pause events/summons for a number of days default ss_event_pause = 0 default ss_summon_pause = 0 default nt_event_pause = 0 default nt_summon_pause = 0 default hg_event_pause = 0 default hg_summon_pause = 0 default cc_event_pause = 0 default cc_summon_pause = 0 default ll_event_pause = 0 default ll_summon_pause = 0 default ag_event_pause = 0 default ag_summon_pause = 0 default sb_event_pause = 0 default sb_summon_pause = 0 # Sprite positioning default nxpos = 0 default nypos = 0 init python: class Environment(object): """Encapsulation for special variables and flags.""" def __init__(self): # Pseudo-constants self._seed = renpy.random.randint(0, 999999) # Protected self._gold = 0 self._tokens = 0 self._day = 0 self._points = { "gryffindor": 122, "slytherin": 35, "hufflepuff": 25, "ravenclaw": 31 } self._weather = "clear" # Normal values self.daytime = True self.difficulty = 2 self.cheats = False self.moon = True # Currencies @property def gold(self): return self._gold @gold.setter def gold(self, value): old = self._gold self._gold = max(0, min(value, 99999)) if not renpy.in_rollback() and not _in_replay: renpy.hide_screen("currency") renpy.show_screen("currency", old, self._gold, "💰") @property def tokens(self): return self._tokens @tokens.setter def tokens(self, value): old = self._tokens self._tokens = max(0, min(value, 99999)) if not renpy.in_rollback() and not _in_replay: renpy.hide_screen("currency") renpy.show_screen("currency", old, self._tokens, "🪙") # Time @property def day(self): return self._day @day.setter def day(self, value): self._day = max(0, value) # Weather @property def weather(self): return self._weather @weather.setter def weather(self, value): self._weather = Weather.set_weather(value) # House Points def set_points(self, d): difference = {} for house, value in d.items(): old_value = self._points[house] if (adjusted := value - old_value) < 0: prefix = "-" direction = "down" else: prefix = "+" direction = "up" value = min(max(1, value), 99999) self._points[house] = value difference[house] = adjusted if not renpy.in_rollback() and not _in_replay: renpy.hide_screen("house_points") renpy.show_screen("house_points", prefix=prefix, direction=direction, **difference) @property def gryffindor(self): return self._points["gryffindor"] @gryffindor.setter def gryffindor(self, value): self.set_points({"gryffindor": value}) @property def slytherin(self): return self._points["slytherin"] @slytherin.setter def slytherin(self, value): self.set_points({"slytherin": value}) @property def ravenclaw(self): return self._points["ravenclaw"] @ravenclaw.setter def ravenclaw(self, value): self.set_points({"ravenclaw": value}) @property def hufflepuff(self): return self._points["hufflepuff"] @hufflepuff.setter def hufflepuff(self, value): self.set_points({"hufflepuff": value}) # Randomisation @property def seed(self): return self._seed # @functools.cache # <-- Causes side effects def _random(self, day): seed = self.seed + day return renpy.random.Random(seed=seed) @property def random(self): return self._random(self.day) default states.env = Environment()