mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-18 13:50:16 +00:00
Compare commits
3 Commits
dbb5d680af
...
f40ea91ee2
Author | SHA1 | Date | |
---|---|---|---|
f40ea91ee2 | |||
ade0bcb2b7 | |||
abc535c59f |
@ -7,7 +7,7 @@ from arcaea_offline.constants.play_result import ScoreLowerLimits
|
|||||||
|
|
||||||
class PlayResultCalculators:
|
class PlayResultCalculators:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def score_possible_range(notes: int, pure: int, far: int) -> tuple[int, int]:
|
def score_possible_range(notes: int, pure: int, far: int) -> Tuple[int, int]:
|
||||||
"""
|
"""
|
||||||
Returns the possible range of score based on the given values.
|
Returns the possible range of score based on the given values.
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ class PlayResultCalculators:
|
|||||||
if score < 0:
|
if score < 0:
|
||||||
raise ValueError("score cannot be negative")
|
raise ValueError("score cannot be negative")
|
||||||
|
|
||||||
if score >= 10000000:
|
if score >= ScoreLowerLimits.PM:
|
||||||
return Decimal(2)
|
return Decimal(2)
|
||||||
if score >= 9800000:
|
if score >= ScoreLowerLimits.EX:
|
||||||
return Decimal(1) + (Decimal(score - 9800000) / 200000)
|
return Decimal(1) + (Decimal(score - 9800000) / 200000)
|
||||||
return Decimal(score - 9500000) / 300000
|
return Decimal(score - 9500000) / 300000
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class ScoreLowerLimits:
|
class ScoreLowerLimits:
|
||||||
|
PM = 10000000
|
||||||
EX_PLUS = 9900000
|
EX_PLUS = 9900000
|
||||||
EX = 9800000
|
EX = 9800000
|
||||||
AA = 9500000
|
AA = 9500000
|
||||||
|
3
tests/external/importers/arcaea/test_st3.py
vendored
3
tests/external/importers/arcaea/test_st3.py
vendored
@ -1,6 +1,5 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from importlib.resources import files
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from arcaea_offline.constants.enums.arcaea import (
|
from arcaea_offline.constants.enums.arcaea import (
|
||||||
@ -14,7 +13,7 @@ import tests.resources
|
|||||||
|
|
||||||
|
|
||||||
class TestSt3Parser:
|
class TestSt3Parser:
|
||||||
DB_PATH = files(tests.resources).joinpath("st3-test.db")
|
DB_PATH = tests.resources.get_resource("st3-test.db")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def play_results(self):
|
def play_results(self):
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
import importlib.resources
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def get_resource(path: str):
|
||||||
|
"""
|
||||||
|
A wrapper for `importlib.resources.files()` since it's not available in Python 3.8.
|
||||||
|
"""
|
||||||
|
if sys.version_info >= (3, 9, 0):
|
||||||
|
with importlib.resources.as_file(
|
||||||
|
importlib.resources.files(__name__).joinpath(path)
|
||||||
|
) as resource_path:
|
||||||
|
return resource_path
|
||||||
|
|
||||||
|
with importlib.resources.path(__name__, path) as resource_path:
|
||||||
|
return resource_path
|
Loading…
x
Reference in New Issue
Block a user