Pre-support 4ex dlc

This commit is contained in:
UnitedAirforce
2025-02-03 20:12:09 +08:00
parent db084c44e6
commit 3e3c0ab575

207
7001.py
View File

@@ -600,17 +600,6 @@ def result():
tree = ET.parse(file_path) tree = ET.parse(file_path)
root = tree.getroot() 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 # Save the record
vid = decrypted_fields[b'vid'][0].decode() vid = decrypted_fields[b'vid'][0].decode()
stts = decrypted_fields[b'stts'][0].decode() stts = decrypted_fields[b'stts'][0].decode()
@@ -633,51 +622,64 @@ def result():
do_update_vid = False do_update_vid = False
last_row_id = 0 last_row_id = 0
#parse whether or not the device is logged in to taito ID 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.
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 != "":
with sqlite3.connect(DATABASE) as connection: with sqlite3.connect(DATABASE) as connection:
cursor = connection.cursor() cursor = connection.cursor()
check_command = """ cursor.execute("SELECT coin FROM daily_reward WHERE device_id = ?", (device_id,))
SELECT rid, score FROM result WHERE id = ? and mode = ? and sid = ? ORDER BY CAST(score AS INTEGER) DESC; row = cursor.fetchone()
"""
cursor.execute(check_command, (id, mode, sid)) if row:
records = cursor.fetchall() current_coin = row[0] if row[0] else start_coin
cursor.close() updated_coin = current_coin + coin_reward
if len(records) > 0: cursor.execute("UPDATE daily_reward SET coin = ? WHERE device_id = ?", (updated_coin, device_id))
last_row_id = records[0][0]
if (score > records[0][1]): #Try to add play record to result table (don't add if playing placeholder songs)
do_update_sid = True #parse whether or not the device is logged in to taito ID
else:
do_insert = True sid = ""
else:
with sqlite3.connect(DATABASE) as connection: with sqlite3.connect(DATABASE) as connection:
cursor = connection.cursor() cursor = connection.cursor()
check_command = """ select_command = """SELECT id FROM user WHERE device_id = ?;"""
SELECT rid, score FROM result WHERE id = ? and mode = ? and sid = ? and vid = ? ORDER BY CAST(score AS INTEGER) DESC; cursor.execute(select_command, (vid,))
""" result = cursor.fetchone() # Fetch one row from the result
cursor.execute(check_command, (id, mode, "", vid))
records = cursor.fetchall()
cursor.close() cursor.close()
if len(records) > 0:
last_row_id = records[0][0] # Check if a row was found
if (score > records[0][1]): if result:
do_update_vid = True sid = result[0]
else:
do_insert = True
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: if do_insert:
@@ -800,6 +802,13 @@ def web_shop():
coin = result[2] if result[2] else 0 coin = result[2] if result[2] else 0
if (cnt_type == "1"): if (cnt_type == "1"):
if (700 not in my_stage and os.path.isfile('./files/dlc_4max.html')):
buttons_html += """
<a href="wwic://web_shop_detail?&cnt_type=1&cnt_id=-1">
<img src="/files/web/dlc_4max.jpg" style="width: 84%; margin-bottom: 20px; margin-top: -100px;" />
</a><br>
"""
for idx, i in enumerate(range(100, 616)): for idx, i in enumerate(range(100, 616)):
if i not in my_stage: if i not in my_stage:
if i not in exclude_stage_exp: if i not in exclude_stage_exp:
@@ -872,25 +881,26 @@ def web_shop_detail():
html = "" html = ""
if (cnt_type == "1"): if (cnt_type == "1"):
song = song_list[cnt_id] if (cnt_id != -1):
difficulty_levels = "/".join(map(str, song.get("difficulty_levels", []))) song = song_list[cnt_id]
song_stage_price = stage_price difficulty_levels = "/".join(map(str, song.get("difficulty_levels", [])))
if (len(song["difficulty_levels"]) == 6): song_stage_price = stage_price
song_stage_price = stage_price * 2 if (len(song["difficulty_levels"]) == 6):
html = f""" song_stage_price = stage_price * 2
<div class="image-container"> html = f"""
<img src="/files/image/icon/shop/{cnt_id}.jpg" alt="Item Image" style="width: 180px; height: 180px;" /> <div class="image-container">
</div> <img src="/files/image/icon/shop/{cnt_id}.jpg" alt="Item Image" style="width: 180px; height: 180px;" />
<p>Would you like to purchase this song?</p> </div>
<div> <p>Would you like to purchase this song?</p>
<p>{song.get("name_en")} - {song.get("author_en")}</p> <div>
<p>Difficulty Levels: {difficulty_levels}</p> <p>{song.get("name_en")} - {song.get("author_en")}</p>
</div> <p>Difficulty Levels: {difficulty_levels}</p>
<div> </div>
<img src="/files/web/coin_icon.png" class="coin-icon" style="width: 40px; height: 40px;" alt="Coin Icon" /> <div>
<span style="color: #FFFFFF; font-size: 44px; font-family: Hiragino Kaku Gothic ProN, sans-serif;">{song_stage_price}</span> <img src="/files/web/coin_icon.png" class="coin-icon" style="width: 40px; height: 40px;" alt="Coin Icon" />
</div> <span style="color: #FFFFFF; font-size: 44px; font-family: Hiragino Kaku Gothic ProN, sans-serif;">{song_stage_price}</span>
""" </div>
"""
elif (cnt_type == "2"): elif (cnt_type == "2"):
avatar = next((item for item in avatar_list if item.get("id") == cnt_id), None) avatar = next((item for item in avatar_list if item.get("id") == cnt_id), None)
@@ -932,16 +942,19 @@ def web_shop_detail():
else: else:
html = "<p>Item not found.</p>" html = "<p>Item not found.</p>"
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"""
<br>
<div class="buttons" style="margin-top: 20px;">
<a href="wwic://web_purchase_coin?cnt_type={cnt_type}&cnt_id={cnt_id}&num=1" class="bt_bg01" >Buy</a><br>
<a href="wwic://web_shop?cnt_type={cnt_type}" class="bt_bg01" >Go Back</a>
</div>
"""
html += f""" with open(source_html, "r", encoding="utf-8") as file:
<br>
<div class="buttons" style="margin-top: 20px;">
<a href="wwic://web_purchase_coin?cnt_type={cnt_type}&cnt_id={cnt_id}&num=1" class="bt_bg01" >Buy</a><br>
<a href="wwic://web_shop?cnt_type={cnt_type}" class="bt_bg01" >Go Back</a>
</div>
"""
with open(f"files/web_shop_detail.html", "r", encoding="utf-8") as file:
html_content = file.read().format(text=html, coin=coin) html_content = file.read().format(text=html, coin=coin)
return html_content return html_content
else: else:
@@ -976,20 +989,34 @@ def buy_by_coin():
# Process based on cnt_type # Process based on cnt_type
if cnt_type == "1": if cnt_type == "1":
song_stage_price = stage_price if cnt_id == -1:
if (len(song_list[cnt_id]["difficulty_levels"]) == 6): song_stage_price = 300
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 coin < song_stage_price: for i in range(617, 950):
return fail_url if i not in stages:
stages.add(i)
stages = set(json.loads(my_stage)) if my_stage else set()
if cnt_id not in stages:
coin -= song_stage_price coin -= song_stage_price
stages.add(cnt_id) my_stage = json.dumps(list(stages))
else: else:
return fail_url song_stage_price = stage_price
my_stage = json.dumps(list(stages)) 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": elif cnt_type == "2":
if coin < avatar_price: if coin < avatar_price: