diff --git a/src/arcaea_offline/calculate/score.py b/src/arcaea_offline/calculate/score.py index fd889bb..03e9afc 100644 --- a/src/arcaea_offline/calculate/score.py +++ b/src/arcaea_offline/calculate/score.py @@ -1,5 +1,7 @@ +from dataclasses import dataclass from decimal import Decimal from math import floor +from typing import Tuple, Union def calculate_score_range(notes: int, pure: int, far: int): @@ -11,17 +13,51 @@ def calculate_score_range(notes: int, pure: int, far: int): return (actual_score, actual_score + pure) +def calculate_score_modifier(score: int) -> Decimal: + if score >= 10000000: + return Decimal(2) + elif score >= 9800000: + return Decimal(1) + (Decimal(score - 9800000) / 200000) + else: + return Decimal(score - 9500000) / 300000 + + def calculate_potential(_constant: float, score: int) -> Decimal: constant = Decimal(_constant) - if score >= 10000000: - return constant + 2 - elif score >= 9800000: - return constant + 1 + (Decimal(score - 9800000) / 200000) - else: - return max(Decimal(0), constant + (Decimal(score - 9500000) / 300000)) + score_modifier = calculate_score_modifier(score) + return max(Decimal(0), constant + score_modifier) def calculate_shiny_pure(notes: int, score: int, pure: int, far: int) -> int: single_note_score = 10000000 / Decimal(notes) actual_score = single_note_score * pure + single_note_score * Decimal(0.5) * far return score - floor(actual_score) + + +@dataclass +class ConstantsFromPotentialResult: + EXPlus: Tuple[Decimal, Decimal] + EX: Tuple[Decimal, Decimal] + AA: Tuple[Decimal, Decimal] + A: Tuple[Decimal, Decimal] + B: Tuple[Decimal, Decimal] + C: Tuple[Decimal, Decimal] + + +def calculate_constants_from_potential(potential: Union[Decimal, str, float, int]): + potential = Decimal(potential) + + ranges = [] + for upperScore, lowerScore in [ + (10000000, 9900000), + (9899999, 9800000), + (9799999, 9500000), + (9499999, 9200000), + (9199999, 8900000), + (8899999, 8600000), + ]: + upperScoreModifier = calculate_score_modifier(upperScore) + lowerScoreModifier = calculate_score_modifier(lowerScore) + ranges.append((potential - upperScoreModifier, potential - lowerScoreModifier)) + + return ConstantsFromPotentialResult(*ranges)