diff --git a/game/scripts/interface/house_points.rpy b/game/scripts/interface/house_points.rpy index 66b26ae2..d0524020 100644 --- a/game/scripts/interface/house_points.rpy +++ b/game/scripts/interface/house_points.rpy @@ -32,27 +32,40 @@ label points_changes: # Gets called every day/night. store.slytherin += points_s hide screen points_changes - show screen points_changes(points_s, points_g, points_r, points_h) + show screen points_changes(points_g, points_s, points_r, points_h) return -screen points_changes(points_s, points_g, points_r, points_h): +screen points_changes(gryffindor=None, slytherin=None, ravenclaw=None, hufflepuff=None, prefix="+", direction="up"): tag points_changes zorder 35 hbox: spacing 15 align (0.5, 0.1) - at transform: - on start: - alpha 0.0 - on show: - yoffset 0 - alpha 1.0 - easein 3.0 yoffset -50 alpha 0.0 + if direction == "up": + at transform: + on start: + alpha 0.0 + on show: + alpha 1.0 + yoffset 0 + easein 4.0 yoffset -50 alpha 0.0 + else: + at transform: + on start: + alpha 0.0 + on show: + alpha 1.0 + yoffset -50 + easein 4.0 yoffset 0 alpha 0.0 - text "+[points_s]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#3A734B" - text "+[points_g]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#A74D2A" - text "+[points_r]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#5974C2" - text "+[points_h]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#FBC60A" + if gryffindor: + text "[prefix][gryffindor]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#A74D2A" + if slytherin: + text "+[prefix][slytherin]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#3A734B" + if ravenclaw: + text "[prefix][ravenclaw]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#5974C2" + if hufflepuff: + text "[prefix][hufflepuff]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#FBC60A" - timer 3.0 action Hide("points_changes") + timer 4.0 action Hide("points_changes") diff --git a/game/scripts/variables.rpy b/game/scripts/variables.rpy index 8533f14e..f3c8d9a9 100644 --- a/game/scripts/variables.rpy +++ b/game/scripts/variables.rpy @@ -3,12 +3,6 @@ init offset = -1 default current_payout = 0 -# House points -default slytherin = 35 -default gryffindor = 122 -default hufflepuff = 25 -default ravenclaw = 31 - # Used to pause events/summons for a number of days default ss_event_pause = 0 default ss_summon_pause = 0 @@ -30,8 +24,6 @@ default nxpos = 0 default nypos = 0 init python: - import functools - class Environment(object): """Encapsulation for special variables and flags.""" @@ -43,10 +35,12 @@ init python: self._gold = 0 self._tokens = 0 self._day = 0 - self._gryf = 0 - self._slyt = 0 - self._rave = 0 - self._huff = 0 + self._points = { + "gryffindor": 122, + "slytherin": 35, + "hufflepuff": 25, + "ravenclaw": 31 + } self._weather = "clear" # Normal values @@ -55,6 +49,7 @@ init python: self.cheats = False self.moon = True + # Currencies @property def gold(self): return self._gold @@ -81,6 +76,7 @@ init python: renpy.hide_screen("currency") renpy.show_screen("currency", old, self._tokens, "🪙") + # Time @property def day(self): return self._day @@ -89,6 +85,7 @@ init python: def day(self, value): self._day = max(0, value) + # Weather @property def weather(self): return self._weather @@ -97,6 +94,55 @@ init python: def weather(self, value): self._weather = Weather.set_weather(value) + # House Points + def set_points(self, house, value): + old_value = self._points[house] + if value < old_value: + prefix = "-" + direction = "down" + else: + prefix = "+" + direction = "up" + + self._points[house] = min(max(1, value), 99999) + + if not renpy.in_rollback() and not _in_replay: + renpy.hide_screen("points_changes") + renpy.show_screen("points_changes", prefix=prefix, direction=direction, **{house: (value-old_value)}) + + @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