WTS/game/scripts/interface/house_points.rpy
2024-06-25 21:31:29 +01:00

93 lines
4.1 KiB
Plaintext

init python:
def house_points_daily():
progress_factor = max(1, int(math.log(states.env.day) * 5))
# Bonuses based on Tonks and Snape friendship stat
bonus_g = states.her.tier
bonus_r = states.cho.tier + states.lun.tier
bonus_h = int((states.ton.level / 100.0) * (progress_factor * 0.7))
bonus_s = int((states.sna.level / 100.0) * (progress_factor * 0.7))
house_points = {
"gryffindor": states.env.gryffindor,
"ravenclaw": states.env.ravenclaw,
"hufflepuff": states.env.hufflepuff,
"slytherin": states.env.slytherin
}
leader = max(house_points.values())
factors = {
"gryffindor": (bonus_g, max(house_points["hufflepuff"], house_points["ravenclaw"], house_points["slytherin"])),
"ravenclaw": (bonus_r, max(house_points["gryffindor"], house_points["hufflepuff"], house_points["slytherin"])),
"hufflepuff": (bonus_h, max(house_points["gryffindor"], house_points["ravenclaw"], house_points["slytherin"])),
"slytherin": (bonus_s, max(house_points["gryffindor"], house_points["hufflepuff"], house_points["ravenclaw"]))
}
points = {
house: min(leader, round((progress_factor + bonus) * max_points / house_points[house]))
for house, (bonus, max_points) in factors.items()
}
for house, point in points.items():
points[house] = renpy.random.randint(point // 2, point) + house_points[house]
states.env.set_points(points)
def house_points_anchors():
yanchors = [0, 0.15, 0.3, 0.45]
housepoints_sorted = sorted((states.env.slytherin, states.env.gryffindor, states.env.ravenclaw, states.env.hufflepuff), reverse=True)
g = housepoints_sorted.index(states.env.gryffindor)
r = housepoints_sorted.index(states.env.ravenclaw)
h = housepoints_sorted.index(states.env.hufflepuff)
s = housepoints_sorted.index(states.env.slytherin)
return [yanchors[g], yanchors[r], yanchors[h], yanchors[s]]
screen house_points():
layer "interface"
tag house_points
zorder 0
default start_yanchors = states.env.banners_yanchors # Updated externally through set_points function
default yanchors = house_points_anchors()
hbox:
spacing 10
xfill False
xalign 0.5
add "house_points_banner_small_gryffindor" at house_points_rollout(start_yanchors[0], yanchors[0])
add "house_points_banner_small_ravenclaw" at house_points_rollout(start_yanchors[1], yanchors[1])
add "house_points_banner_small_hufflepuff" at house_points_rollout(start_yanchors[2], yanchors[2])
add "house_points_banner_small_slytherin" at house_points_rollout(start_yanchors[3], yanchors[3])
at house_points_show_hide
timer 6.4 action Hide("house_points")
transform house_points_rollout(start_yanchor, yanchor):
subpixel True
yanchor start_yanchor
linear 1 yanchor yanchor
transform house_points_show_hide:
on show:
alpha 0.0
events False
easein 0.4 alpha 1.0
on hide:
alpha 1.0
events False
easein 0.4 alpha 0.0
image house_points_banner_small_gryffindor = Image("/gui/creamy_pumpkin_pie/banners/banners_gryffindor.png", oversample=12)
image house_points_banner_small_ravenclaw = Image("/gui/creamy_pumpkin_pie/banners/banners_ravenclaw.png", oversample=12)
image house_points_banner_small_hufflepuff = Image("/gui/creamy_pumpkin_pie/banners/banners_hufflepuff.png", oversample=12)
image house_points_banner_small_slytherin = Image("/gui/creamy_pumpkin_pie/banners/banners_slytherin.png", oversample=12)
image house_points_emblem_small_gryffindor = Image("/gui/creamy_pumpkin_pie/banners/banners_gryffindor_emblem.png", oversample=16)
image house_points_emblem_small_ravenclaw = Image("/gui/creamy_pumpkin_pie/banners/banners_ravenclaw_emblem.png", oversample=16)
image house_points_emblem_small_hufflepuff = Image("/gui/creamy_pumpkin_pie/banners/banners_hufflepuff_emblem.png", oversample=16)
image house_points_emblem_small_slytherin = Image("/gui/creamy_pumpkin_pie/banners/banners_slytherin_emblem.png", oversample=16)