mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-20 14:40:16 +00:00
feat(utils): bring utils back
This commit is contained in:
parent
262495a580
commit
54851549d5
0
src/arcaea_offline/utils/__init__.py
Normal file
0
src/arcaea_offline/utils/__init__.py
Normal file
23
src/arcaea_offline/utils/rating.py
Normal file
23
src/arcaea_offline/utils/rating.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
RATING_CLASS_TEXT_MAP = {
|
||||||
|
0: "Past",
|
||||||
|
1: "Present",
|
||||||
|
2: "Future",
|
||||||
|
3: "Beyond",
|
||||||
|
}
|
||||||
|
|
||||||
|
RATING_CLASS_SHORT_TEXT_MAP = {
|
||||||
|
0: "PST",
|
||||||
|
1: "PRS",
|
||||||
|
2: "FTR",
|
||||||
|
3: "BYD",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def rating_class_to_text(rating_class: int) -> Optional[str]:
|
||||||
|
return RATING_CLASS_TEXT_MAP.get(rating_class)
|
||||||
|
|
||||||
|
|
||||||
|
def rating_class_to_short_text(rating_class: int) -> Optional[str]:
|
||||||
|
return RATING_CLASS_SHORT_TEXT_MAP.get(rating_class)
|
29
src/arcaea_offline/utils/score.py
Normal file
29
src/arcaea_offline/utils/score.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from typing import Any, Sequence
|
||||||
|
|
||||||
|
SCORE_GRADE_FLOOR = [9900000, 9800000, 9500000, 9200000, 8900000, 8600000, 0]
|
||||||
|
SCORE_GRADE_TEXTS = ["EX+", "EX", "AA", "A", "B", "C", "D"]
|
||||||
|
|
||||||
|
|
||||||
|
def zip_score_grade(score: int, __seq: Sequence, default: Any = "__PRESERVE__"):
|
||||||
|
"""
|
||||||
|
zip_score_grade is a simple wrapper that equals to:
|
||||||
|
```py
|
||||||
|
for score_floor, val in zip(SCORE_GRADE_FLOOR, __seq):
|
||||||
|
if score >= score_floor:
|
||||||
|
return val
|
||||||
|
return seq[-1] if default == "__PRESERVE__" else default
|
||||||
|
```
|
||||||
|
Could be useful in specific cases.
|
||||||
|
"""
|
||||||
|
return next(
|
||||||
|
(
|
||||||
|
val
|
||||||
|
for score_floor, val in zip(SCORE_GRADE_FLOOR, __seq)
|
||||||
|
if score >= score_floor
|
||||||
|
),
|
||||||
|
__seq[-1] if default == "__PRESERVE__" else default,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def score_to_grade_text(score: int) -> str:
|
||||||
|
return zip_score_grade(score, SCORE_GRADE_TEXTS)
|
Loading…
x
Reference in New Issue
Block a user