roguetest.py 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. import random
  2. import json
  3. import os
  4. # import psutil
  5. import win32gui
  6. import tkinter as tk
  7. import sys
  8. import logging
  9. import rougetask
  10. import rougesetting
  11. # import cProfile
  12. import requests
  13. from datetime import datetime, timedelta
  14. # from memory_profiler import profile
  15. # import easygui as eg
  16. from game import control
  17. from game.algo import rougeGen
  18. from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
  19. from game.algo import utils as util
  20. from game.const import rouge as R
  21. from game.const import game as G
  22. current_folder_path = os.getcwd()
  23. def current_lv(lv):
  24. lv_list = R.lv_list
  25. if lv >= sum(lv_list):
  26. return "--"
  27. for k in range(0,14):
  28. if sum(lv_list[:k]) <= lv < sum(lv_list[:k+1]):
  29. return str(sum(lv_list[:k+1])-lv)
  30. def check_rouge_ob_data(data):
  31. hero_data_dic = {
  32. "Fox": {"exp": 0, "lv": 1}, "Boboli": {"exp": 0, "lv": 1}, "Naruto_old": {"exp": 0, "lv": 1},
  33. "Asha": {"exp": 0, "lv": 1}, "Maria": {"exp": 0, "lv": 1}, "Surprise": {"exp": 0, "lv": 1}
  34. }
  35. err_cnt = 0
  36. for k, v in hero_data_dic.items():
  37. if k not in data.keys():
  38. data[k] = v
  39. err_cnt += 1
  40. print(f"缺失{k}数据, 正在补充...")
  41. if err_cnt > 0:
  42. save_encrypt_single_rouge_file(data, "rougeOB")
  43. class App:
  44. def __init__(self, master):
  45. self.master = master
  46. master.geometry("960x640")
  47. master.configure(bg='#7E587E')
  48. master.title("QQTRogue二测β2.3.1(底层逻辑:永恒; 肉鸽算法开发与设计:100の雨女; 唯一官方群756422783免费下载; 擅自售卖皆属剽窃!)")
  49. rougeOB_data = {}
  50. rougeOB_achivements = []
  51. self.current_hero = "Fox"
  52. self.current_difficulty = "Easy"
  53. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  54. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  55. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  56. rouge_file_path = os.path.join(qqtpve_folder, "rougeOB.rougedata") # 构建文件路径
  57. rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
  58. old_file_path = os.path.join(qqtpve_folder, "rouge.json") # 构建文件路径
  59. old_achivements_file_path = os.path.join(qqtpve_folder, "rouge_achievement.json") # 构建成就文件路径
  60. rouge_task_file_path = os.path.join(qqtpve_folder, "rougeOB_task.rougedata") # 构建任务文件路径
  61. last_game_file_path = os.path.join(qqtpve_folder, "rougeOBLastGame.rougedata") # 构建存档文件路径
  62. other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
  63. # 杂项第一次打开
  64. if not os.path.exists(other_file_path):
  65. rougeOB_other_data = {"Bomb": [],
  66. "Pet": [],
  67. "Hat": [],
  68. "LastRandom": 0,
  69. "Other": []}
  70. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  71. # 正常打开
  72. else:
  73. rougeOB_other_data = load_rouge_data(other_file_path)
  74. if 'Cursor_Skin' not in rougeOB_other_data.keys():
  75. rougeOB_other_data['Cursor_Skin'] = "fire_cursor"
  76. R.cursor_skin = "fire_cursor"
  77. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  78. else:
  79. R.cursor_skin = rougeOB_other_data['Cursor_Skin']
  80. if 'Bomb_Skin' not in rougeOB_other_data.keys():
  81. rougeOB_other_data['Bomb_Skin'] = "bomb1"
  82. R.bomb_skin = "bomb1"
  83. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  84. else:
  85. R.bomb_skin = rougeOB_other_data['Bomb_Skin']
  86. # 第一次打开
  87. if not os.path.exists(rouge_task_file_path):
  88. rougeOB_task_data = {"1": {"task": "击杀5只命运维系者", "reward": "800经验", "process": 0, "finish": 5, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  89. "2": {"task": "击杀3只渊烬龙王", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  90. "3": {"task": "到达3-1十次", "reward": "800经验", "process": 0, "finish": 10, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  91. "4": {"task": "击杀5只因果阅律者", "reward": "800经验", "process": 0, "finish": 5, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  92. "5": {"task": "完成20次挑衅敌人", "reward": "800经验", "process": 0, "finish": 20, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  93. "6": {"task": "使用小倩到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  94. "7": {"task": "使用波波丽到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  95. "8": {"task": "使用火影到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  96. "9": {"task": "使用阿莎到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  97. "10": {"task": "使用玛莉亚到达3-5三次", "reward": "800经验", "process": 0, "finish": 3, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  98. "11": {"task": "到达4-1一次", "reward": "800经验", "process": 0, "finish": 1, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  99. "12": {"task": "累积使用20次复活卡", "reward": "800经验", "process": 0, "finish": 20, "last_finish": 1970, "reward_exp": 800, "hero": "Fox", "rewarded": True},
  100. "today": {"task": "进行一盘游戏并到达2-1", "reward": "50经验", "process": 0, "finish": 1, "last_finish": "1970-1-1", "reward_exp": 50, "hero": "Fox", "rewarded": True}}
  101. save_encrypt_single_rouge_file(rougeOB_task_data, "rougeOB_task")
  102. # 正常打开
  103. else:
  104. rougeOB_task_data = load_rouge_data(rouge_task_file_path)
  105. now = datetime.now()
  106. # 格式化年月日
  107. year = now.strftime("%Y")
  108. month = now.strftime("%m")
  109. day = now.strftime("%d")
  110. # 移除月份和日期的前导零(如果有)
  111. month = month.lstrip("0")
  112. day = day.lstrip("0")
  113. R.today_datetime["year"] = int(year)
  114. R.today_datetime["month"] = int(month)
  115. R.today_datetime["day"] = int(day)
  116. try:
  117. if len(rougeOB_task_data[str(month)]["last_finish"]) > 4: # 防一手格式错误
  118. rougeOB_task_data[str(month)]["last_finish"] = rougeOB_task_data[str(month)]["last_finish"][0:4]
  119. except:
  120. pass
  121. if int(rougeOB_task_data[str(month)]["last_finish"]) < int(year):
  122. rougeOB_task_data[str(month)]["process"] = 0
  123. rougeOB_task_data[str(month)]["last_finish"] = year
  124. rougeOB_task_data[str(month)]["rewarded"] = False
  125. if rougeOB_task_data["today"]["last_finish"] != year + "-" + month + "-" + day:
  126. rougeOB_task_data["today"]["process"] = 0
  127. rougeOB_task_data["today"]["last_finish"] = year + "-" + month + "-" + day
  128. rougeOB_task_data["today"]["rewarded"] = False
  129. save_encrypt_single_rouge_file(rougeOB_task_data, "rougeOB_task")
  130. # 第一次打开
  131. if not os.path.exists(rouge_file_path):
  132. # 若参与过第一轮beta测试
  133. if os.path.exists(old_file_path):
  134. # 备份旧文件
  135. old_json = load_json(old_file_path)
  136. rougeOB_data = {"Fox": {"exp": old_json["Fox"]["exp"], "lv": old_json["Fox"]["lv"]},
  137. "Boboli": {"exp": old_json["Boboli"]["exp"], "lv": old_json["Boboli"]["exp"]},
  138. "Naruto_old": {"exp": 0, "lv": 1},
  139. "Asha": {"exp": old_json["Naruto_old"]["exp"], "lv": old_json["Naruto_old"]["exp"]},
  140. "Maria": {"exp": 0, "lv": 1},
  141. "Surprise": {"exp": 0, "lv": 1}}
  142. print("等级数据继承成功")
  143. else:
  144. rougeOB_data = {
  145. "Fox": {"exp": 0, "lv": 1},
  146. "Boboli": {"exp": 0, "lv": 1},
  147. "Naruto_old": {"exp": 0, "lv": 1},
  148. "Asha": {"exp": 0, "lv": 1},
  149. "Maria": {"exp": 0, "lv": 1},
  150. "Surprise": {"exp": 0, "lv": 1}
  151. }
  152. save_encrypt_single_rouge_file(rougeOB_data, "rougeOB")
  153. # 正常打开
  154. else:
  155. rougeOB_data = load_rouge_data(rouge_file_path)
  156. # =========================================================================================
  157. util.load_online_config()
  158. if G.UID == "" and G.USERNAME == "":
  159. # username = input("请输入昵称: ").strip()
  160. # password = input("请输入密码: ").strip()
  161. util.register()
  162. new_info = rougeOB_data
  163. new_info["record"] = "null"
  164. result = util.update_profile(G.UID, new_info, G.PASSWORD)
  165. print(result.get('message', '未知错误'))
  166. is_online = util.try_login()
  167. if is_online:
  168. rougeOB_data = util.get_online_data()
  169. # =========================================================================================
  170. check_rouge_ob_data(rougeOB_data)
  171. print(rougeOB_data)
  172. for hero in ["Fox", "Boboli", "Naruto_old", "Asha", "Maria"]:
  173. rougeOB_data[hero]["lv"] = R.current_lv(rougeOB_data[hero]["exp"])
  174. Fox_info = "小倩: 等级"+str(rougeOB_data["Fox"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Fox"]["exp"]) + ", 技能: 自身血量减少1则糖泡伤害增加"+str(R.FoxSkill(rougeOB_data["Fox"]["lv"]))
  175. Boboli_info = "波波丽: 等级"+str(rougeOB_data["Boboli"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Boboli"]["exp"]) + ", 技能: 每次攻击额外造成"+str(int(R.BoboliSkill(rougeOB_data["Boboli"]["lv"])*100))+"%真实伤害"
  176. 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))+"%"
  177. Asha_info = "阿莎: 等级"+str(rougeOB_data["Asha"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Asha"]["exp"]) + ", 技能: 每次糖泡造成伤害恢复血量"+str(R.AshaSkill(rougeOB_data["Asha"]["lv"])*100)+"%"
  178. 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"]))+"防御"
  179. # 第一次打开
  180. if not os.path.exists(rouge_achivements_file_path):
  181. # 若参与过第一轮beta测试
  182. '''
  183. if os.path.exists(old_achivements_file_path):
  184. # 备份旧文件
  185. old_achivements_json = load_json(old_achivements_file_path)
  186. rougeOB_achivements = old_achivements_json
  187. print("成就数据继承成功")
  188. else:
  189. rougeOB_achivements = []
  190. '''
  191. rougeOB_achivements = []
  192. save_encrypt_single_rouge_file(rougeOB_achivements, "rougeOB_achievement")
  193. # 正常打开
  194. else:
  195. rougeOB_achivements = load_rouge_data(rouge_achivements_file_path)
  196. # for ch in rougeOB_achivements:
  197. # print(ch)
  198. max_level = 0
  199. max_level_hero = "Fox"
  200. max_diff = "Easy"
  201. max_diff_num = 1
  202. self.hero_dic= {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"}
  203. self.diff_dic = {"Easy": "简单", "Normal": "困难", "Hell": "炼狱", "Hell+": "炼狱+"}
  204. diff_num = {"Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4}
  205. diff_status = {"Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
  206. for data in rougeOB_achivements:
  207. if diff_num[data["DIFF"]] > max_diff_num:
  208. max_level = data["CL"]
  209. max_level_hero = data["HERO"]
  210. max_diff = data["DIFF"]
  211. max_diff_num = diff_num[data["DIFF"]]
  212. if diff_num[data["DIFF"]] == max_diff_num:
  213. if data["CL"] > max_level:
  214. max_level = data["CL"]
  215. max_level_hero = data["HERO"]
  216. if data["CL"] == 20:
  217. diff_status[data["DIFF"]] = 2
  218. if max_level > 0:
  219. 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]
  220. else:
  221. record_text = "暂无挑战记录"
  222. if max_diff == "Hell+":
  223. R.pass_status["Easy"] = 1
  224. R.pass_status["Normal"] = 1
  225. R.pass_status["Hell"] = 1
  226. if max_level >= 15:
  227. R.pass_status["Hell+"] = 1
  228. elif max_diff == "Hell":
  229. R.pass_status["Easy"] = 1
  230. R.pass_status["Normal"] = 1
  231. # R.cursor_skin = "fire_cursor_kubi"
  232. if max_level >= 15:
  233. R.pass_status["Hell"] = 1
  234. # R.cursor_skin = "fire_cursor_gold_kubi"
  235. elif max_diff == "Normal":
  236. R.pass_status["Easy"] = 1
  237. # R.cursor_skin = "fire_cursor2"
  238. if max_level >= 15:
  239. R.pass_status["Normal"] = 1
  240. # R.cursor_skin = "fire_cursor_kubi"
  241. else:
  242. if max_level >= 15:
  243. R.pass_status["Easy"] = 1
  244. # R.cursor_skin = "fire_cursor2"
  245. for dif in ["Easy","Normal","Hell","Hell+"]:
  246. if diff_status[dif] == 2:
  247. R.pass_status[dif] = 2
  248. # 开始游戏
  249. 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))
  250. self.button0.place(relx=0.5, rely=0.29, anchor='center')
  251. # 继续游戏
  252. if os.path.exists(last_game_file_path):
  253. last_game_file = load_rouge_data(last_game_file_path)
  254. 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"]] + ")",
  255. command=lambda: self.button_continue(last_game_file, last_game_file_path), bg="#C68E17", font=("Microsoft YaHei", 18))
  256. self.button000.place(relx=0.5, rely=0.44, anchor='center')
  257. # 任务系统
  258. self.button_task = tk.Button(master, text= "任务系统", command=lambda: self.button_task_start(), bg="#C68E17", font=("Microsoft YaHei", 24))
  259. self.button_task.place(relx=0.16, rely=0.16, anchor='center')
  260. # 选择皮肤
  261. self.button_task = tk.Button(master, text= "陈列馆", command=lambda: self.button_setting_start(), bg="#C68E17", font=("Microsoft YaHei", 18))
  262. self.button_task.place(relx=0.16, rely=0.28, anchor='center')
  263. # 选择简单
  264. self.button_easy = tk.Button(master, text="● 选择简单难度", command=lambda: self.button_choose_diff("Easy"), bg="#C47451", font=("Microsoft YaHei", 12))
  265. self.button_easy.place(relx=0.75, rely=0.1, anchor='w')
  266. # 选择普通
  267. if max_diff in ["Normal", "Hell", "Hell+"] or max_level >= 15:
  268. self.button_normal = tk.Button(master, text="● 选择困难难度", command=lambda: self.button_choose_diff("Normal"), bg="#C47451", font=("Microsoft YaHei", 12))
  269. self.button_normal.place(relx=0.75, rely=0.18, anchor='w')
  270. # 选择随机
  271. if abs(60*datetime.now().hour+datetime.now().minute - int(rougeOB_other_data["LastRandom"])) >= 3:
  272. self.button5 = tk.Button(master, text="● 随机开局", command=lambda: self.button_choose_hero("Random"), bg="#C47451", font=("Microsoft YaHei", 12))
  273. self.button5.place(relx=0.07, rely=0.95, anchor='w')
  274. else:
  275. self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12))
  276. self.button5.place(relx=0.07, rely=0.95, anchor='w')
  277. # 提示用
  278. if abs(60*datetime.now().hour+datetime.now().minute - rougeOB_other_data["LastRandom"]) >= 3:
  279. self.button109 = tk.Button(master, text="随机选择上列英雄,并获得<引路人>(本选项冷却时间3分钟)", bg="#E6A9EC", font=("Microsoft YaHei", 12))
  280. self.button109.place(relx=0.2, rely=0.95, anchor='w')
  281. else:
  282. last_time = rougeOB_other_data["LastRandom"]
  283. self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(选项冷却中-下次开启-"+ f"{((last_time + 3) // 60) % 24:02d}:{(last_time + 3) % 60:02d}" +")", bg="#E6A9EC", font=("Microsoft YaHei", 12))
  284. self.button109.place(relx=0.2, rely=0.95, anchor='w')
  285. else:
  286. self.button_normal = tk.Button(master, text="○ 困难难度(通关简单后解锁)", bg="#614051", font=("Microsoft YaHei", 12))
  287. self.button_normal.place(relx=0.75, rely=0.18, anchor='w')
  288. # 选择随机
  289. self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12))
  290. self.button5.place(relx=0.07, rely=0.95, anchor='w')
  291. self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(通关一次简单难度后开启)", bg="#E6A9EC", font=("Microsoft YaHei", 12))
  292. self.button109.place(relx=0.2, rely=0.95, anchor='w')
  293. # 选择炼狱
  294. if max_diff in ["Hell", "Hell+"] or (max_diff == "Normal" and max_level >= 15):
  295. self.button_hell = tk.Button(master, text="● 选择炼狱难度", command=lambda: self.button_choose_diff("Hell"), bg="#C47451", font=("Microsoft YaHei", 12))
  296. self.button_hell.place(relx=0.75, rely=0.26, anchor='w')
  297. else:
  298. self.button_hell = tk.Button(master, text="○ 炼狱难度(通关困难后解锁)", bg="#614051", font=("Microsoft YaHei", 12))
  299. self.button_hell.place(relx=0.75, rely=0.26, anchor='w')
  300. # 选择炼狱+
  301. if max_diff == "Hell+" or (max_diff == "Hell" and max_level >= 15):
  302. self.button_hell_plus = tk.Button(master, text="● 选择炼狱+难度", command=lambda: self.button_choose_diff("Hell+"), bg="#C47451", font=("Microsoft YaHei", 12))
  303. self.button_hell_plus.place(relx=0.75, rely=0.34, anchor='w')
  304. else:
  305. self.button_hell_plus = tk.Button(master, text="○ 炼狱+难度(通关炼狱后解锁)", bg="#614051", font=("Microsoft YaHei", 12))
  306. self.button_hell_plus.place(relx=0.75, rely=0.34, anchor='w')
  307. # 选择Fox
  308. self.button1 = tk.Button(master, text="● 选择小倩", command=lambda: self.button_choose_hero("Fox"), bg="#C47451", font=("Microsoft YaHei", 12))
  309. self.button1.place(relx=0.07, rely=0.65, anchor='w')
  310. # 选择Boboli
  311. self.button2 = tk.Button(master, text="● 选择波波丽", command=lambda: self.button_choose_hero("Boboli"), bg="#C47451", font=("Microsoft YaHei", 12))
  312. self.button2.place(relx=0.07, rely=0.71, anchor='w')
  313. # 选择Naruto_old
  314. self.button3 = tk.Button(master, text="● 选择火影", command=lambda: self.button_choose_hero("Naruto_old"), bg="#C47451", font=("Microsoft YaHei", 12))
  315. self.button3.place(relx=0.07, rely=0.77, anchor='w')
  316. # 选择Asha
  317. self.button4 = tk.Button(master, text="● 选择阿莎", command=lambda: self.button_choose_hero("Asha"), bg="#C47451", font=("Microsoft YaHei", 12))
  318. self.button4.place(relx=0.07, rely=0.83, anchor='w')
  319. # 选择Maria
  320. self.button5 = tk.Button(master, text="● 选择玛莉亚", command=lambda: self.button_choose_hero("Maria"), bg="#C47451", font=("Microsoft YaHei", 12))
  321. self.button5.place(relx=0.07, rely=0.89, anchor='w')
  322. # 选择???
  323. self.button6 = tk.Button(master, text="● 选择???", command=lambda: self.button_choose_hero("Surprise"), bg="#C47451", font=("Microsoft YaHei", 12))
  324. self.button6.place(relx=0.07, rely=0.5, anchor='w')
  325. # 选择随机
  326. # if abs(60*datetime.now().hour+datetime.now().minute - int(rougeOB_other_data["LastRandom"])) >= 3:
  327. # self.button5 = tk.Button(master, text="● 随机开局", command=lambda: self.button_choose_hero("Random"), bg="#C47451", font=("Microsoft YaHei", 12))
  328. # self.button5.place(relx=0.07, rely=0.95, anchor='w')
  329. # else:
  330. # self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12))
  331. # self.button5.place(relx=0.07, rely=0.95, anchor='w')
  332. # 通关成就展示
  333. self.button100 = tk.Button(master, text=record_text, bg="#7E354D", font=("Microsoft YaHei", 14))
  334. self.button100.place(relx=0.5, rely=0.56, anchor='center')
  335. # 提示用
  336. self.button101 = tk.Button(master, text=Fox_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
  337. self.button101.place(relx=0.2, rely=0.65, anchor='w')
  338. # 提示用
  339. self.button102 = tk.Button(master, text=Boboli_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
  340. self.button102.place(relx=0.2, rely=0.71, anchor='w')
  341. # 提示用
  342. self.button103 = tk.Button(master, text=Naruto_old_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
  343. self.button103.place(relx=0.2, rely=0.77, anchor='w')
  344. # 提示用
  345. self.button104 = tk.Button(master, text=Asha_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
  346. self.button104.place(relx=0.2, rely=0.83, anchor='w')
  347. # 提示用
  348. self.button105 = tk.Button(master, text=Maria_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
  349. self.button105.place(relx=0.2, rely=0.89, anchor='w')
  350. # 提示用
  351. # if abs(60*datetime.now().hour+datetime.now().minute - rougeOB_other_data["LastRandom"]) >= 3:
  352. # self.button109 = tk.Button(master, text="随机选择上列英雄,并获得<引路人>(本选项冷却时间3分钟)", bg="#E6A9EC", font=("Microsoft YaHei", 12))
  353. # self.button109.place(relx=0.2, rely=0.95, anchor='w')
  354. # else:
  355. # last_time = rougeOB_other_data["LastRandom"]
  356. # self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(选项冷却中-下次开启-"+ f"{((last_time + 3) // 60) % 24:02d}:{(last_time + 3) % 60:02d}" +")", bg="#E6A9EC", font=("Microsoft YaHei", 12))
  357. # self.button109.place(relx=0.2, rely=0.95, anchor='w')
  358. # 通用开局
  359. def button_general_start(self, hero, difficulty):
  360. if hero == "Random":
  361. hero = random.choice(["Fox","Boboli","Naruto_old","Asha","Maria","Surprise"])
  362. R.show_cursor = True
  363. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  364. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  365. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  366. other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
  367. if not os.path.exists(other_file_path):
  368. rougeOB_other_data = {"Bomb": [],
  369. "Pet": [],
  370. "Hat": [],
  371. "LastRandom": int(60*datetime.now().hour+datetime.now().minute),
  372. "Other": []}
  373. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  374. else:
  375. rougeOB_other_data = load_rouge_data(other_file_path)
  376. rougeOB_other_data["LastRandom"] = int(60*datetime.now().hour+datetime.now().minute)
  377. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  378. with open("config.json", "r", encoding="utf-8") as json_file:
  379. mapsetdata = json.load(json_file)
  380. mapsetdata["map_set"] = "rogueMapSet"
  381. mapsetdata["your_hero"] = hero
  382. R.difficulty = difficulty
  383. with open("config.json", "w", encoding="utf-8") as json_file:
  384. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  385. self.master.destroy()
  386. rougeGen.main_func()
  387. control.Control()
  388. # 读取上次存档
  389. def button_continue(self, last_data, last_path):
  390. self.master.destroy()
  391. R.continuing_game = True
  392. G.CURRENT_LEVEL = last_data["current_level"]
  393. R.map_json_dic = last_data["map_json_dic"]
  394. R.central_mapset = last_data["central_mapset"]
  395. R.difficulty = last_data["difficulty"]
  396. R.today_datetime = last_data["today_datetime"]
  397. R.task_RougeTreasureDestinyElite = last_data["task_RougeTreasureDestinyElite"]
  398. R.task_MineCFireDragonBoss = last_data["task_MineCFireDragonBoss"]
  399. R.task_RougeTreasureDestinyWizard = last_data["task_RougeTreasureDestinyWizard"]
  400. R.task_combat = last_data["task_combat"]
  401. R.task_revival = last_data["task_revival"]
  402. R.rouge_data = last_data["rouge_data"]
  403. R.rouge_hero = last_data["rouge_hero"]
  404. R.rouge_lv = last_data["rouge_lv"]
  405. R.rouge_exp = last_data["rouge_exp"]
  406. R.game_exp = last_data["game_exp"]
  407. R.rouge_story = last_data["rouge_story"]
  408. R.rouge_theme_1 = last_data["rouge_theme_1"]
  409. R.rouge_theme_2 = last_data["rouge_theme_2"]
  410. R.rouge_theme_3 = last_data["rouge_theme_3"]
  411. R.rouge_theme_4 = last_data["rouge_theme_4"]
  412. R.rouge_destiny = last_data["rouge_destiny"]
  413. R.coin = last_data["coin"]
  414. R.general_mon_dic = last_data["general_mon_dic"]
  415. R.story_eden = last_data["story_eden"]
  416. R.story_destiny = last_data["story_destiny"]
  417. R.current_standard_HP = last_data["current_standard_HP"]
  418. R.current_standard_damage = last_data["current_standard_damage"]
  419. R.current_standard_speed = last_data["current_standard_speed"]
  420. R.current_standard_defense = last_data["current_standard_defense"]
  421. R.current_standard_bomb = last_data["current_standard_bomb"]
  422. R.se_district = last_data["se_district"]
  423. R.battle_district = last_data["battle_district"]
  424. R.monster_defense_delta = last_data["monster_defense_delta"]
  425. R.monster_HP_rate = last_data["monster_HP_rate"]
  426. R.player_bomb_self_damage_reduce_rate = last_data["player_bomb_self_damage_reduce_rate"]
  427. R.slow_immune = last_data["slow_immune"]
  428. R.reverse_immune = last_data["reverse_immune"]
  429. R.root_immune = last_data["root_immune"]
  430. R.stun_immune = last_data["stun_immune"]
  431. R.random_dmg = last_data["random_dmg"]
  432. R.show_cursor = last_data["show_cursor"]
  433. R.last_item = last_data["items"]
  434. if os.path.exists(last_path):
  435. os.remove(last_path)
  436. print("已读取,清除数据!!!!!!!!!!!!!")
  437. else:
  438. print("???")
  439. control.Control(is_continue=True)
  440. # 任务系统
  441. def button_task_start(self):
  442. self.master.destroy()
  443. app_task = tk.Tk()
  444. rougetask.Task(app_task)
  445. # 选择皮肤
  446. def button_setting_start(self):
  447. self.master.destroy()
  448. app_setting = tk.Tk()
  449. rougesetting.Setting(app_setting)
  450. # 通用英雄
  451. def button_choose_hero(self, hero):
  452. self.current_hero = hero
  453. with open("config.json", "r", encoding="utf-8") as json_file:
  454. mapsetdata = json.load(json_file)
  455. mapsetdata["map_set"] = "rogueMapSet"
  456. mapsetdata["your_hero"] = hero
  457. with open("config.json", "w", encoding="utf-8") as json_file:
  458. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  459. if hero == "Random":
  460. self.button0.config(text="进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: 随机)")
  461. print("已选择随机")
  462. else:
  463. self.button0.config(text="进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: " + self.hero_dic[self.current_hero] + ")")
  464. print("已选择" + hero)
  465. # 选择难度
  466. def button_choose_diff(self, diff):
  467. self.current_difficulty = diff
  468. R.difficulty = self.current_difficulty
  469. with open("config.json", "r", encoding="utf-8") as json_file:
  470. mapsetdata = json.load(json_file)
  471. mapsetdata["map_set"] = "rogueMapSet"
  472. with open("config.json", "w", encoding="utf-8") as json_file:
  473. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  474. if self.current_hero == "Random":
  475. self.button0.config(text=f"进入游戏 \n (当前难度: {self.diff_dic[self.current_difficulty]}; 当前英雄: 随机)")
  476. print("已选择随机")
  477. else:
  478. self.button0.config(text=f"进入游戏 \n (当前难度: {self.diff_dic[self.current_difficulty]}; 当前英雄: {self.hero_dic[self.current_hero]})")
  479. print("已选择" + diff)
  480. def show_prompt():
  481. """显示提示框,询问用户如何操作"""
  482. import tkinter as tk
  483. from tkinter import messagebox
  484. def close_existing():
  485. root.destroy()
  486. sys.exit()
  487. root = tk.Tk()
  488. root.withdraw() # 隐藏主窗口
  489. if messagebox.askyesno("进程已打开", "已有一个游戏进程正在运行。请关闭后再运行!"):
  490. close_existing()
  491. # 获取所有窗口句柄
  492. def get_all_windows():
  493. windows = []
  494. def enum_windows_proc(hwnd, _):
  495. if win32gui.IsWindowVisible(hwnd):
  496. window_text = win32gui.GetWindowText(hwnd)
  497. if window_text:
  498. windows.append(window_text)
  499. return True
  500. win32gui.EnumWindows(enum_windows_proc, None)
  501. return windows
  502. # 检测窗口是否存在
  503. def check_window_exists():
  504. windows = get_all_windows()
  505. # print(windows)
  506. for window in windows:
  507. if "QQTRogue" in window and "永恒" in window and "100の雨女" in window and "756422783" in window and "擅自售卖皆属剽窃" in window:
  508. return True
  509. return False
  510. if __name__ == "__main__":
  511. # # 定义日志文件路径
  512. # # log_file_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "program.log")
  513. # log_file_path = os.path.join(os.getcwd(), "program.log")
  514. # # 打开日志文件并重定向 stdout
  515. # log_file = open(log_file_path, 'a', encoding='utf-8') # 'a' 是追加模式
  516. # # 重定向 sys.stdout(print 函数输出)
  517. # sys.stdout = log_file
  518. # # 重定向 sys.stderr(报错信息)
  519. # sys.stderr = log_file
  520. print("=========== start ==============")
  521. if check_window_exists():
  522. show_prompt()
  523. root = tk.Tk()
  524. app = App(root)
  525. root.mainloop()