chore(calc)!: potential -> play_rating

This commit is contained in:
283375 2023-09-18 14:05:28 +08:00
parent f72410d0bc
commit bed9e14368
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
3 changed files with 20 additions and 16 deletions

View File

@ -1,2 +1,2 @@
from .b30 import calculate_b30, get_b30_calculated_list from .b30 import calculate_b30, get_b30_calculated_list
from .score import calculate_potential, calculate_score_range, calculate_shiny_pure from .score import calculate_play_rating, calculate_score_range, calculate_shiny_pure

View File

@ -22,8 +22,10 @@ def calculate_score_modifier(score: int) -> Decimal:
return Decimal(score - 9500000) / 300000 return Decimal(score - 9500000) / 300000
def calculate_potential(_constant: float, score: int) -> Decimal: def calculate_play_rating(
constant = Decimal(_constant) constant: Union[Decimal, str, float, int], score: int
) -> Decimal:
constant = Decimal(constant)
score_modifier = calculate_score_modifier(score) score_modifier = calculate_score_modifier(score)
return max(Decimal(0), constant + score_modifier) return max(Decimal(0), constant + score_modifier)
@ -35,7 +37,7 @@ def calculate_shiny_pure(notes: int, score: int, pure: int, far: int) -> int:
@dataclass @dataclass
class ConstantsFromPotentialResult: class ConstantsFromPlayRatingResult:
EXPlus: Tuple[Decimal, Decimal] EXPlus: Tuple[Decimal, Decimal]
EX: Tuple[Decimal, Decimal] EX: Tuple[Decimal, Decimal]
AA: Tuple[Decimal, Decimal] AA: Tuple[Decimal, Decimal]
@ -44,8 +46,8 @@ class ConstantsFromPotentialResult:
C: Tuple[Decimal, Decimal] C: Tuple[Decimal, Decimal]
def calculate_constants_from_potential(potential: Union[Decimal, str, float, int]): def calculate_constants_from_play_rating(play_rating: Union[Decimal, str, float, int]):
potential = Decimal(potential) play_rating = Decimal(play_rating)
ranges = [] ranges = []
for upperScore, lowerScore in [ for upperScore, lowerScore in [
@ -58,6 +60,8 @@ def calculate_constants_from_potential(potential: Union[Decimal, str, float, int
]: ]:
upperScoreModifier = calculate_score_modifier(upperScore) upperScoreModifier = calculate_score_modifier(upperScore)
lowerScoreModifier = calculate_score_modifier(lowerScore) lowerScoreModifier = calculate_score_modifier(lowerScore)
ranges.append((potential - upperScoreModifier, potential - lowerScoreModifier)) ranges.append(
(play_rating - upperScoreModifier, play_rating - lowerScoreModifier)
)
return ConstantsFromPotentialResult(*ranges) return ConstantsFromPlayRatingResult(*ranges)

View File

@ -6,15 +6,15 @@ class PlayResults:
def __init__( def __init__(
self, self,
*, *,
potential: Union[Decimal, str, float, int], play_rating: Union[Decimal, str, float, int],
partner_step: Union[Decimal, str, float, int], partner_step: Union[Decimal, str, float, int],
): ):
self.__potential = potential self.__play_rating = play_rating
self.__partner_step = partner_step self.__partner_step = partner_step
@property @property
def potential(self): def play_rating(self):
return Decimal(self.__potential) return Decimal(self.__play_rating)
@property @property
def partner_step(self): def partner_step(self):
@ -119,7 +119,7 @@ def calculate_step_original(
partner_bonus: Optional[PartnerBonus] = None, partner_bonus: Optional[PartnerBonus] = None,
booster: Optional[StepBooster] = None, booster: Optional[StepBooster] = None,
): ):
ptt = play_results.potential ptt = play_results.play_rating
step = play_results.partner_step step = play_results.partner_step
if partner_bonus: if partner_bonus:
partner_bonus_step = partner_bonus.step_bonus partner_bonus_step = partner_bonus.step_bonus
@ -150,7 +150,7 @@ def calculate_step(
return round(play_result_original, 1) return round(play_result_original, 1)
def calculate_potential_from_step( def calculate_play_rating_from_step(
step: Union[Decimal, str, int, float], step: Union[Decimal, str, int, float],
partner_step_value: Union[Decimal, str, int, float], partner_step_value: Union[Decimal, str, int, float],
*, *,
@ -169,7 +169,7 @@ def calculate_potential_from_step(
if partner_bonus and partner_bonus.step_bonus: if partner_bonus and partner_bonus.step_bonus:
step -= partner_bonus.step_bonus step -= partner_bonus.step_bonus
potential_sqrt = (Decimal(50) * step - Decimal("2.5") * partner_step_value) / ( play_rating_sqrt = (Decimal(50) * step - Decimal("2.5") * partner_step_value) / (
Decimal("2.45") * partner_step_value Decimal("2.45") * partner_step_value
) )
return potential_sqrt**2 return play_rating_sqrt**2