diff --git a/7001.py b/7001.py index d039ce8..987a89e 100644 --- a/7001.py +++ b/7001.py @@ -600,17 +600,6 @@ def result(): tree = ET.parse(file_path) root = tree.getroot() - # Increment coin for user - with sqlite3.connect(DATABASE) as connection: - cursor = connection.cursor() - cursor.execute("SELECT coin FROM daily_reward WHERE device_id = ?", (device_id,)) - row = cursor.fetchone() - - if row: - current_coin = row[0] if row[0] else start_coin - updated_coin = current_coin + coin_reward - cursor.execute("UPDATE daily_reward SET coin = ? WHERE device_id = ?", (updated_coin, device_id)) - # Save the record vid = decrypted_fields[b'vid'][0].decode() stts = decrypted_fields[b'stts'][0].decode() @@ -633,51 +622,64 @@ def result(): do_update_vid = False last_row_id = 0 - #parse whether or not the device is logged in to taito ID - - sid = "" - with sqlite3.connect(DATABASE) as connection: - cursor = connection.cursor() - select_command = """SELECT id FROM user WHERE device_id = ?;""" - cursor.execute(select_command, (vid,)) - result = cursor.fetchone() # Fetch one row from the result - cursor.close() - - # Check if a row was found - if result: - sid = result[0] - - - if sid != "": + if (int(id) not in range(616, 1000) or int(mode) not in range(10, 14)): + # Increment coin for user, if track is not 4max dlx pack mobile difficulty. with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor() - check_command = """ - SELECT rid, score FROM result WHERE id = ? and mode = ? and sid = ? ORDER BY CAST(score AS INTEGER) DESC; - """ - cursor.execute(check_command, (id, mode, sid)) - records = cursor.fetchall() - cursor.close() - if len(records) > 0: - last_row_id = records[0][0] - if (score > records[0][1]): - do_update_sid = True - else: - do_insert = True - else: + cursor.execute("SELECT coin FROM daily_reward WHERE device_id = ?", (device_id,)) + row = cursor.fetchone() + + if row: + current_coin = row[0] if row[0] else start_coin + updated_coin = current_coin + coin_reward + cursor.execute("UPDATE daily_reward SET coin = ? WHERE device_id = ?", (updated_coin, device_id)) + + #Try to add play record to result table (don't add if playing placeholder songs) + #parse whether or not the device is logged in to taito ID + + sid = "" with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor() - check_command = """ - SELECT rid, score FROM result WHERE id = ? and mode = ? and sid = ? and vid = ? ORDER BY CAST(score AS INTEGER) DESC; - """ - cursor.execute(check_command, (id, mode, "", vid)) - records = cursor.fetchall() + select_command = """SELECT id FROM user WHERE device_id = ?;""" + cursor.execute(select_command, (vid,)) + result = cursor.fetchone() # Fetch one row from the result cursor.close() - if len(records) > 0: - last_row_id = records[0][0] - if (score > records[0][1]): - do_update_vid = True - else: - do_insert = True + + # Check if a row was found + if result: + sid = result[0] + + + if sid != "": + with sqlite3.connect(DATABASE) as connection: + cursor = connection.cursor() + check_command = """ + SELECT rid, score FROM result WHERE id = ? and mode = ? and sid = ? ORDER BY CAST(score AS INTEGER) DESC; + """ + cursor.execute(check_command, (id, mode, sid)) + records = cursor.fetchall() + cursor.close() + if len(records) > 0: + last_row_id = records[0][0] + if (score > records[0][1]): + do_update_sid = True + else: + do_insert = True + else: + with sqlite3.connect(DATABASE) as connection: + cursor = connection.cursor() + check_command = """ + SELECT rid, score FROM result WHERE id = ? and mode = ? and sid = ? and vid = ? ORDER BY CAST(score AS INTEGER) DESC; + """ + cursor.execute(check_command, (id, mode, "", vid)) + records = cursor.fetchall() + cursor.close() + if len(records) > 0: + last_row_id = records[0][0] + if (score > records[0][1]): + do_update_vid = True + else: + do_insert = True if do_insert: @@ -800,6 +802,13 @@ def web_shop(): coin = result[2] if result[2] else 0 if (cnt_type == "1"): + if (700 not in my_stage and os.path.isfile('./files/dlc_4max.html')): + buttons_html += """ + + +
+ """ + for idx, i in enumerate(range(100, 616)): if i not in my_stage: if i not in exclude_stage_exp: @@ -872,25 +881,26 @@ def web_shop_detail(): html = "" if (cnt_type == "1"): - song = song_list[cnt_id] - difficulty_levels = "/".join(map(str, song.get("difficulty_levels", []))) - song_stage_price = stage_price - if (len(song["difficulty_levels"]) == 6): - song_stage_price = stage_price * 2 - html = f""" -
- Item Image -
-

Would you like to purchase this song?

-
-

{song.get("name_en")} - {song.get("author_en")}

-

Difficulty Levels: {difficulty_levels}

-
-
- Coin Icon - {song_stage_price} -
- """ + if (cnt_id != -1): + song = song_list[cnt_id] + difficulty_levels = "/".join(map(str, song.get("difficulty_levels", []))) + song_stage_price = stage_price + if (len(song["difficulty_levels"]) == 6): + song_stage_price = stage_price * 2 + html = f""" +
+ Item Image +
+

Would you like to purchase this song?

+
+

{song.get("name_en")} - {song.get("author_en")}

+

Difficulty Levels: {difficulty_levels}

+
+
+ Coin Icon + {song_stage_price} +
+ """ elif (cnt_type == "2"): avatar = next((item for item in avatar_list if item.get("id") == cnt_id), None) @@ -932,16 +942,19 @@ def web_shop_detail(): else: html = "

Item not found.

" + if (cnt_type == "1" and cnt_id == -1): + source_html = f"files/dlc_4max.html" + else: + source_html = f"files/web_shop_detail.html" + html += f""" +
+
+ Buy
+ Go Back +
+ """ - html += f""" -
-
- Buy
- Go Back -
- """ - - with open(f"files/web_shop_detail.html", "r", encoding="utf-8") as file: + with open(source_html, "r", encoding="utf-8") as file: html_content = file.read().format(text=html, coin=coin) return html_content else: @@ -976,20 +989,34 @@ def buy_by_coin(): # Process based on cnt_type if cnt_type == "1": - song_stage_price = stage_price - if (len(song_list[cnt_id]["difficulty_levels"]) == 6): - song_stage_price = song_stage_price * 2 + if cnt_id == -1: + song_stage_price = 300 + if coin < song_stage_price: + return fail_url + + stages = set(json.loads(my_stage)) if my_stage else set() - if coin < song_stage_price: - return fail_url - - stages = set(json.loads(my_stage)) if my_stage else set() - if cnt_id not in stages: + for i in range(617, 950): + if i not in stages: + stages.add(i) coin -= song_stage_price - stages.add(cnt_id) + my_stage = json.dumps(list(stages)) + else: - return fail_url - my_stage = json.dumps(list(stages)) + song_stage_price = stage_price + if (len(song_list[cnt_id]["difficulty_levels"]) == 6): + song_stage_price = song_stage_price * 2 + + if coin < song_stage_price: + return fail_url + + stages = set(json.loads(my_stage)) if my_stage else set() + if cnt_id not in stages: + coin -= song_stage_price + stages.add(cnt_id) + else: + return fail_url + my_stage = json.dumps(list(stages)) elif cnt_type == "2": if coin < avatar_price: