mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-09 17:40:17 +00:00
chore(calc): split calculate
module
This commit is contained in:
parent
c909886902
commit
c6014bd1b6
2
src/arcaea_offline/calculate/__init__.py
Normal file
2
src/arcaea_offline/calculate/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .b30 import calculate_b30, get_b30_calculated_list
|
||||
from .score import calculate_potential, calculate_score_range, calculate_shiny_pure
|
24
src/arcaea_offline/calculate/b30.py
Normal file
24
src/arcaea_offline/calculate/b30.py
Normal file
@ -0,0 +1,24 @@
|
||||
from decimal import Decimal
|
||||
from typing import Dict, List
|
||||
|
||||
from ..models.scores import ScoreCalculated
|
||||
|
||||
|
||||
def get_b30_calculated_list(
|
||||
calculated_list: List[ScoreCalculated],
|
||||
) -> List[ScoreCalculated]:
|
||||
best_scores: Dict[str, ScoreCalculated] = {}
|
||||
for calculated in calculated_list:
|
||||
key = f"{calculated.song_id}_{calculated.rating_class}"
|
||||
stored = best_scores.get(key)
|
||||
if stored and stored.score < calculated.score or not stored:
|
||||
best_scores[key] = calculated
|
||||
ret_list = list(best_scores.values())
|
||||
ret_list = sorted(ret_list, key=lambda c: c.potential, reverse=True)[:30]
|
||||
return ret_list
|
||||
|
||||
|
||||
def calculate_b30(calculated_list: List[ScoreCalculated]) -> Decimal:
|
||||
ptt_list = [Decimal(c.potential) for c in get_b30_calculated_list(calculated_list)]
|
||||
sum_ptt_list = sum(ptt_list)
|
||||
return (sum_ptt_list / len(ptt_list)) if sum_ptt_list else Decimal("0.0")
|
@ -1,8 +1,5 @@
|
||||
from decimal import Decimal
|
||||
from math import floor
|
||||
from typing import Dict, List
|
||||
|
||||
from .models.scores import ScoreCalculated
|
||||
|
||||
|
||||
def calculate_score_range(notes: int, pure: int, far: int):
|
||||
@ -28,23 +25,3 @@ 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)
|
||||
|
||||
|
||||
def get_b30_calculated_list(
|
||||
calculated_list: List[ScoreCalculated],
|
||||
) -> List[ScoreCalculated]:
|
||||
best_scores: Dict[str, ScoreCalculated] = {}
|
||||
for calculated in calculated_list:
|
||||
key = f"{calculated.song_id}_{calculated.rating_class}"
|
||||
stored = best_scores.get(key)
|
||||
if stored and stored.score < calculated.score or not stored:
|
||||
best_scores[key] = calculated
|
||||
ret_list = list(best_scores.values())
|
||||
ret_list = sorted(ret_list, key=lambda c: c.potential, reverse=True)[:30]
|
||||
return ret_list
|
||||
|
||||
|
||||
def calculate_b30(calculated_list: List[ScoreCalculated]) -> Decimal:
|
||||
ptt_list = [Decimal(c.potential) for c in get_b30_calculated_list(calculated_list)]
|
||||
sum_ptt_list = sum(ptt_list)
|
||||
return (sum_ptt_list / len(ptt_list)) if sum_ptt_list else Decimal("0.0")
|
Loading…
x
Reference in New Issue
Block a user