diff --git a/umalauncher/constants.py b/umalauncher/constants.py index e671d71..d5410f2 100644 --- a/umalauncher/constants.py +++ b/umalauncher/constants.py @@ -143,35 +143,35 @@ 30000: "Platinum 4" } -SCOUTING_SCORE_TO_RANK_DICT = { - 0: "No rank", - 60000: "E", - 63000: "E1", - 66000: "E2", - 69000: "E3", - 72000: "D", - 76000: "D1", - 80000: "D2", - 85000: "D3", - 90000: "C", - 95000: "C1", - 100000: "C2", - 105000: "C3", - 110000: "B", - 115000: "B1", - 120000: "B2", - 125000: "B3", - 130000: "A", - 135000: "A1", - 140000: "A2", - 145000: "A3", - 150000: "A4", - 155000: "A5", - 160000: "S", - 165000: "S1", - 170000: "S2", - 180000: "S3", - 190000: "S4", - 200000: "S5", - 210000: "SS" -} \ No newline at end of file +SCOUTING_RANK_LIST = [ + "No rank", + "E", + "E1", + "E2", + "E3", + "D", + "D1", + "D2", + "D3", + "C", + "C1", + "C2", + "C3", + "B", + "B1", + "B2", + "B3", + "A", + "A1", + "A2", + "A3", + "A4", + "A5", + "S", + "S1", + "S2", + "S3", + "S4", + "S5", + "SS" +] \ No newline at end of file diff --git a/umalauncher/mdb.py b/umalauncher/mdb.py index 3c038a0..edf09d1 100644 --- a/umalauncher/mdb.py +++ b/umalauncher/mdb.py @@ -433,6 +433,28 @@ def get_skill_id_dict(force=False): return SKILL_ID_DICT +SCOUTING_SCORE_TO_RANK_DICT = {} +def get_scouting_score_to_rank_dict(force=False): + global SCOUTING_SCORE_TO_RANK_DICT + if force or not SCOUTING_SCORE_TO_RANK_DICT: + with Connection() as (_, cursor): + cursor.execute( + """SELECT team_min_value FROM team_building_rank""" + ) + rows = cursor.fetchall() + + tmp_dict = {} + for i, row in enumerate(rows): + min_score = row[0] + try: + rank = constants.SCOUTING_RANK_LIST[i] + except IndexError: + rank = constants.SCOUTING_RANK_LIST[-1] + tmp_dict[min_score] = rank + + SCOUTING_SCORE_TO_RANK_DICT.update(tmp_dict) + + return SCOUTING_SCORE_TO_RANK_DICT def get_card_inherent_skills(card_id, level=99): skills = [] @@ -515,4 +537,5 @@ def get_total_minigame_plushies(force=False): get_gl_lesson_dict, get_group_card_effect_ids, get_skill_id_dict, + get_scouting_score_to_rank_dict ] \ No newline at end of file diff --git a/umalauncher/util.py b/umalauncher/util.py index dc0c9fb..5563a0f 100644 --- a/umalauncher/util.py +++ b/umalauncher/util.py @@ -483,8 +483,8 @@ def heroes_score_to_league_string(score): return current_league def scouting_score_to_rank_string(score): - current_rank = list(constants.SCOUTING_SCORE_TO_RANK_DICT.keys())[0] - for score_threshold, rank in constants.SCOUTING_SCORE_TO_RANK_DICT.items(): + current_rank = list(mdb.get_scouting_score_to_rank_dict().keys())[0] + for score_threshold, rank in mdb.get_scouting_score_to_rank_dict().items(): if score >= score_threshold: current_rank = rank else: