Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grab team building event ranks from mdb instead of hardcoding it. #253

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions umalauncher/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
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"
]
23 changes: 23 additions & 0 deletions umalauncher/mdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
]
4 changes: 2 additions & 2 deletions umalauncher/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down