2022-05-16 23:48:22 +00:00
|
|
|
#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
|
2024-04-25 18:49:09 +00:00
|
|
|
|
|
|
|
init python:
|
|
|
|
class Environment(object):
|
|
|
|
"""Encapsulation for special variables and flags."""
|
|
|
|
|
|
|
|
def __init__(self):
|
2024-04-26 23:41:38 +00:00
|
|
|
# Pseudo-constants
|
|
|
|
self._seed = renpy.random.randint(0, 999999)
|
|
|
|
|
|
|
|
# Protected
|
2024-04-25 18:49:09 +00:00
|
|
|
self._gold = 0
|
2024-04-25 19:39:50 +00:00
|
|
|
self._tokens = 0
|
2024-04-25 18:49:09 +00:00
|
|
|
self._day = 0
|
2024-04-27 00:54:41 +00:00
|
|
|
self._points = {
|
|
|
|
"gryffindor": 122,
|
|
|
|
"slytherin": 35,
|
|
|
|
"hufflepuff": 25,
|
|
|
|
"ravenclaw": 31
|
|
|
|
}
|
2024-04-25 18:49:09 +00:00
|
|
|
self._weather = "clear"
|
|
|
|
|
|
|
|
# Normal values
|
|
|
|
self.daytime = True
|
|
|
|
self.difficulty = 2
|
|
|
|
self.cheats = False
|
|
|
|
self.moon = True
|
2024-04-27 17:12:13 +00:00
|
|
|
self.houses = {
|
|
|
|
"gryffindor": {
|
|
|
|
"properties": {
|
|
|
|
"color": "#A74D2A",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"slytherin": {
|
|
|
|
"properties": {
|
|
|
|
"color": "#3A734B",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"ravenclaw": {
|
|
|
|
"properties": {
|
|
|
|
"color": "#5974C2",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"hufflepuff": {
|
|
|
|
"properties": {
|
|
|
|
"color": "#FBC60A",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-25 18:49:09 +00:00
|
|
|
|
2024-04-27 00:54:41 +00:00
|
|
|
# Currencies
|
2024-04-25 18:49:09 +00:00
|
|
|
@property
|
|
|
|
def gold(self):
|
|
|
|
return self._gold
|
|
|
|
|
|
|
|
@gold.setter
|
|
|
|
def gold(self, value):
|
2024-04-27 17:12:13 +00:00
|
|
|
old_value = self._gold
|
|
|
|
properties = {"pos": (70, 370)}
|
|
|
|
|
|
|
|
if (adjusted := value - old_value) < 0:
|
|
|
|
displayables = (Text(f"-{adjusted}{{color=#FF0000}}{{size=-12}}{{unicode}} ▼{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text"),)
|
|
|
|
properties["at"] = smooth_swipe(-50, 0)
|
|
|
|
else:
|
|
|
|
displayables = (Text(f"+{adjusted}{{color=#00FF00}}{{size=-12}}{{unicode}} ▲{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text"),)
|
|
|
|
properties["at"] = smooth_swipe(0, -50)
|
|
|
|
|
2024-04-25 18:49:09 +00:00
|
|
|
self._gold = max(0, min(value, 99999))
|
|
|
|
|
|
|
|
if not renpy.in_rollback() and not _in_replay:
|
2024-04-25 19:39:50 +00:00
|
|
|
renpy.hide_screen("currency")
|
2024-04-27 17:12:13 +00:00
|
|
|
renpy.show_screen("currency", old_value, value, "💰")
|
|
|
|
|
|
|
|
if states.room == "main_room":
|
|
|
|
renpy.hide_screen("currency_alt")
|
|
|
|
renpy.show_screen("currency_alt", displayables, properties)
|
2024-04-25 19:39:50 +00:00
|
|
|
|
|
|
|
@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, "🪙")
|
2024-04-25 18:49:09 +00:00
|
|
|
|
2024-04-27 00:54:41 +00:00
|
|
|
# Time
|
2024-04-25 18:49:09 +00:00
|
|
|
@property
|
|
|
|
def day(self):
|
|
|
|
return self._day
|
|
|
|
|
|
|
|
@day.setter
|
|
|
|
def day(self, value):
|
|
|
|
self._day = max(0, value)
|
|
|
|
|
2024-04-27 00:54:41 +00:00
|
|
|
# Weather
|
2024-04-25 18:49:09 +00:00
|
|
|
@property
|
|
|
|
def weather(self):
|
2024-04-25 19:39:50 +00:00
|
|
|
return self._weather
|
2024-04-25 18:49:09 +00:00
|
|
|
|
|
|
|
@weather.setter
|
|
|
|
def weather(self, value):
|
2024-04-25 19:39:50 +00:00
|
|
|
self._weather = Weather.set_weather(value)
|
2024-04-25 18:49:09 +00:00
|
|
|
|
2024-04-27 00:54:41 +00:00
|
|
|
# House Points
|
2024-04-27 14:24:14 +00:00
|
|
|
def set_points(self, d):
|
2024-04-27 17:12:13 +00:00
|
|
|
properties = {"spacing": 15, "align": (0.5, 0.1)}
|
|
|
|
displayables = []
|
2024-04-27 14:24:14 +00:00
|
|
|
difference = {}
|
|
|
|
for house, value in d.items():
|
|
|
|
old_value = self._points[house]
|
|
|
|
if (adjusted := value - old_value) < 0:
|
2024-04-27 17:12:13 +00:00
|
|
|
disp = At(Text(f"-{adjusted}{{color=#FF0000}}{{size=-12}}{{unicode}} ▼{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text", **self.houses[house]["properties"]), smooth_swipe(-50, 0))
|
2024-04-27 14:24:14 +00:00
|
|
|
else:
|
2024-04-27 17:12:13 +00:00
|
|
|
disp = At(Text(f"+{adjusted}{{color=#00FF00}}{{size=-12}}{{unicode}} ▲{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text", **self.houses[house]["properties"]), smooth_swipe(0, -50))
|
|
|
|
displayables.append(disp)
|
2024-04-27 14:24:14 +00:00
|
|
|
value = min(max(1, value), 99999)
|
|
|
|
self._points[house] = value
|
|
|
|
difference[house] = adjusted
|
2024-04-27 00:54:41 +00:00
|
|
|
|
|
|
|
if not renpy.in_rollback() and not _in_replay:
|
2024-04-27 17:12:13 +00:00
|
|
|
renpy.hide_screen("currency_alt")
|
|
|
|
renpy.show_screen("currency_alt", displayables, properties)
|
2024-04-27 00:54:41 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def gryffindor(self):
|
|
|
|
return self._points["gryffindor"]
|
|
|
|
|
|
|
|
@gryffindor.setter
|
|
|
|
def gryffindor(self, value):
|
2024-04-27 14:24:14 +00:00
|
|
|
self.set_points({"gryffindor": value})
|
2024-04-27 00:54:41 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def slytherin(self):
|
|
|
|
return self._points["slytherin"]
|
|
|
|
|
|
|
|
@slytherin.setter
|
|
|
|
def slytherin(self, value):
|
2024-04-27 14:24:14 +00:00
|
|
|
self.set_points({"slytherin": value})
|
2024-04-27 00:54:41 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def ravenclaw(self):
|
|
|
|
return self._points["ravenclaw"]
|
|
|
|
|
|
|
|
@ravenclaw.setter
|
|
|
|
def ravenclaw(self, value):
|
2024-04-27 14:24:14 +00:00
|
|
|
self.set_points({"ravenclaw": value})
|
2024-04-27 00:54:41 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def hufflepuff(self):
|
|
|
|
return self._points["hufflepuff"]
|
|
|
|
|
|
|
|
@hufflepuff.setter
|
|
|
|
def hufflepuff(self, value):
|
2024-04-27 14:24:14 +00:00
|
|
|
self.set_points({"hufflepuff": value})
|
2024-04-27 00:54:41 +00:00
|
|
|
|
|
|
|
# Randomisation
|
2024-04-26 23:41:38 +00:00
|
|
|
@property
|
|
|
|
def seed(self):
|
|
|
|
return self._seed
|
|
|
|
|
2024-04-27 00:05:53 +00:00
|
|
|
# @functools.cache # <-- Causes side effects
|
2024-04-26 23:41:38 +00:00
|
|
|
def _random(self, day):
|
|
|
|
seed = self.seed + day
|
2024-04-27 00:05:53 +00:00
|
|
|
return renpy.random.Random(seed=seed)
|
2024-04-26 23:41:38 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def random(self):
|
|
|
|
return self._random(self.day)
|
|
|
|
|
2024-04-25 18:49:09 +00:00
|
|
|
default states.env = Environment()
|