[Enhance][Refactor] unranked score & warning log

- Add an option that can be used to forbid some illegal scores
- Add brief warning logs for custom exceptions
This commit is contained in:
Lost-MSth
2022-11-28 21:58:06 +08:00
parent a7a9a4ba3d
commit 426f65ea9e
9 changed files with 84 additions and 66 deletions

View File

@@ -1,4 +1,5 @@
from .error import NoData
from .config_manager import Config
class Chart:
@@ -33,8 +34,10 @@ class Chart:
'''select rating_pst, rating_prs, rating_ftr, rating_byn from chart where song_id=:a''', {'a': self.song_id})
x = self.c.fetchone()
if x is None:
self.defnum = -10
# raise NoData('The song `%s` does not exist.' % self.song_id)
if Config.ALLOW_SCORE_WITH_NO_SONG:
self.defnum = -10
else:
raise NoData(f'The song `{self.song_id}` does not exist.', 120)
else:
self.defnum = x[self.difficulty]