Placeholder
league_pb_rank - the position of your league PB on the league category leaderboardnumber_of_runners_in_category - the number of runners that have submitted to the category so farnumber_of_league_participants - the total number of participants in the leagueleague_pb_in_milliseconds - the total time of your league PB, in millisecondsleague_pb_in_seconds_floor - the total time of your league PB, in seconds, rounded downleague_pb_in_seconds_ceiling - the total time of your league PB, in seconds, rounded upinitial_pb_in_milliseconds - the total time of your initial PB, in millisecondsinitial_pb_in_seconds_floor - the total time of your initial PB, in seconds, rounded downinitial_pb_in_seconds_ceiling - the total time of your initial PB, in seconds, rounded uphas_initial_pb - whether you have an initial PB or not (0 or 1)a * b - a multiplied by ba ** b - a to the power of ba // b - how many full lots of a fit into b (also known as "integer divide")a % b - a modulo bmin(a, b, ...) - the lowest of a, b, ...max(a, b, ...) - the highest of a, b, ...abs(a) - the absolute value of acheck_league_pb_var('a', 'b') - 0 or 1, indicating whether the league PB has a variable a with value bcheck_initial_pb_var('a', 'b') - 0 or 1, indicating whether the initial PB has a variable a with value bis_league_pb_n64 = check_league_pb_var('Platform', 'N64')
is_league_pb_emu = check_league_pb_var('Platform', 'EMU')
is_league_pb_n64_or_emu = is_league_pb_n64 + is_league_pb_emu
is_league_pb_vc = abs(is_league_pb_n64_or_emu - 1)
# adjust time: +8s for EMU, +20s for VC
league_pb_in_milliseconds_adjusted = league_pb_in_milliseconds + is_league_pb_emu * 8000
league_pb_in_milliseconds_adjusted = league_pb_in_milliseconds_adjusted + is_league_pb_vc * 20000
league_pb = league_pb_in_milliseconds_adjusted // 1000
is_initial_pb_n64 = check_initial_pb_var('Platform', 'N64')
is_initial_pb_emu = check_initial_pb_var('Platform', 'EMU')
is_initial_pb_n64_or_emu = is_initial_pb_n64 + is_initial_pb_emu
is_initial_pb_vc = abs(is_initial_pb_n64_or_emu - 1)
# adjust time: +8s for EMU, +20s for VC
initial_pb_in_milliseconds_adjusted = initial_pb_in_milliseconds + is_initial_pb_emu * 8000
initial_pb_in_milliseconds_adjusted = initial_pb_in_milliseconds_adjusted + is_initial_pb_vc * 20000
initial_pb = initial_pb_in_milliseconds_adjusted // 1000
has_pb_improved = min(1, max(0, initial_pb_in_milliseconds_adjusted - league_pb_in_milliseconds_adjusted))
# points per second of PB improvement
pps_1 = 4 * max(0, min(1200, initial_pb) - max(1110, league_pb))
pps_2 = 6 * max(0, min(1110, initial_pb) - max(1035, league_pb))
pps_3 = 8 * max(0, min(1035, initial_pb) - max(975, league_pb))
pps_4 = 12 * max(0, min(975, initial_pb) - max(935, league_pb))
pps_5 = 20 * max(0, min(935, initial_pb) - max(910, league_pb))
pps_6 = 36 * max(0, min(910, initial_pb) - max(895, league_pb))
pps_7 = 60 * max(0, min(895, initial_pb) - max(885, league_pb))
pps_8 = 128 * max(0, min(885, initial_pb) - max(879, league_pb))
pps_9 = 196 * max(0, min(879, initial_pb) - max(0, league_pb))
pps = pps_1 + pps_2 + pps_3 + pps_4 + pps_5 + pps_6 + pps_7 + pps_8 + pps_9
# standards points - bonuses for beating certain times
tier_1 = 30 * min(1, max(0, 35999 - league_pb))
tier_2 = 45 * min(1, max(0, 1650 - league_pb))
tier_3 = 75 * min(1, max(0, 1470 - league_pb))
tier_4 = 100 * min(1, max(0, 1290 - league_pb))
tier_5 = 150 * min(1, max(0, 1140 - league_pb))
tier_6 = 200 * min(1, max(0, 1080 - league_pb))
tier_7 = 250 * min(1, max(0, 1010 - league_pb))
tier_8 = 300 * min(1, max(0, 955 - league_pb))
tier_9 = 400 * min(1, max(0, 915 - league_pb))
tier_10 = 500 * min(1, max(0, 895 - league_pb))
tier_11 = 750 * min(1, max(0, 875 - league_pb))
standards = tier_1 + tier_2 + tier_3 + tier_4 + tier_5 + tier_6 + tier_7 + tier_8 + tier_9 + tier_10 + tier_11
# rank points
# you get a certain number of points for a last-placed run, plus extra for each rank you climb from there
# there are also bonuses for being in the top 3, 5, 10, and 25
baseline = 65
rank_score = 3 * max(0, number_of_runners_in_category + 1 - league_pb_rank)
top3_sum = 50 * min(1, max(0, 4 - league_pb_rank))
top5_sum = 40 * min(1, max(0, 6 - league_pb_rank))
top10_sum = 30 * min(1, max(0, 11 - league_pb_rank))
top25_sum = 20 * min(1, max(0, 26 - league_pb_rank))
rank = baseline + rank_score + top3_sum + top5_sum + top10_sum + top25_sum
score = pps + standards + rank
final_score = has_pb_improved * score # runs that are not a PB will score 0