Merge pull request #182 from Guzi422/dev

Dev bug fix about notification setting & course
This commit is contained in:
Lost-MSth
2024-09-27 00:19:17 +08:00
committed by GitHub
4 changed files with 25 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
from .error import NoData
from .item import ItemFactory
from .score import Score
from .song import Chart
@@ -281,12 +282,13 @@ class CoursePlay(UserCourse):
self.user_play.course_play_state += 1
from .score import Score
if Score.get_song_state(self.clear_type) > Score.get_song_state(self.user_play.clear_type):
self.clear_type = self.user_play.clear_type
self.user_play.update_play_state_for_course()
if self.user_play.course_play_state == 4:
self.user.select_user_about_stamina()
self.items = []
if not self.is_completed:
self.user.select_user_about_stamina()
self.select_course_item()

View File

@@ -305,6 +305,7 @@ class UserInfo(User):
self.recent_score = Score()
self.favorite_character = None
self.max_stamina_notification_enabled = False
self.mp_notification_enabled = False
self.prog_boost: int = 0
self.beyond_boost_gauge: float = 0
self.kanae_stored_prog: float = 0
@@ -495,7 +496,8 @@ class UserInfo(User):
"settings": {
"favorite_character": favorite_character_id,
"is_hide_rating": self.is_hide_rating,
"max_stamina_notification_enabled": self.max_stamina_notification_enabled
"max_stamina_notification_enabled": self.max_stamina_notification_enabled,
"mp_notification_enabled": self.mp_notification_enabled
},
"user_id": self.user_id,
"name": self.name,
@@ -560,6 +562,7 @@ class UserInfo(User):
self.favorite_character = None if x[23] == - \
1 else UserCharacter(self.c, x[23])
self.max_stamina_notification_enabled = x[24] == 1
self.mp_notification_enabled = x[37] == 1
self.current_map = Map(x[25]) if x[25] is not None else Map('')
self.ticket = x[26]
self.prog_boost = x[27] if x[27] is not None else 0
@@ -661,6 +664,20 @@ class UserInfo(User):
self.rating_ptt = x[1]
self.is_hide_rating = x[2] == 1
def select_user_about_settings(self) -> None:
'''
查询 user 表有关设置的信息
'''
self.c.execute(
'''select is_hide_rating, max_stamina_notification_enabled, mp_notification_enabled from user where user_id=?''', (self.user_id,)
x = self.c.fetchone()
if not x:
raise NoData('No user.', 108, -3)
self.is_hide_rating = x[0] == 1
self.max_stamina_notification_enabled = x[1] == 1
self.mp_notification_enabled = x[2] == 1
@property
def global_rank(self) -> int:
'''用户世界排名如果超过设定最大值返回0'''

View File

@@ -35,7 +35,8 @@ max_stamina_ts int,
stamina int,
world_mode_locked_end_ts int,
beyond_boost_gauge real default 0,
kanae_stored_prog real default 0
kanae_stored_prog real default 0,
mp_notification_enabled int
);
create table if not exists login(access_token text,
user_id int,

View File

@@ -157,7 +157,8 @@ def sys_set(user_id, set_arg):
user.change_favorite_character(int(value))
else:
value = 'true' == value
if set_arg in ('is_hide_rating', 'max_stamina_notification_enabled'):
if set_arg in ('is_hide_rating', 'max_stamina_notification_enabled', 'mp_notification_enabled'):
user.select_user_about_settings()
user.update_user_one_column(set_arg, value)
return success_return(user.to_dict())