import random import json import os # import psutil import win32gui import tkinter as tk import sys import logging import rougetask import rougesetting # import cProfile import requests from datetime import datetime, timedelta # from memory_profiler import profile # import easygui as eg from game import control from game.algo import rougeGen from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data from game.algo import utils as util from game.const import rouge as R from game.const import game as G current_folder_path = os.getcwd() def current_lv(lv): lv_list = R.lv_list if lv >= sum(lv_list): return "--" for k in range(0,14): if sum(lv_list[:k]) <= lv < sum(lv_list[:k+1]): return str(sum(lv_list[:k+1])-lv) def check_rouge_ob_data(data): hero_data_dic = { "Fox": {"exp": 0, "lv": 1}, "Boboli": {"exp": 0, "lv": 1}, "Naruto_old": {"exp": 0, "lv": 1}, "Asha": {"exp": 0, "lv": 1}, "Maria": {"exp": 0, "lv": 1}, "Surprise": {"exp": 0, "lv": 1} } err_cnt = 0 for k, v in hero_data_dic.items(): if k not in data.keys(): data[k] = v err_cnt += 1 print(f"缺失{k}数据, 正在补充...") if err_cnt > 0: save_encrypt_single_rouge_file(data, "rougeOB") class App: def __init__(self, master): self.master = master master.geometry("960x640") master.configure(bg='#7E587E') master.title("QQTRogue二测β2.3.1(底层逻辑:永恒; 肉鸽算法开发与设计:100の雨女; 唯一官方群756422783免费下载; 擅自售卖皆属剽窃!)") rougeOB_data = {} rougeOB_achivements = [] self.current_hero = "Fox" self.current_difficulty = "Easy" user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径 qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径 os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建 rouge_file_path = os.path.join(qqtpve_folder, "rougeOB.rougedata") # 构建文件路径 rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径 old_file_path = os.path.join(qqtpve_folder, "rouge.json") # 构建文件路径 old_achivements_file_path = os.path.join(qqtpve_folder, "rouge_achievement.json") # 构建成就文件路径 rouge_task_file_path = os.path.join(qqtpve_folder, "rougeOB_task.rougedata") # 构建任务文件路径 last_game_file_path = os.path.join(qqtpve_folder, "rougeOBLastGame.rougedata") # 构建存档文件路径 other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径 # 杂项第一次打开 if not os.path.exists(other_file_path): rougeOB_other_data = {"Bomb": [], "Pet": [], "Hat": [], "LastRandom": 0, "Other": []} save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther") # 正常打开 else: rougeOB_other_data = load_rouge_data(other_file_path) if 'Cursor_Skin' not in rougeOB_other_data.keys(): rougeOB_other_data['Cursor_Skin'] = "fire_cursor" R.cursor_skin = "fire_cursor" save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther") else: R.cursor_skin = rougeOB_other_data['Cursor_Skin'] if 'Bomb_Skin' not in rougeOB_other_data.keys(): rougeOB_other_data['Bomb_Skin'] = "bomb1" R.bomb_skin = "bomb1" save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther") else: R.bomb_skin = rougeOB_other_data['Bomb_Skin'] # 第一次打开 if not os.path.exists(rouge_task_file_path): rougeOB_task_data = {"1": {"task": "击杀5只命运维系者", "reward": "800经验", "process": 0, "finish": 5, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "2": {"task": "击杀3只渊烬龙王", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "3": {"task": "到达3-1十次", "reward": "800经验", "process": 0, "finish": 10, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "4": {"task": "击杀5只因果阅律者", "reward": "800经验", "process": 0, "finish": 5, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "5": {"task": "完成20次挑衅敌人", "reward": "800经验", "process": 0, "finish": 20, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "6": {"task": "使用小倩到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "7": {"task": "使用波波丽到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "8": {"task": "使用火影到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "9": {"task": "使用阿莎到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "10": {"task": "使用玛莉亚到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "11": {"task": "到达4-1一次", "reward": "800经验", "process": 0, "finish": 1, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "12": {"task": "累积使用20次复活卡", "reward": "800经验", "process": 0, "finish": 20, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True}, "today": {"task": "进行一盘游戏并到达2-1", "reward": "50经验", "process": 0, "finish": 1, "last_finish": "1970-1-1", "reward_exp": 50, "hero": "Fox", "rewarded": True}} save_encrypt_single_rouge_file(rougeOB_task_data, "rougeOB_task") # 正常打开 else: rougeOB_task_data = load_rouge_data(rouge_task_file_path) now = datetime.now() # 格式化年月日 year = now.strftime("%Y") month = now.strftime("%m") day = now.strftime("%d") # 移除月份和日期的前导零(如果有) month = month.lstrip("0") day = day.lstrip("0") R.today_datetime["year"] = int(year) R.today_datetime["month"] = int(month) R.today_datetime["day"] = int(day) try: if len(rougeOB_task_data[str(month)]["last_finish"]) > 4: # 防一手格式错误 rougeOB_task_data[str(month)]["last_finish"] = rougeOB_task_data[str(month)]["last_finish"][0:4] except: pass if int(rougeOB_task_data[str(month)]["last_finish"]) < int(year): rougeOB_task_data[str(month)]["process"] = 0 rougeOB_task_data[str(month)]["last_finish"] = year rougeOB_task_data[str(month)]["rewarded"] = False if rougeOB_task_data["today"]["last_finish"] != year + "-" + month + "-" + day: rougeOB_task_data["today"]["process"] = 0 rougeOB_task_data["today"]["last_finish"] = year + "-" + month + "-" + day rougeOB_task_data["today"]["rewarded"] = False save_encrypt_single_rouge_file(rougeOB_task_data, "rougeOB_task") # 第一次打开 if not os.path.exists(rouge_file_path): # 若参与过第一轮beta测试 if os.path.exists(old_file_path): # 备份旧文件 old_json = load_json(old_file_path) rougeOB_data = {"Fox": {"exp": old_json["Fox"]["exp"], "lv": old_json["Fox"]["lv"]}, "Boboli": {"exp": old_json["Boboli"]["exp"], "lv": old_json["Boboli"]["exp"]}, "Naruto_old": {"exp": 0, "lv": 1}, "Asha": {"exp": old_json["Naruto_old"]["exp"], "lv": old_json["Naruto_old"]["exp"]}, "Maria": {"exp": 0, "lv": 1}, "Surprise": {"exp": 0, "lv": 1}} print("等级数据继承成功") else: rougeOB_data = { "Fox": {"exp": 0, "lv": 1}, "Boboli": {"exp": 0, "lv": 1}, "Naruto_old": {"exp": 0, "lv": 1}, "Asha": {"exp": 0, "lv": 1}, "Maria": {"exp": 0, "lv": 1}, "Surprise": {"exp": 0, "lv": 1} } save_encrypt_single_rouge_file(rougeOB_data, "rougeOB") # 正常打开 else: rougeOB_data = load_rouge_data(rouge_file_path) # ========================================================================================= util.load_online_config() if G.UID == "" and G.USERNAME == "": # username = input("请输入昵称: ").strip() # password = input("请输入密码: ").strip() util.register() new_info = rougeOB_data new_info["record"] = "null" result = util.update_profile(G.UID, new_info, G.PASSWORD) print(result.get('message', '未知错误')) is_online = util.try_login() if is_online: rougeOB_data = util.get_online_data() # ========================================================================================= check_rouge_ob_data(rougeOB_data) print(rougeOB_data) for hero in ["Fox", "Boboli", "Naruto_old", "Asha", "Maria"]: rougeOB_data[hero]["lv"] = R.current_lv(rougeOB_data[hero]["exp"]) Fox_info = "小倩: 等级"+str(rougeOB_data["Fox"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Fox"]["exp"]) + ", 技能: 自身血量减少1则糖泡伤害增加"+str(R.FoxSkill(rougeOB_data["Fox"]["lv"])) Boboli_info = "波波丽: 等级"+str(rougeOB_data["Boboli"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Boboli"]["exp"]) + ", 技能: 每次攻击额外造成"+str(int(R.BoboliSkill(rougeOB_data["Boboli"]["lv"])*100))+"%真实伤害" Naruto_old_info = "火影: 等级"+str(rougeOB_data["Naruto_old"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Naruto_old"]["exp"]) + ", 技能: 首次攻击每只怪物时攻击力变为"+str(int(R.Naruto_oldSkill(rougeOB_data["Naruto_old"]["lv"])*100))+"%" Asha_info = "阿莎: 等级"+str(rougeOB_data["Asha"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Asha"]["exp"]) + ", 技能: 每次糖泡造成伤害恢复血量"+str(R.AshaSkill(rougeOB_data["Asha"]["lv"])*100)+"%" Maria_info = "玛莉亚: 等级"+str(rougeOB_data["Maria"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Maria"]["exp"]) + ", 技能: 每次造成伤害降低怪物近身"+str(R.MariaSkill(rougeOB_data["Maria"]["lv"])*100)+"%(最高50%)与"+str(R.MariaSkill2(rougeOB_data["Maria"]["lv"]))+"防御" # 第一次打开 if not os.path.exists(rouge_achivements_file_path): # 若参与过第一轮beta测试 ''' if os.path.exists(old_achivements_file_path): # 备份旧文件 old_achivements_json = load_json(old_achivements_file_path) rougeOB_achivements = old_achivements_json print("成就数据继承成功") else: rougeOB_achivements = [] ''' rougeOB_achivements = [] save_encrypt_single_rouge_file(rougeOB_achivements, "rougeOB_achievement") # 正常打开 else: rougeOB_achivements = load_rouge_data(rouge_achivements_file_path) # for ch in rougeOB_achivements: # print(ch) max_level = 0 max_level_hero = "Fox" max_diff = "Easy" max_diff_num = 1 self.hero_dic= {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"} self.diff_dic = {"Easy": "简单", "Normal": "困难", "Hell": "炼狱", "Hell+": "炼狱+"} diff_num = {"Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4} diff_status = {"Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0} for data in rougeOB_achivements: if diff_num[data["DIFF"]] > max_diff_num: max_level = data["CL"] max_level_hero = data["HERO"] max_diff = data["DIFF"] max_diff_num = diff_num[data["DIFF"]] if diff_num[data["DIFF"]] == max_diff_num: if data["CL"] > max_level: max_level = data["CL"] max_level_hero = data["HERO"] if data["CL"] == 20: diff_status[data["DIFF"]] = 2 if max_level > 0: record_text = "最高挑战纪录: 通关<"+ self.diff_dic[max_diff] +str((max_level -1)//5+1)+ "-" + str((max_level-1)%5+1) + ">; 使用英雄: " + self.hero_dic[max_level_hero] else: record_text = "暂无挑战记录" if max_diff == "Hell+": R.pass_status["Easy"] = 1 R.pass_status["Normal"] = 1 R.pass_status["Hell"] = 1 if max_level >= 15: R.pass_status["Hell+"] = 1 elif max_diff == "Hell": R.pass_status["Easy"] = 1 R.pass_status["Normal"] = 1 # R.cursor_skin = "fire_cursor_kubi" if max_level >= 15: R.pass_status["Hell"] = 1 # R.cursor_skin = "fire_cursor_gold_kubi" elif max_diff == "Normal": R.pass_status["Easy"] = 1 # R.cursor_skin = "fire_cursor2" if max_level >= 15: R.pass_status["Normal"] = 1 # R.cursor_skin = "fire_cursor_kubi" else: if max_level >= 15: R.pass_status["Easy"] = 1 # R.cursor_skin = "fire_cursor2" for dif in ["Easy","Normal","Hell","Hell+"]: if diff_status[dif] == 2: R.pass_status[dif] = 2 # 开始游戏 self.button0 = tk.Button(master, text= "进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: "+ self.hero_dic[self.current_hero] + ")", command=lambda: self.button_general_start(self.current_hero, self.current_difficulty), bg="#C68E17", font=("Microsoft YaHei", 20)) self.button0.place(relx=0.5, rely=0.29, anchor='center') # 继续游戏 if os.path.exists(last_game_file_path): last_game_file = load_rouge_data(last_game_file_path) self.button000 = tk.Button(master, text= "继续游戏 (关卡: " + str(((last_game_file["current_level"]+2)//2 -1)//5+1) + "-" + str(((last_game_file["current_level"]+2)//2-1)%5+1) + "结束) \n (难度: " + self.diff_dic[last_game_file["difficulty"]] + "; 英雄: "+ self.hero_dic[last_game_file["rouge_hero"]] + ")", command=lambda: self.button_continue(last_game_file, last_game_file_path), bg="#C68E17", font=("Microsoft YaHei", 18)) self.button000.place(relx=0.5, rely=0.44, anchor='center') # 任务系统 self.button_task = tk.Button(master, text= "任务系统", command=lambda: self.button_task_start(), bg="#C68E17", font=("Microsoft YaHei", 24)) self.button_task.place(relx=0.16, rely=0.16, anchor='center') # 选择皮肤 self.button_task = tk.Button(master, text= "陈列馆", command=lambda: self.button_setting_start(), bg="#C68E17", font=("Microsoft YaHei", 18)) self.button_task.place(relx=0.16, rely=0.28, anchor='center') # 选择简单 self.button_easy = tk.Button(master, text="● 选择简单难度", command=lambda: self.button_choose_diff("Easy"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button_easy.place(relx=0.75, rely=0.1, anchor='w') # 选择普通 if max_diff in ["Normal", "Hell", "Hell+"] or max_level >= 15: self.button_normal = tk.Button(master, text="● 选择困难难度", command=lambda: self.button_choose_diff("Normal"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button_normal.place(relx=0.75, rely=0.18, anchor='w') # 选择随机 if abs(60*datetime.now().hour+datetime.now().minute - int(rougeOB_other_data["LastRandom"])) >= 3: self.button5 = tk.Button(master, text="● 随机开局", command=lambda: self.button_choose_hero("Random"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button5.place(relx=0.07, rely=0.95, anchor='w') else: self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12)) self.button5.place(relx=0.07, rely=0.95, anchor='w') # 提示用 if abs(60*datetime.now().hour+datetime.now().minute - rougeOB_other_data["LastRandom"]) >= 3: self.button109 = tk.Button(master, text="随机选择上列英雄,并获得<引路人>(本选项冷却时间3分钟)", bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button109.place(relx=0.2, rely=0.95, anchor='w') else: last_time = rougeOB_other_data["LastRandom"] self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(选项冷却中-下次开启-"+ f"{((last_time + 3) // 60) % 24:02d}:{(last_time + 3) % 60:02d}" +")", bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button109.place(relx=0.2, rely=0.95, anchor='w') else: self.button_normal = tk.Button(master, text="○ 困难难度(通关简单后解锁)", bg="#614051", font=("Microsoft YaHei", 12)) self.button_normal.place(relx=0.75, rely=0.18, anchor='w') # 选择随机 self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12)) self.button5.place(relx=0.07, rely=0.95, anchor='w') self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(通关一次简单难度后开启)", bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button109.place(relx=0.2, rely=0.95, anchor='w') # 选择炼狱 if max_diff in ["Hell", "Hell+"] or (max_diff == "Normal" and max_level >= 15): self.button_hell = tk.Button(master, text="● 选择炼狱难度", command=lambda: self.button_choose_diff("Hell"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button_hell.place(relx=0.75, rely=0.26, anchor='w') else: self.button_hell = tk.Button(master, text="○ 炼狱难度(通关困难后解锁)", bg="#614051", font=("Microsoft YaHei", 12)) self.button_hell.place(relx=0.75, rely=0.26, anchor='w') # 选择炼狱+ if max_diff == "Hell+" or (max_diff == "Hell" and max_level >= 15): self.button_hell_plus = tk.Button(master, text="● 选择炼狱+难度", command=lambda: self.button_choose_diff("Hell+"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button_hell_plus.place(relx=0.75, rely=0.34, anchor='w') else: self.button_hell_plus = tk.Button(master, text="○ 炼狱+难度(通关炼狱后解锁)", bg="#614051", font=("Microsoft YaHei", 12)) self.button_hell_plus.place(relx=0.75, rely=0.34, anchor='w') # 选择Fox self.button1 = tk.Button(master, text="● 选择小倩", command=lambda: self.button_choose_hero("Fox"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button1.place(relx=0.07, rely=0.65, anchor='w') # 选择Boboli self.button2 = tk.Button(master, text="● 选择波波丽", command=lambda: self.button_choose_hero("Boboli"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button2.place(relx=0.07, rely=0.71, anchor='w') # 选择Naruto_old self.button3 = tk.Button(master, text="● 选择火影", command=lambda: self.button_choose_hero("Naruto_old"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button3.place(relx=0.07, rely=0.77, anchor='w') # 选择Asha self.button4 = tk.Button(master, text="● 选择阿莎", command=lambda: self.button_choose_hero("Asha"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button4.place(relx=0.07, rely=0.83, anchor='w') # 选择Maria self.button5 = tk.Button(master, text="● 选择玛莉亚", command=lambda: self.button_choose_hero("Maria"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button5.place(relx=0.07, rely=0.89, anchor='w') # 选择??? self.button6 = tk.Button(master, text="● 选择???", command=lambda: self.button_choose_hero("Surprise"), bg="#C47451", font=("Microsoft YaHei", 12)) self.button6.place(relx=0.07, rely=0.5, anchor='w') # 选择随机 # if abs(60*datetime.now().hour+datetime.now().minute - int(rougeOB_other_data["LastRandom"])) >= 3: # self.button5 = tk.Button(master, text="● 随机开局", command=lambda: self.button_choose_hero("Random"), bg="#C47451", font=("Microsoft YaHei", 12)) # self.button5.place(relx=0.07, rely=0.95, anchor='w') # else: # self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12)) # self.button5.place(relx=0.07, rely=0.95, anchor='w') # 通关成就展示 self.button100 = tk.Button(master, text=record_text, bg="#7E354D", font=("Microsoft YaHei", 14)) self.button100.place(relx=0.5, rely=0.56, anchor='center') # 提示用 self.button101 = tk.Button(master, text=Fox_info, bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button101.place(relx=0.2, rely=0.65, anchor='w') # 提示用 self.button102 = tk.Button(master, text=Boboli_info, bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button102.place(relx=0.2, rely=0.71, anchor='w') # 提示用 self.button103 = tk.Button(master, text=Naruto_old_info, bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button103.place(relx=0.2, rely=0.77, anchor='w') # 提示用 self.button104 = tk.Button(master, text=Asha_info, bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button104.place(relx=0.2, rely=0.83, anchor='w') # 提示用 self.button105 = tk.Button(master, text=Maria_info, bg="#E6A9EC", font=("Microsoft YaHei", 12)) self.button105.place(relx=0.2, rely=0.89, anchor='w') # 提示用 # if abs(60*datetime.now().hour+datetime.now().minute - rougeOB_other_data["LastRandom"]) >= 3: # self.button109 = tk.Button(master, text="随机选择上列英雄,并获得<引路人>(本选项冷却时间3分钟)", bg="#E6A9EC", font=("Microsoft YaHei", 12)) # self.button109.place(relx=0.2, rely=0.95, anchor='w') # else: # last_time = rougeOB_other_data["LastRandom"] # self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(选项冷却中-下次开启-"+ f"{((last_time + 3) // 60) % 24:02d}:{(last_time + 3) % 60:02d}" +")", bg="#E6A9EC", font=("Microsoft YaHei", 12)) # self.button109.place(relx=0.2, rely=0.95, anchor='w') # 通用开局 def button_general_start(self, hero, difficulty): if hero == "Random": hero = random.choice(["Fox","Boboli","Naruto_old","Asha","Maria","Surprise"]) R.show_cursor = True user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径 qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径 os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建 other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径 if not os.path.exists(other_file_path): rougeOB_other_data = {"Bomb": [], "Pet": [], "Hat": [], "LastRandom": int(60*datetime.now().hour+datetime.now().minute), "Other": []} save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther") else: rougeOB_other_data = load_rouge_data(other_file_path) rougeOB_other_data["LastRandom"] = int(60*datetime.now().hour+datetime.now().minute) save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther") with open("config.json", "r", encoding="utf-8") as json_file: mapsetdata = json.load(json_file) mapsetdata["map_set"] = "rogueMapSet" mapsetdata["your_hero"] = hero R.difficulty = difficulty with open("config.json", "w", encoding="utf-8") as json_file: json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False) self.master.destroy() rougeGen.main_func() control.Control() # 读取上次存档 def button_continue(self, last_data, last_path): self.master.destroy() R.continuing_game = True G.CURRENT_LEVEL = last_data["current_level"] R.map_json_dic = last_data["map_json_dic"] R.central_mapset = last_data["central_mapset"] R.difficulty = last_data["difficulty"] R.today_datetime = last_data["today_datetime"] R.task_RougeTreasureDestinyElite = last_data["task_RougeTreasureDestinyElite"] R.task_MineCFireDragonBoss = last_data["task_MineCFireDragonBoss"] R.task_RougeTreasureDestinyWizard = last_data["task_RougeTreasureDestinyWizard"] R.task_combat = last_data["task_combat"] R.task_revival = last_data["task_revival"] R.rouge_data = last_data["rouge_data"] R.rouge_hero = last_data["rouge_hero"] R.rouge_lv = last_data["rouge_lv"] R.rouge_exp = last_data["rouge_exp"] R.game_exp = last_data["game_exp"] R.rouge_story = last_data["rouge_story"] R.rouge_theme_1 = last_data["rouge_theme_1"] R.rouge_theme_2 = last_data["rouge_theme_2"] R.rouge_theme_3 = last_data["rouge_theme_3"] R.rouge_theme_4 = last_data["rouge_theme_4"] R.rouge_destiny = last_data["rouge_destiny"] R.coin = last_data["coin"] R.general_mon_dic = last_data["general_mon_dic"] R.story_eden = last_data["story_eden"] R.story_destiny = last_data["story_destiny"] R.current_standard_HP = last_data["current_standard_HP"] R.current_standard_damage = last_data["current_standard_damage"] R.current_standard_speed = last_data["current_standard_speed"] R.current_standard_defense = last_data["current_standard_defense"] R.current_standard_bomb = last_data["current_standard_bomb"] R.se_district = last_data["se_district"] R.battle_district = last_data["battle_district"] R.monster_defense_delta = last_data["monster_defense_delta"] R.monster_HP_rate = last_data["monster_HP_rate"] R.player_bomb_self_damage_reduce_rate = last_data["player_bomb_self_damage_reduce_rate"] R.slow_immune = last_data["slow_immune"] R.reverse_immune = last_data["reverse_immune"] R.root_immune = last_data["root_immune"] R.stun_immune = last_data["stun_immune"] R.random_dmg = last_data["random_dmg"] R.show_cursor = last_data["show_cursor"] R.last_item = last_data["items"] if os.path.exists(last_path): os.remove(last_path) print("已读取,清除数据!!!!!!!!!!!!!") else: print("???") control.Control(is_continue=True) # 任务系统 def button_task_start(self): self.master.destroy() app_task = tk.Tk() rougetask.Task(app_task) # 选择皮肤 def button_setting_start(self): self.master.destroy() app_setting = tk.Tk() rougesetting.Setting(app_setting) # 通用英雄 def button_choose_hero(self, hero): self.current_hero = hero with open("config.json", "r", encoding="utf-8") as json_file: mapsetdata = json.load(json_file) mapsetdata["map_set"] = "rogueMapSet" mapsetdata["your_hero"] = hero with open("config.json", "w", encoding="utf-8") as json_file: json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False) if hero == "Random": self.button0.config(text="进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: 随机)") print("已选择随机") else: self.button0.config(text="进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: " + self.hero_dic[self.current_hero] + ")") print("已选择" + hero) # 选择难度 def button_choose_diff(self, diff): self.current_difficulty = diff R.difficulty = self.current_difficulty with open("config.json", "r", encoding="utf-8") as json_file: mapsetdata = json.load(json_file) mapsetdata["map_set"] = "rogueMapSet" with open("config.json", "w", encoding="utf-8") as json_file: json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False) if self.current_hero == "Random": self.button0.config(text=f"进入游戏 \n (当前难度: {self.diff_dic[self.current_difficulty]}; 当前英雄: 随机)") print("已选择随机") else: self.button0.config(text=f"进入游戏 \n (当前难度: {self.diff_dic[self.current_difficulty]}; 当前英雄: {self.hero_dic[self.current_hero]})") print("已选择" + diff) def show_prompt(): """显示提示框,询问用户如何操作""" import tkinter as tk from tkinter import messagebox def close_existing(): root.destroy() sys.exit() root = tk.Tk() root.withdraw() # 隐藏主窗口 if messagebox.askyesno("进程已打开", "已有一个游戏进程正在运行。请关闭后再运行!"): close_existing() # 获取所有窗口句柄 def get_all_windows(): windows = [] def enum_windows_proc(hwnd, _): if win32gui.IsWindowVisible(hwnd): window_text = win32gui.GetWindowText(hwnd) if window_text: windows.append(window_text) return True win32gui.EnumWindows(enum_windows_proc, None) return windows # 检测窗口是否存在 def check_window_exists(): windows = get_all_windows() # print(windows) for window in windows: if "QQTRogue" in window and "永恒" in window and "100の雨女" in window and "756422783" in window and "擅自售卖皆属剽窃" in window: return True return False if __name__ == "__main__": # # 定义日志文件路径 # # log_file_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "program.log") # log_file_path = os.path.join(os.getcwd(), "program.log") # # 打开日志文件并重定向 stdout # log_file = open(log_file_path, 'a', encoding='utf-8') # 'a' 是追加模式 # # 重定向 sys.stdout(print 函数输出) # sys.stdout = log_file # # 重定向 sys.stderr(报错信息) # sys.stderr = log_file print("=========== start ==============") if check_window_exists(): show_prompt() root = tk.Tk() app = App(root) root.mainloop()