choose_hero_menu.py 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. import pygame
  2. import json
  3. import os
  4. import random
  5. from datetime import datetime
  6. from game.const import game as G
  7. from game.const import window as W
  8. from game.const import rouge as R
  9. from game.sound import sound_player
  10. from game.algo import utils as util
  11. from game.utils import local_data_manager as DM
  12. from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
  13. from game.ui.menu.component import PygameButton, PygameButtonBackIMG, PygameButtonBackIMGRoll, Particle, PygameIMG
  14. def check_rouge_ob_data(data):
  15. hero_data_dic = {
  16. "Fox": {"exp": 0, "lv": 1}, "Boboli": {"exp": 0, "lv": 1}, "Naruto_old": {"exp": 0, "lv": 1},
  17. "Asha": {"exp": 0, "lv": 1}, "Maria": {"exp": 0, "lv": 1}, "Chunli": {"exp": 0, "lv": 1},
  18. "Titan": {"exp": 0, "lv": 1}, "Chris": {"exp": 0, "lv": 1}, "SeaPrince_old": {"exp": 0, "lv": 1},
  19. "Witch": {"exp": 0, "lv": 1}, "Surprise": {"exp": 0, "lv": 1}
  20. }
  21. err_cnt = 0
  22. for k, v in hero_data_dic.items():
  23. if k not in data.keys():
  24. data[k] = v
  25. err_cnt += 1
  26. print(f"缺失{k}数据, 正在补充...")
  27. if err_cnt > 0:
  28. save_encrypt_single_rouge_file(data, "rougeOB")
  29. return data
  30. current_folder_path = os.getcwd()
  31. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  32. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  33. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  34. rouge_file_path = os.path.join(qqtpve_folder, "rougeOB.rougedata") # 构建文件路径
  35. rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
  36. rougeOB_data = load_rouge_data(rouge_file_path)
  37. if G.IS_ONLINE:
  38. rougeOB_data = util.get_online_data()
  39. rougeOB_data = check_rouge_ob_data(rougeOB_data)
  40. def current_lv(lv):
  41. lv_list = R.lv_list
  42. if lv >= sum(lv_list):
  43. return "--"
  44. for k in range(0, 14):
  45. if sum(lv_list[:k]) <= lv < sum(lv_list[:k + 1]):
  46. return str(sum(lv_list[:k + 1]) - lv)
  47. diff_cn = {
  48. "练习": "Baby",
  49. "简单": "Easy",
  50. "困难": "Normal",
  51. "炼狱": "Hell",
  52. "炼狱+": "Hell+",
  53. }
  54. # diff_HP = {"Easy": 0.7, "Normal": 1, "Hell": 1.2, "Hell+": 1.3}
  55. # diff_Delta_Defense = {"Easy": -1200, "Normal": 0, "Hell": 800, "Hell+": 1000}
  56. # diff_speed = {"Easy": 0.9, "Normal": 1, "Hell": 1.05, "Hell+": 1.08}
  57. # diff_contact = {"Easy": 0.7, "Normal": 1, "Hell": 1.2, "Hell+": 1.3}
  58. # diff_exp = {"Easy": 1, "Normal": 1.5, "Hell": 2.2, "Hell+": 3}
  59. diff_dict = {
  60. "Baby": {"unlock": 1, "name": "练习", "info": f"经验效率{int(R.diff_exp['Baby']*100)}%, 怪物血量-50%, 防御-2000", "condition": "纯新手练习难度"},
  61. "Easy": {"unlock": 1, "name": "简单", "info": f"经验效率{int(R.diff_exp['Easy']*100)}%, 怪物血量-30%, 防御-1200", "condition": "最初的起点"},
  62. "Normal": {"unlock": R.pass_status["Easy"], "name": "困难", "info": f"经验效率{int(R.diff_exp['Normal']*100)}%, 怪物血量+0%, 防御+0", "condition": "通关简单难度解锁"},
  63. "Hell": {"unlock": R.pass_status["Normal"], "name": "炼狱", "info": f"经验效率{int(R.diff_exp['Hell']*100)}%, 怪物血量+20%, 防御+800", "condition": "通关困难难度解锁"},
  64. "Hell+": {"unlock": R.pass_status["Hell"], "name": "炼狱+", "info": f"经验效率{int(R.diff_exp['Hell+']*100)}%, 怪物血量+30%, 防御+1000", "condition": "通关炼狱难度解锁"},
  65. }
  66. diff_list = ["练习", "简单", "困难", "炼狱", "炼狱+"]
  67. hero_cn = {
  68. "小倩": "Fox",
  69. "波波丽": "Boboli",
  70. "火影": "Naruto_old",
  71. "阿莎": "Asha",
  72. "玛莉亚": "Maria",
  73. "春丽": "Chunli",
  74. "泰坦": "Titan",
  75. "克莉斯": "Chris",
  76. "海王子": "SeaPrince_old",
  77. "随机": "Random",
  78. }
  79. hero_dict = {
  80. "Fox": {
  81. "own": True, "name": "小倩",
  82. "exp": f"等级{rougeOB_data['Fox']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Fox']['exp'])}",
  83. "info": f"技能: 自身血量减少1则糖泡伤害增加{R.FoxSkill(rougeOB_data['Fox']['lv'])}",
  84. "growth": f"成长: 血量: {R.growth['Fox']['HP']}, 伤害: {R.growth['Fox']['Damage']}",
  85. "img": pygame.image.load(r"res/img/ui/game/icon_xq.png").convert_alpha()
  86. },
  87. "Boboli": {
  88. "own": True, "name": "波波丽",
  89. "exp": f"等级{rougeOB_data['Boboli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Boboli']['exp'])}",
  90. "info": f"技能: 每次攻击额外造成{int(R.BoboliSkill(rougeOB_data['Boboli']['lv']) * 100)}%真实伤害",
  91. "growth": f"成长: 血量: {R.growth['Boboli']['HP']}, 伤害: {R.growth['Boboli']['Damage']}",
  92. "img": pygame.image.load(r"res/img/ui/game/icon_bbl.png").convert_alpha()
  93. },
  94. "Naruto_old": {
  95. "own": True, "name": "火影",
  96. "exp": f"等级{rougeOB_data['Naruto_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Naruto_old']['exp'])}",
  97. "info": f"技能: 首次攻击每只怪物时攻击力变为{int(R.Naruto_oldSkill(rougeOB_data['Naruto_old']['lv']) * 100)}%",
  98. "growth": f"成长: 血量: {R.growth['Naruto_old']['HP']}, 伤害: {R.growth['Naruto_old']['Damage']}",
  99. "img": pygame.image.load(r"res/img/ui/game/icon_hy.png").convert_alpha()
  100. },
  101. "Asha": {
  102. "own": True, "name": "阿莎",
  103. "exp": f"等级{rougeOB_data['Asha']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Asha']['exp'])}",
  104. "info": f"技能: 每次糖泡造成伤害恢复血量{R.AshaSkill(rougeOB_data['Asha']['lv']) * 100}%",
  105. "growth": f"成长: 血量: {R.growth['Asha']['HP']}, 伤害: {R.growth['Asha']['Damage']}",
  106. "img": pygame.image.load(r"res/img/ui/game/icon_as.png").convert_alpha()
  107. },
  108. "Maria": {
  109. "own": True, "name": "玛莉亚",
  110. "exp": f"等级{rougeOB_data['Maria']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Maria']['exp'])}",
  111. "info": f"技能: 每次造成伤害降低怪物{R.MariaSkill2(rougeOB_data['Maria']['lv'])}防御",
  112. "growth": f"成长: 血量: {R.growth['Maria']['HP']}, 伤害: {R.growth['Maria']['Damage']}",
  113. "img": pygame.image.load(r"res/img/ui/game/icon_mly.png").convert_alpha()
  114. },
  115. "Chunli": {
  116. "own": True, "name": "春丽",
  117. "exp": f"等级{rougeOB_data['Chunli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chunli']['exp'])}",
  118. "info": f"技能: 每{R.ChunliSkill(rougeOB_data['Chunli']['lv'])}个糖泡放置一个双倍伤害超级糖泡",
  119. "growth": f"成长: 血量: {R.growth['Chunli']['HP']}, 伤害: {R.growth['Chunli']['Damage']}",
  120. "img": pygame.image.load(r"res/img/ui/game/icon_cl.png").convert_alpha()
  121. },
  122. "Titan": {
  123. "own": True, "name": "泰坦",
  124. "exp": f"等级{rougeOB_data['Titan']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Titan']['exp'])}",
  125. "info": f"技能: 初始获得{R.TitanSkill(rougeOB_data['Titan']['lv'])}防御",
  126. "growth": f"成长: 血量: {R.growth['Titan']['HP']}, 伤害: {R.growth['Titan']['Damage']}",
  127. "img": pygame.image.load(r"res/img/ui/game/icon_tt.png").convert_alpha()
  128. },
  129. "Chris": {
  130. "own": True, "name": "克莉斯",
  131. "exp": f"等级{rougeOB_data['Chris']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chris']['exp'])}",
  132. "info": f"技能: 灵净{R.ChrisLvSkill(rougeOB_data['Chris']['lv'])}(怪物死后变为光灵协同净化升华)", # 变身光灵, 自动寻敌(区域中)造成3x3 200%伤害, 无击杀则消失, 若无怪物目标则返回克莉丝处恢复1%生命
  133. "growth": f"成长: 血量: {R.growth['Chris']['HP']}, 伤害: {R.growth['Chris']['Damage']}",
  134. "img": pygame.image.load(r"res/img/ui/game/icon_kls.png").convert_alpha()
  135. },
  136. "SeaPrince_old": {
  137. "own": True, "name": "海王子",
  138. "exp": f"等级{rougeOB_data['SeaPrince_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['SeaPrince_old']['exp'])}",
  139. "info": f"技能: 初始糖币+{R.SeaPrinceSkill1(rougeOB_data['SeaPrince_old']['lv'])}, 每持有1糖币伤害增加{R.SeaPrinceSkill2(rougeOB_data['SeaPrince_old']['lv'])}",
  140. "growth": f"成长: 血量: {R.growth['SeaPrince_old']['HP']}, 伤害: {R.growth['SeaPrince_old']['Damage']}",
  141. "img": pygame.image.load(r"res/img/ui/game/icon_hwz.png").convert_alpha()
  142. },
  143. "Random": {
  144. "own": False, "name": "随机",
  145. "exp": f"--",
  146. "info": f"随机选择一个英雄(含隐藏角色)与引路人",
  147. "growth": f"--",
  148. "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
  149. },
  150. "Surprise": {
  151. "own": True, "name": "随机",
  152. "exp": f"--",
  153. "info": f"随机选择一个英雄(含隐藏角色)与引路人",
  154. "growth": f"--",
  155. "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
  156. },
  157. "Witch": {
  158. "own": True, "name": "嫦娥",
  159. "exp": f"等级{rougeOB_data['Witch']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Witch']['exp'])}",
  160. "info": f"[限时体验]",
  161. "growth": f"成长: 血量: {R.growth['Witch']['HP']}, 伤害: {R.growth['Witch']['Damage']}",
  162. "img": pygame.image.load(r"res/img/ui/game/icon_witch.png").convert_alpha()
  163. },
  164. }
  165. hero_list = ["小倩", "波波丽", "火影", "阿莎", "玛莉亚", "春丽", "泰坦", "克莉斯", "海王子", "随机"]
  166. random_hero_list = ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Chunli", "Titan", "Chris", "SeaPrince_old"] + ["Witch"]*9 + ["Surprise"]*9
  167. # random_hero_list = ["Surprise"]
  168. # ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Surprise"]
  169. # {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"}
  170. def reload_data():
  171. global rougeOB_data, diff_dict, hero_dict
  172. rougeOB_data = load_rouge_data(rouge_file_path)
  173. if G.IS_ONLINE:
  174. rougeOB_data = util.get_online_data()
  175. rougeOB_data = check_rouge_ob_data(rougeOB_data)
  176. rougeOB_achievements = load_rouge_data(rouge_achivements_file_path)
  177. max_level = 0
  178. max_diff = "Easy"
  179. diff_status = {"Baby": 1, "Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
  180. if rougeOB_achievements["Highest"]["level"] != "":
  181. max_level = rougeOB_achievements["Highest"]["level"]
  182. if rougeOB_achievements["Highest"]["diff"] != "":
  183. max_diff = rougeOB_achievements["Highest"]["diff"]
  184. if max_level == 20:
  185. diff_status[max_diff] = 2
  186. if max_diff == "Hell+":
  187. R.pass_status["Easy"] = 1
  188. R.pass_status["Normal"] = 1
  189. R.pass_status["Hell"] = 1
  190. if max_level >= 15:
  191. R.pass_status["Hell+"] = 1
  192. elif max_diff == "Hell":
  193. R.pass_status["Easy"] = 1
  194. R.pass_status["Normal"] = 1
  195. if max_level >= 15:
  196. R.pass_status["Hell"] = 1
  197. elif max_diff == "Normal":
  198. R.pass_status["Easy"] = 1
  199. if max_level >= 15:
  200. R.pass_status["Normal"] = 1
  201. else:
  202. if max_level >= 15:
  203. R.pass_status["Easy"] = 1
  204. for dif in ["Easy", "Normal", "Hell", "Hell+"]:
  205. if diff_status[dif] == 2:
  206. R.pass_status[dif] = 2
  207. diff_dict = {
  208. "Baby": {"unlock": 1, "name": "练习", "info": f"经验效率{int(R.diff_exp['Baby']*100)}%, 怪物血量-50%, 防御-2000", "condition": "纯新手练习难度"},
  209. "Easy": {"unlock": 1, "name": "简单", "info": f"经验效率{int(R.diff_exp['Easy']*100)}%, 怪物血量-30%, 防御-1200", "condition": "最初的起点"},
  210. "Normal": {"unlock": R.pass_status["Easy"], "name": "困难", "info": f"经验效率{int(R.diff_exp['Normal']*100)}%, 怪物血量+0%, 防御+0", "condition": "通关简单难度解锁"},
  211. "Hell": {"unlock": R.pass_status["Normal"], "name": "炼狱", "info": f"经验效率{int(R.diff_exp['Hell']*100)}%, 怪物血量+20%, 防御+800", "condition": "通关困难难度解锁"},
  212. "Hell+": {"unlock": R.pass_status["Hell"], "name": "炼狱+", "info": f"经验效率{int(R.diff_exp['Hell+']*100)}%, 怪物血量+30%, 防御+1000", "condition": "通关炼狱难度解锁"},
  213. }
  214. hero_dict = {
  215. "Fox": {
  216. "own": True, "name": "小倩",
  217. "exp": f"等级{rougeOB_data['Fox']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Fox']['exp'])}",
  218. "info": f"技能: 自身血量减少1则糖泡伤害增加{R.FoxSkill(rougeOB_data['Fox']['lv'])}",
  219. "growth": f"成长: 血量: {R.growth['Fox']['HP']}, 伤害: {R.growth['Fox']['Damage']}",
  220. "img": pygame.image.load(r"res/img/ui/game/icon_xq.png").convert_alpha()
  221. },
  222. "Boboli": {
  223. "own": True, "name": "波波丽",
  224. "exp": f"等级{rougeOB_data['Boboli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Boboli']['exp'])}",
  225. "info": f"技能: 每次攻击额外造成{int(R.BoboliSkill(rougeOB_data['Boboli']['lv']) * 100)}%真实伤害",
  226. "growth": f"成长: 血量: {R.growth['Boboli']['HP']}, 伤害: {R.growth['Boboli']['Damage']}",
  227. "img": pygame.image.load(r"res/img/ui/game/icon_bbl.png").convert_alpha()
  228. },
  229. "Naruto_old": {
  230. "own": True, "name": "火影",
  231. "exp": f"等级{rougeOB_data['Naruto_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Naruto_old']['exp'])}",
  232. "info": f"技能: 首次攻击每只怪物时攻击力变为{int(R.Naruto_oldSkill(rougeOB_data['Naruto_old']['lv']) * 100)}%",
  233. "growth": f"成长: 血量: {R.growth['Naruto_old']['HP']}, 伤害: {R.growth['Naruto_old']['Damage']}",
  234. "img": pygame.image.load(r"res/img/ui/game/icon_hy.png").convert_alpha()
  235. },
  236. "Asha": {
  237. "own": True, "name": "阿莎",
  238. "exp": f"等级{rougeOB_data['Asha']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Asha']['exp'])}",
  239. "info": f"技能: 每次糖泡造成伤害恢复血量{R.AshaSkill(rougeOB_data['Asha']['lv']) * 100}%",
  240. "growth": f"成长: 血量: {R.growth['Asha']['HP']}, 伤害: {R.growth['Asha']['Damage']}",
  241. "img": pygame.image.load(r"res/img/ui/game/icon_as.png").convert_alpha()
  242. },
  243. "Maria": {
  244. "own": True, "name": "玛莉亚",
  245. "exp": f"等级{rougeOB_data['Maria']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Maria']['exp'])}",
  246. "info": f"技能: 每次造成伤害降低怪物{R.MariaSkill2(rougeOB_data['Maria']['lv'])}防御",
  247. "growth": f"成长: 血量: {R.growth['Maria']['HP']}, 伤害: {R.growth['Maria']['Damage']}",
  248. "img": pygame.image.load(r"res/img/ui/game/icon_mly.png").convert_alpha()
  249. },
  250. "Chunli": {
  251. "own": True, "name": "春丽",
  252. "exp": f"等级{rougeOB_data['Chunli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chunli']['exp'])}",
  253. "info": f"技能: 每{R.ChunliSkill(rougeOB_data['Chunli']['lv'])}个糖泡放置一个双倍伤害超级糖泡",
  254. "growth": f"成长: 血量: {R.growth['Chunli']['HP']}, 伤害: {R.growth['Chunli']['Damage']}",
  255. "img": pygame.image.load(r"res/img/ui/game/icon_cl.png").convert_alpha()
  256. },
  257. "Titan": {
  258. "own": True, "name": "泰坦",
  259. "exp": f"等级{rougeOB_data['Titan']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Titan']['exp'])}",
  260. "info": f"技能: 初始获得{R.TitanSkill(rougeOB_data['Titan']['lv'])}防御",
  261. "growth": f"成长: 血量: {R.growth['Titan']['HP']}, 伤害: {R.growth['Titan']['Damage']}",
  262. "img": pygame.image.load(r"res/img/ui/game/icon_tt.png").convert_alpha()
  263. },
  264. "Chris": {
  265. "own": True, "name": "克莉斯",
  266. "exp": f"等级{rougeOB_data['Chris']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chris']['exp'])}",
  267. "info": f"技能: 灵净{R.ChrisLvSkill(rougeOB_data['Chris']['lv'])}(怪物死后变为光灵协同净化升华)", # 变身光灵, 自动寻敌(区域中)造成3x3 200%伤害, 无击杀则消失, 若无怪物目标则返回克莉丝处恢复1%生命
  268. "growth": f"成长: 血量: {R.growth['Chris']['HP']}, 伤害: {R.growth['Chris']['Damage']}",
  269. "img": pygame.image.load(r"res/img/ui/game/icon_kls.png").convert_alpha()
  270. },
  271. "SeaPrince_old": {
  272. "own": True, "name": "海王子",
  273. "exp": f"等级{rougeOB_data['SeaPrince_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['SeaPrince_old']['exp'])}",
  274. "info": f"技能: 初始糖币+{R.SeaPrinceSkill1(rougeOB_data['SeaPrince_old']['lv'])}, 每持有1糖币伤害增加{R.SeaPrinceSkill2(rougeOB_data['SeaPrince_old']['lv'])}",
  275. "growth": f"成长: 血量: {R.growth['SeaPrince_old']['HP']}, 伤害: {R.growth['SeaPrince_old']['Damage']}",
  276. "img": pygame.image.load(r"res/img/ui/game/icon_hwz.png").convert_alpha()
  277. },
  278. "Random": {
  279. "own": False, "name": "随机",
  280. "exp": f"--",
  281. "info": f"随机选择一个英雄(含隐藏角色)与引路人",
  282. "growth": f"--",
  283. "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
  284. },
  285. "Surprise": {
  286. "own": True, "name": "随机",
  287. "exp": f"--",
  288. "info": f"随机选择一个英雄(含隐藏角色)与引路人",
  289. "growth": f"--",
  290. "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
  291. },
  292. "Witch": {
  293. "own": True, "name": "嫦娥",
  294. "exp": f"等级{rougeOB_data['Witch']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Witch']['exp'])}",
  295. "info": f"[限时体验]",
  296. "growth": f"成长: 血量: {R.growth['Witch']['HP']}, 伤害: {R.growth['Witch']['Damage']}",
  297. "img": pygame.image.load(r"res/img/ui/game/icon_witch.png").convert_alpha()
  298. },
  299. }
  300. class ChoosePage:
  301. def __init__(self):
  302. self.screen = W.MENU
  303. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  304. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  305. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  306. self.rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
  307. self.other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
  308. self.rougeOB_achievements = {}
  309. self.rougeOB_other_data = {}
  310. self.diff_map = {}
  311. self.is_random = False
  312. self.current_diff = None
  313. self.view_diff = None
  314. self.current_hero = R.rouge_hero
  315. self.diff_num = {"Baby": 1, "Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4}
  316. self.diff_status = {"Baby": 1, "Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
  317. self.max_diff = "Easy"
  318. self.init_choose_page()
  319. self.load_achievements_data()
  320. def init_choose_page(self):
  321. DM.init_achievement()
  322. self.rougeOB_achievements = load_rouge_data(self.rouge_achivements_file_path)
  323. def load_achievements_data(self):
  324. if self.rougeOB_achievements["Highest"]["diff"] != "":
  325. self.max_diff = self.rougeOB_achievements["Highest"]["diff"]
  326. if self.diff_num[self.max_diff] > 1:
  327. hero_dict["Random"]["own"] = True
  328. if self.diff_num[R.difficulty]-1 > self.diff_num[self.max_diff]: # 作弊
  329. print("作弊!!!")
  330. R.difficulty = "Easy"
  331. with open("config.json", "r", encoding="utf-8") as json_file:
  332. mapsetdata = json.load(json_file)
  333. mapsetdata["map_set"] = "rogueMapSet"
  334. mapsetdata["rogue_difficulty"] = "Easy"
  335. with open("config.json", "w", encoding="utf-8") as json_file:
  336. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  337. def draw(self):
  338. self.screen.buttons.clear()
  339. # ================================= 信息展示 =================================
  340. info_button = PygameButton(
  341. self.screen.screen, "", 0.25, 0.47, 18, "#2a2a2a",
  342. fg_color=(215,220,217), action=None,
  343. anchor="center", is_bold=True, fix_shape=(360,120), bg_alpha=159,
  344. frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
  345. )
  346. # ================================= 图片 =================================
  347. cx, cy = 0.35, 0.7
  348. img_button = PygameButtonBackIMG(
  349. self.screen, self.screen.screen, cx, cy, "res/ui/button/img_board.png", "res/ui/button/img_board.png",
  350. action=None, anchor='center', shiny_spark=False
  351. )
  352. img = PygameIMG(self.screen, self.screen.screen, cx, cy, py_img=hero_dict[R.rouge_hero]["img"], anchor='center')
  353. # ================================= 选择 =================================
  354. choose_button = PygameButtonBackIMG(
  355. self.screen, self.screen.screen, 0.13, 0.7, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
  356. action=None, anchor='center'
  357. )
  358. # ================================= 展示框 =================================
  359. cy = 0.2
  360. cx = 0.25
  361. button_blank = 0.13
  362. roll_button = PygameButtonBackIMGRoll(
  363. self.screen, self.screen.screen, cx, cy, "res/ui/button/cursor_board.png", hero_list,
  364. action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
  365. anchor='center', font_name="hk4e_zh-cn.ttf", font_size=24, small_scale=0.7, small_alpha=159, color=(0, 0, 0), shiny_spark=False,
  366. related_button=[info_button, choose_button, img],
  367. notify_action=[
  368. lambda x: hero_update_notify(roll_button, x, self.current_hero),
  369. lambda _: self.update_choose_hero_btn(roll_button, choose_button, info_button),
  370. lambda _: hero_img_update(roll_button, img)
  371. ]
  372. )
  373. # ================================= 初始化 =================================
  374. choose_button.action = lambda: self.choose_hero(roll_button, info_button, choose_button) # 追加action
  375. roll_button.set_current_text(hero_dict[self.current_hero]["name"])
  376. hero_update_notify(roll_button, info_button, self.current_hero)
  377. self.update_choose_hero_btn(roll_button, choose_button, info_button)
  378. # ================================= 添加按钮 =================================
  379. self.screen.buttons.append(info_button)
  380. self.screen.buttons.append(choose_button)
  381. self.screen.buttons.append(roll_button)
  382. self.screen.buttons.append(img_button)
  383. self.screen.buttons.append(img)
  384. # ================================= 上翻页 =================================
  385. self.screen.buttons.append(PygameButtonBackIMG(
  386. self.screen, self.screen.screen, cx, cy-button_blank, "res/ui/button/up.png", "res/ui/button/up_press.png", action=roll_button.roll_up, anchor='center', shiny_spark=False)
  387. )
  388. # ================================= 下翻页 =================================
  389. self.screen.buttons.append(PygameButtonBackIMG(
  390. self.screen, self.screen.screen, cx, cy+button_blank, "res/ui/button/down.png", "res/ui/button/down_press.png", action=roll_button.roll_down, anchor='center', shiny_spark=False)
  391. )
  392. # ===================================================================================
  393. # ===================================================================================
  394. # ===================================================================================
  395. # ================================= 信息展示 =================================
  396. diff_info_button = PygameButton(
  397. self.screen.screen, "", 0.75, 0.47, 18, "#2a2a2a",
  398. fg_color=(215,220,217), action=None,
  399. anchor="center", is_bold=True, fix_shape=(360,100), bg_alpha=159,
  400. frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
  401. )
  402. # ================================= 选择 =================================
  403. diff_choose_button = PygameButtonBackIMG(
  404. self.screen, self.screen.screen, 0.87, 0.22, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
  405. action=None, anchor='center'
  406. )
  407. # ================================= 展示框 =================================
  408. cx, cy = 0.6, 0.2
  409. button_blank = 0.13
  410. diff_roll_button = PygameButtonBackIMGRoll(
  411. self.screen, self.screen.screen, cx, cy, "res/ui/button/cursor_board.png", diff_list,
  412. action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
  413. anchor='center', font_name="hk4e_zh-cn.ttf", font_size=24, small_scale=0.7, small_alpha=159, color=(0, 0, 0), shiny_spark=False,
  414. related_button=[diff_info_button, diff_choose_button],
  415. notify_action=[
  416. lambda x: diff_update_notify(diff_roll_button, x, R.difficulty),
  417. lambda _: self.update_choose_diff_btn(diff_roll_button, diff_choose_button, diff_info_button)
  418. ]
  419. )
  420. # ================================= 初始化 =================================
  421. diff_choose_button.action = lambda: self.choose_diff(diff_roll_button, diff_info_button, diff_choose_button) # 追加action
  422. diff_roll_button.set_current_text(diff_dict[R.difficulty]["name"])
  423. diff_update_notify(diff_roll_button, diff_info_button, R.difficulty)
  424. self.update_choose_diff_btn(diff_roll_button, diff_choose_button, diff_info_button)
  425. # ================================= 添加按钮 =================================
  426. self.screen.buttons.append(diff_info_button)
  427. self.screen.buttons.append(diff_choose_button)
  428. self.screen.buttons.append(diff_roll_button)
  429. # ================================= 上翻页 =================================
  430. self.screen.buttons.append(PygameButtonBackIMG(
  431. self.screen, self.screen.screen, cx, cy-button_blank, "res/ui/button/up.png", "res/ui/button/up_press.png", action=diff_roll_button.roll_up, anchor='center', shiny_spark=False)
  432. )
  433. # ================================= 下翻页 =================================
  434. self.screen.buttons.append(PygameButtonBackIMG(
  435. self.screen, self.screen.screen, cx, cy+button_blank, "res/ui/button/down.png", "res/ui/button/down_press.png", action=diff_roll_button.roll_down, anchor='center', shiny_spark=False)
  436. )
  437. # ================================= 开始 =================================
  438. self.screen.buttons.append(
  439. PygameButtonBackIMG(
  440. self.screen, self.screen.screen, 0.75, 0.64, "res/ui/button/go.png", "res/ui/button/go_press.png",
  441. action=self.start, anchor='center'
  442. )
  443. )
  444. # ================================= 返回上一级 =================================
  445. self.screen.buttons.append(PygameButtonBackIMG(
  446. self.screen, self.screen.screen, 0.75, 0.8, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.refresh, anchor='center')
  447. )
  448. def start(self):
  449. if self.is_random or R.rouge_hero in {"Surprise"}:
  450. if not self.is_random:
  451. current = random.choice(random_hero_list)
  452. R.rouge_hero = current
  453. self.current_hero = current
  454. with open("config.json", "r", encoding="utf-8") as json_file:
  455. mapsetdata = json.load(json_file)
  456. mapsetdata["map_set"] = "rogueMapSet"
  457. mapsetdata["your_hero"] = current
  458. with open("config.json", "w", encoding="utf-8") as json_file:
  459. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  460. R.show_cursor = True
  461. other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata")
  462. if not os.path.exists(other_file_path):
  463. rougeOB_other_data = {
  464. "Bomb": [],
  465. "Pet": [],
  466. "Hat": [],
  467. "LastRandom": int(60*datetime.now().hour+datetime.now().minute),
  468. "Other": []
  469. }
  470. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  471. else:
  472. rougeOB_other_data = load_rouge_data(other_file_path)
  473. rougeOB_other_data["LastRandom"] = int(60*datetime.now().hour+datetime.now().minute)
  474. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  475. print(f">> R.show_cursor: {R.show_cursor}")
  476. self.screen.start()
  477. def choose_hero(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
  478. cn_name = roll_btn.get_current_text()
  479. current = hero_cn[cn_name]
  480. if current == "Random":
  481. current = random.choice(random_hero_list)
  482. self.is_random = True
  483. else:
  484. self.is_random = False
  485. R.rouge_hero = current
  486. self.current_hero = current
  487. with open("config.json", "r", encoding="utf-8") as json_file:
  488. mapsetdata = json.load(json_file)
  489. mapsetdata["map_set"] = "rogueMapSet"
  490. mapsetdata["your_hero"] = current
  491. with open("config.json", "w", encoding="utf-8") as json_file:
  492. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  493. if self.is_random:
  494. roll_btn.set_current_text("随机")
  495. else:
  496. roll_btn.set_current_text(hero_dict[self.current_hero]["name"])
  497. hero_update_notify(roll_btn, info_button, self.current_hero)
  498. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  499. choose_btn.shiny_spark = False
  500. choose_btn.action = None
  501. def update_choose_hero_btn(self, roll_button, choose_btn, info_button):
  502. # 拿到当前展示的中文名
  503. cn_name = roll_button.get_current_text()
  504. # 拿到内部 key
  505. key = hero_cn[cn_name]
  506. if self.is_random:
  507. if cn_name != "随机":
  508. choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
  509. choose_btn.shiny_spark = True
  510. choose_btn.action = lambda cn=cn_name: self.choose_hero(roll_button, info_button, choose_btn)
  511. else:
  512. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  513. choose_btn.shiny_spark = False
  514. choose_btn.action = None
  515. return
  516. if R.rouge_hero in {"Surprise"}:
  517. if cn_name == "随机":
  518. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  519. choose_btn.shiny_spark = False
  520. choose_btn.action = None
  521. return
  522. # 拿到是否已解锁
  523. owned = hero_dict[key]["own"]
  524. if owned:
  525. if self.current_hero == key: # 当前
  526. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  527. choose_btn.shiny_spark = False
  528. choose_btn.action = None
  529. else:
  530. choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
  531. choose_btn.shiny_spark = True
  532. choose_btn.action = lambda cn=cn_name: self.choose_hero(roll_button, info_button, choose_btn)
  533. else:
  534. choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
  535. choose_btn.shiny_spark = False
  536. choose_btn.action = None
  537. def choose_diff(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
  538. cn_name = roll_btn.get_current_text()
  539. current = diff_cn[cn_name]
  540. R.difficulty = current
  541. with open("config.json", "r", encoding="utf-8") as json_file:
  542. mapsetdata = json.load(json_file)
  543. mapsetdata["map_set"] = "rogueMapSet"
  544. mapsetdata["rogue_difficulty"] = current
  545. with open("config.json", "w", encoding="utf-8") as json_file:
  546. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  547. roll_btn.set_current_text(diff_dict[R.difficulty]["name"])
  548. diff_update_notify(roll_btn, info_button, R.difficulty)
  549. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  550. choose_btn.shiny_spark = False
  551. choose_btn.action = None
  552. def update_choose_diff_btn(self, roll_button, choose_btn, info_button):
  553. # 拿到当前展示的中文名
  554. cn_name = roll_button.get_current_text()
  555. # 拿到内部 key
  556. key = diff_cn[cn_name]
  557. # 拿到是否已解锁
  558. # owned = (R.pass_status[key] > 0)
  559. owned = diff_dict[key]["unlock"]
  560. if key == "Easy":
  561. owned = True
  562. if owned:
  563. if R.difficulty == key: # 当前
  564. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  565. choose_btn.shiny_spark = False
  566. choose_btn.action = None
  567. else:
  568. choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
  569. choose_btn.shiny_spark = True
  570. choose_btn.action = lambda cn=cn_name: self.choose_diff(roll_button, info_button, choose_btn)
  571. else:
  572. choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
  573. choose_btn.shiny_spark = False
  574. choose_btn.action = None
  575. def hero_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
  576. cn_name = board.get_current_text()
  577. current = hero_cn[cn_name]
  578. is_chosen = "<当前选择>" if (current == R.rouge_hero) else ""
  579. owned = "" if hero_dict[current]["own"] else "(通关困难1-1后解锁)--"
  580. exp = hero_dict[current]["exp"]
  581. info = hero_dict[current]["info"]
  582. growth = hero_dict[current]["growth"]
  583. observer.set_text(f" {is_chosen}{cn_name} \n {exp}{owned} \n {info} \n {growth} ")
  584. def hero_img_update(board: PygameButtonBackIMGRoll, img: PygameIMG):
  585. cn_name = board.get_current_text()
  586. current = hero_cn[cn_name]
  587. img.update_image(hero_dict[current]["img"])
  588. def diff_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
  589. cn_name = board.get_current_text()
  590. current = diff_cn[cn_name]
  591. is_chosen = "<当前选择>" if (current == R.difficulty) else ""
  592. unlock = "" if (R.pass_status[current] > 0 or current == "Easy") else "(通关一次上一难度解锁)"
  593. info = diff_dict[current]["info"]
  594. condition = diff_dict[current]["condition"]
  595. observer.set_text(f" {is_chosen}{cn_name} \n {info} \n {condition} ")