-
-
Save ladyisak/3954ad984b2f505f7db884a9ec307ce8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stats.rpy | |
# Keeps track of and displays the stats for the DSE. | |
# | |
# To change styles, look for the dse_stats_* blocks in styles.rpy | |
init -99 python: | |
__dse_stats = [ ] | |
class __Stat(object): | |
def __init__(self, name, var, default, max, type=None, hidden=False): | |
self.name = name | |
self.var = var | |
self.default = default | |
self.max = max | |
self.hidden = hidden | |
self.type = type | |
def ding(stat): | |
x = getattr(store, stat) | |
x = float(x) - (float(x) * (10.00/100)) | |
setattr(store, stat, x) | |
def ditch(stat): | |
x = getattr(store, stat) | |
x = float(x) - (float(x) * (15.00/100)) | |
setattr(store, stat, x) | |
def demolish(stat): | |
x = getattr(store, stat) | |
x = float(x) - (float(x) * (20.00/100)) | |
setattr(store, stat, x) | |
def tad(stat): | |
x = getattr(store, stat) | |
x = float(x) + ((100.00-float(x))*((10.00/100))) | |
setattr(store, stat, x) | |
def bump(stat): | |
x = getattr(store, stat) | |
x = float(x) + ((100.00-float(x))*((15.00/100))) | |
setattr(store, stat, x) | |
def demolish(stat): | |
x = getattr(store, stat) | |
x = float(x) + ((100.00-float(x))*((20.00/100))) | |
setattr(store, stat, x) | |
def __init_stats(): | |
for s in __dse_stats: | |
setattr(store, s.var, s.default) | |
config.start_callbacks.append(__init_stats) | |
# Call this function to add a stat to keep track of. | |
# Arguments: | |
# Name: name of stat. Will be displayed in the Stats screen | |
# var: name of variable to use to keep track of stat. | |
# default: starting value for the stat | |
# max: maximum value for the stat | |
# hidden: Is this stat hidden from the user? Hidden stats will not be displayed in the stats screen. | |
def register_stat(name, var, default=0, max=100, type=None, hidden=False): | |
__dse_stats.append(__Stat(name, var, default, max, type, hidden)) | |
def normalize_stats(): | |
for s in __dse_stats: | |
v = getattr(store, s.var) | |
if v > s.max: | |
v = s.max | |
if v < 0: | |
v = 0 | |
setattr(store, s.var, v) | |
# Whenever a python statement is executed, we will ensure our stats | |
# stay within range. | |
config.python_callbacks.append(normalize_stats) | |
# Display the stats in a frame. | |
# name - display the stat's name | |
# bar - display a bar indicating the value of the stat | |
# value - display the numerical value of the stat | |
# max - display the maximum value of the stat | |
screen display_stats(name=True, bar=True, value=True, max=True): | |
$ dse_stat_length = len(__dse_stats) | |
#The number of rows is the number of stats that are not hidden | |
for s in __dse_stats: | |
if s.hidden: | |
$ dse_stat_length -= 1 | |
style_prefix "stats" | |
frame at If(anim, menu_load(x=-200), None): | |
vbox: | |
grid 2 2: | |
xspacing 21 | |
yspacing 6 | |
$ status_index = -1 | |
for s in filter(lambda x: x.type=="status", __dse_stats): | |
#Skip if the stat is a hidden stat | |
if (not s.hidden): | |
$ v = getattr(store, s.var) | |
$ status_index += 1 | |
vbox: | |
xminimum 180 xmaximum 180 | |
spacing -9 | |
if name: | |
label s.name.lower() | |
if bar: | |
bar: | |
value v range s.max | |
xfill True | |
ysize gui.small_bar_size | |
left_bar Frame("gui/bar/stats_left.png", gui.small_bar_borders, tile=gui.bar_tile) | |
right_bar Frame("gui/bar/stats_right.png", gui.small_bar_borders, tile=gui.bar_tile) | |
null height 72 | |
label _("Skills").upper() at If(anim, menu_load(y=-200), None) style_prefix "skills_heading" | |
vbox: | |
xfill True | |
spacing 12 | |
$ stat_index = 0 | |
for s in filter(lambda x: x.type=="skill", __dse_stats): | |
if (not s.hidden): | |
$ v = getattr(store, s.var) | |
$ stat_index += 1 | |
vbox: | |
xminimum 360 xmaximum 360 | |
spacing -9 xalign 0.5 | |
label s.name.lower() | |
bar: | |
value v range s.max | |
xfill True xalign 0.5 | |
ysize gui.small_bar_size | |
left_bar Frame("gui/bar/stats_left.png", gui.small_bar_borders, tile=gui.bar_tile) | |
right_bar Frame("gui/bar/stats_right.png", gui.small_bar_borders, tile=gui.bar_tile) | |
label _("Stats").upper() at If(anim, menu_load(y=-200), None) style_prefix "stats_heading" | |
style stats_frame: | |
xminimum 444 xmaximum 444 | |
yminimum 1011 ymaximum 1011 | |
ypos 27 xpos 15 | |
padding gui.stats_frame_borders.padding | |
background Frame("gui/frame/stats.png", gui.stats_frame_borders, tile=gui.frame_tile) | |
style skills_heading_label: | |
xalign 0.5 xoffset 6 | |
style stats_heading_label: | |
xanchor 0.5 yanchor 0.5 | |
xpos 233 ypos 137 | |
xoffset 6 | |
style skills_heading_label_text is planner_heading_label_text | |
style stats_heading_label_text is planner_heading_label_text | |
style stats_label_text: | |
size 42 color color_blush | |
style stats_label is planner_label |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment