choose_hero_menu.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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.utils import local_data_manager as DM
  11. from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
  12. from game.ui.menu.component import PygameButton, PygameButtonBackIMG, PygameButtonBackIMGRoll, Particle, PygameIMG
  13. current_folder_path = os.getcwd()
  14. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  15. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  16. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  17. rouge_file_path = os.path.join(qqtpve_folder, "rougeOB.rougedata") # 构建文件路径
  18. rougeOB_data = load_rouge_data(rouge_file_path)
  19. def current_lv(lv):
  20. lv_list = R.lv_list
  21. if lv >= sum(lv_list):
  22. return "--"
  23. for k in range(0, 14):
  24. if sum(lv_list[:k]) <= lv < sum(lv_list[:k + 1]):
  25. return str(sum(lv_list[:k + 1]) - lv)
  26. diff_cn = {
  27. "练习": "Baby",
  28. "简单": "Easy",
  29. "困难": "Normal",
  30. "炼狱": "Hell",
  31. "炼狱+": "Hell+",
  32. }
  33. # diff_HP = {"Easy": 0.7, "Normal": 1, "Hell": 1.2, "Hell+": 1.3}
  34. # diff_Delta_Defense = {"Easy": -1200, "Normal": 0, "Hell": 800, "Hell+": 1000}
  35. # diff_speed = {"Easy": 0.9, "Normal": 1, "Hell": 1.05, "Hell+": 1.08}
  36. # diff_contact = {"Easy": 0.7, "Normal": 1, "Hell": 1.2, "Hell+": 1.3}
  37. # diff_exp = {"Easy": 1, "Normal": 1.5, "Hell": 2.2, "Hell+": 3}
  38. diff_dict = {
  39. "Baby": {"unlock": 1, "name": "练习", "info": "经验效率10%, 怪物血量-50%, 防御-2000", "condition": "纯新手练习难度"},
  40. "Easy": {"unlock": 1, "name": "简单", "info": "经验效率100%, 怪物血量-30%, 防御-1200", "condition": "最初的起点"},
  41. "Normal": {"unlock": R.pass_status["Easy"], "name": "困难", "info": "经验效率150%, 怪物血量+0%, 防御+0", "condition": "通关简单难度解锁"},
  42. "Hell": {"unlock": R.pass_status["Normal"], "name": "炼狱", "info": "经验效率220%, 怪物血量+20%, 防御+800", "condition": "通关困难难度解锁"},
  43. "Hell+": {"unlock": R.pass_status["Hell"], "name": "炼狱+", "info": "经验效率300%, 怪物血量+30%, 防御+1000", "condition": "通关炼狱难度解锁"},
  44. }
  45. diff_list = ["练习", "简单", "困难", "炼狱", "炼狱+"]
  46. hero_cn = {
  47. "小倩": "Fox",
  48. "波波丽": "Boboli",
  49. "火影": "Naruto_old",
  50. "阿莎": "Asha",
  51. "玛莉亚": "Maria",
  52. "嫦娥": "Witch",
  53. "随机": "Random",
  54. }
  55. hero_dict = {
  56. "Fox": {
  57. "own": True, "name": "小倩",
  58. "exp": f"等级{rougeOB_data['Fox']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Fox']['exp'])}",
  59. "info": f"技能: 自身血量减少1则糖泡伤害增加{R.FoxSkill(rougeOB_data['Fox']['lv'])}",
  60. "growth": f"成长: 血量: 100, 伤害: 50",
  61. "img": pygame.image.load(r"res/img/ui/game/icon_xq.png").convert_alpha()
  62. },
  63. "Boboli": {
  64. "own": True, "name": "波波丽",
  65. "exp": f"等级{rougeOB_data['Boboli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Boboli']['exp'])}",
  66. "info": f"技能: 每次攻击额外造成{int(R.BoboliSkill(rougeOB_data['Boboli']['lv']) * 100)}%真实伤害",
  67. "growth": f"成长: 血量: 60, 伤害: 90",
  68. "img": pygame.image.load(r"res/img/ui/game/icon_bbl.png").convert_alpha()
  69. },
  70. "Naruto_old": {
  71. "own": True, "name": "火影",
  72. "exp": f"等级{rougeOB_data['Naruto_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Naruto_old']['exp'])}",
  73. "info": f"技能: 首次攻击每只怪物时攻击力变为{int(R.Naruto_oldSkill(rougeOB_data['Naruto_old']['lv']) * 100)}%",
  74. "growth": f"成长: 血量: 50, 伤害: 100",
  75. "img": pygame.image.load(r"res/img/ui/game/icon_hy.png").convert_alpha()
  76. },
  77. "Asha": {
  78. "own": True, "name": "阿莎",
  79. "exp": f"等级{rougeOB_data['Asha']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Asha']['exp'])}",
  80. "info": f"技能: 每次糖泡造成伤害恢复血量{R.AshaSkill(rougeOB_data['Asha']['lv']) * 100}%",
  81. "growth": f"成长: 血量: 90, 伤害: 60",
  82. "img": pygame.image.load(r"res/img/ui/game/icon_as.png").convert_alpha()
  83. },
  84. "Maria": {
  85. "own": True, "name": "玛莉亚",
  86. "exp": f"等级{rougeOB_data['Maria']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Maria']['exp'])}",
  87. "info": f"技能: 每次造成伤害降低怪物{R.MariaSkill2(rougeOB_data['Maria']['lv'])}防御",
  88. "growth": f"成长: 血量: 300, 伤害: 300",
  89. "img": pygame.image.load(r"res/img/ui/game/icon_mly.png").convert_alpha()
  90. },
  91. "Random": {
  92. "own": False, "name": "随机",
  93. "exp": f"--",
  94. "info": f"随机选择一个英雄(含隐藏角色)与引路人",
  95. "growth": f"--",
  96. "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
  97. },
  98. "Surprise": {
  99. "own": True, "name": "随机",
  100. "exp": f"--",
  101. "info": f"随机选择一个英雄(含隐藏角色)与引路人",
  102. "growth": f"--",
  103. "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
  104. },
  105. "Witch": {
  106. "own": True, "name": "嫦娥",
  107. "exp": f"等级{rougeOB_data['Witch']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Witch']['exp'])}",
  108. "info": f"--",
  109. "growth": f"成长: 血量: 50, 伤害: 50",
  110. "img": pygame.image.load(r"res/img/ui/game/icon_witch.png").convert_alpha()
  111. },
  112. }
  113. hero_list = ["小倩", "波波丽", "火影", "阿莎", "玛莉亚", "嫦娥", "随机"]
  114. random_hero_list = ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Witch", "Surprise", "Surprise", "Surprise"]
  115. # random_hero_list = ["Surprise"]
  116. # ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Surprise"]
  117. # {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"}
  118. class ChoosePage:
  119. def __init__(self):
  120. self.screen = W.MENU
  121. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  122. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  123. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  124. self.rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
  125. self.other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
  126. self.rougeOB_achievements = {}
  127. self.rougeOB_other_data = {}
  128. self.diff_map = {}
  129. self.is_random = False
  130. self.current_diff = None
  131. self.view_diff = None
  132. self.current_hero = R.rouge_hero
  133. self.diff_num = {"Baby": 1, "Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4}
  134. self.diff_status = {"Baby": 1, "Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
  135. self.max_diff = "Easy"
  136. self.init_choose_page()
  137. self.load_achievements_data()
  138. def init_choose_page(self):
  139. DM.init_achievement()
  140. self.rougeOB_achievements = load_rouge_data(self.rouge_achivements_file_path)
  141. def load_achievements_data(self):
  142. if self.rougeOB_achievements["Highest"]["diff"] != "":
  143. self.max_diff = self.rougeOB_achievements["Highest"]["diff"]
  144. if self.diff_num[self.max_diff] > 1:
  145. hero_dict["Random"]["own"] = True
  146. if self.diff_num[R.difficulty]-1 > self.diff_num[self.max_diff]: # 作弊
  147. print("作弊!!!")
  148. R.difficulty = "Easy"
  149. with open("config.json", "r", encoding="utf-8") as json_file:
  150. mapsetdata = json.load(json_file)
  151. mapsetdata["map_set"] = "rogueMapSet"
  152. mapsetdata["rogue_difficulty"] = "Easy"
  153. with open("config.json", "w", encoding="utf-8") as json_file:
  154. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  155. def draw(self):
  156. self.screen.buttons.clear()
  157. # ================================= 信息展示 =================================
  158. info_button = PygameButton(
  159. self.screen.screen, "", 0.25, 0.47, 18, "#2a2a2a",
  160. fg_color=(215,220,217), action=None,
  161. anchor="center", is_bold=True, fix_shape=(360,120), bg_alpha=159,
  162. frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
  163. )
  164. # ================================= 图片 =================================
  165. cx, cy = 0.35, 0.7
  166. img_button = PygameButtonBackIMG(
  167. self.screen, self.screen.screen, cx, cy, "res/ui/button/img_board.png", "res/ui/button/img_board.png",
  168. action=None, anchor='center', shiny_spark=False
  169. )
  170. img = PygameIMG(self.screen, self.screen.screen, cx, cy, py_img=hero_dict[R.rouge_hero]["img"], anchor='center')
  171. # ================================= 选择 =================================
  172. choose_button = PygameButtonBackIMG(
  173. self.screen, self.screen.screen, 0.13, 0.7, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
  174. action=None, anchor='center'
  175. )
  176. # ================================= 展示框 =================================
  177. cy = 0.2
  178. cx = 0.25
  179. button_blank = 0.13
  180. roll_button = PygameButtonBackIMGRoll(
  181. self.screen, self.screen.screen, cx, cy, "res/ui/button/cursor_board.png", hero_list,
  182. action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
  183. 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,
  184. related_button=[info_button, choose_button, img],
  185. notify_action=[
  186. lambda x: hero_update_notify(roll_button, x, self.current_hero),
  187. lambda _: self.update_choose_hero_btn(roll_button, choose_button, info_button),
  188. lambda _: hero_img_update(roll_button, img)
  189. ]
  190. )
  191. # ================================= 初始化 =================================
  192. choose_button.action = lambda: self.choose_hero(roll_button, info_button, choose_button) # 追加action
  193. roll_button.set_current_text(hero_dict[self.current_hero]["name"])
  194. hero_update_notify(roll_button, info_button, self.current_hero)
  195. self.update_choose_hero_btn(roll_button, choose_button, info_button)
  196. # ================================= 添加按钮 =================================
  197. self.screen.buttons.append(info_button)
  198. self.screen.buttons.append(choose_button)
  199. self.screen.buttons.append(roll_button)
  200. self.screen.buttons.append(img_button)
  201. self.screen.buttons.append(img)
  202. # ================================= 上翻页 =================================
  203. self.screen.buttons.append(PygameButtonBackIMG(
  204. 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)
  205. )
  206. # ================================= 下翻页 =================================
  207. self.screen.buttons.append(PygameButtonBackIMG(
  208. 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)
  209. )
  210. # ===================================================================================
  211. # ===================================================================================
  212. # ===================================================================================
  213. # ================================= 信息展示 =================================
  214. diff_info_button = PygameButton(
  215. self.screen.screen, "", 0.75, 0.47, 18, "#2a2a2a",
  216. fg_color=(215,220,217), action=None,
  217. anchor="center", is_bold=True, fix_shape=(360,100), bg_alpha=159,
  218. frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
  219. )
  220. # ================================= 选择 =================================
  221. diff_choose_button = PygameButtonBackIMG(
  222. self.screen, self.screen.screen, 0.87, 0.22, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
  223. action=None, anchor='center'
  224. )
  225. # ================================= 展示框 =================================
  226. cx, cy = 0.6, 0.2
  227. button_blank = 0.13
  228. diff_roll_button = PygameButtonBackIMGRoll(
  229. self.screen, self.screen.screen, cx, cy, "res/ui/button/cursor_board.png", diff_list,
  230. action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
  231. 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,
  232. related_button=[diff_info_button, diff_choose_button],
  233. notify_action=[
  234. lambda x: diff_update_notify(diff_roll_button, x, R.difficulty),
  235. lambda _: self.update_choose_diff_btn(diff_roll_button, diff_choose_button, diff_info_button)
  236. ]
  237. )
  238. # ================================= 初始化 =================================
  239. diff_choose_button.action = lambda: self.choose_diff(diff_roll_button, diff_info_button, diff_choose_button) # 追加action
  240. diff_roll_button.set_current_text(diff_dict[R.difficulty]["name"])
  241. diff_update_notify(diff_roll_button, diff_info_button, R.difficulty)
  242. self.update_choose_diff_btn(diff_roll_button, diff_choose_button, diff_info_button)
  243. # ================================= 添加按钮 =================================
  244. self.screen.buttons.append(diff_info_button)
  245. self.screen.buttons.append(diff_choose_button)
  246. self.screen.buttons.append(diff_roll_button)
  247. # ================================= 上翻页 =================================
  248. self.screen.buttons.append(PygameButtonBackIMG(
  249. 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)
  250. )
  251. # ================================= 下翻页 =================================
  252. self.screen.buttons.append(PygameButtonBackIMG(
  253. 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)
  254. )
  255. # ================================= 开始 =================================
  256. self.screen.buttons.append(
  257. PygameButtonBackIMG(
  258. self.screen, self.screen.screen, 0.75, 0.64, "res/ui/button/go.png", "res/ui/button/go_press.png",
  259. action=self.start, anchor='center'
  260. )
  261. )
  262. # ================================= 返回上一级 =================================
  263. self.screen.buttons.append(PygameButtonBackIMG(
  264. 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')
  265. )
  266. def start(self):
  267. if self.is_random or R.rouge_hero in {"Surprise"}:
  268. if not self.is_random:
  269. current = random.choice(random_hero_list)
  270. R.rouge_hero = current
  271. self.current_hero = current
  272. with open("config.json", "r", encoding="utf-8") as json_file:
  273. mapsetdata = json.load(json_file)
  274. mapsetdata["map_set"] = "rogueMapSet"
  275. mapsetdata["your_hero"] = current
  276. with open("config.json", "w", encoding="utf-8") as json_file:
  277. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  278. R.show_cursor = True
  279. other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata")
  280. if not os.path.exists(other_file_path):
  281. rougeOB_other_data = {
  282. "Bomb": [],
  283. "Pet": [],
  284. "Hat": [],
  285. "LastRandom": int(60*datetime.now().hour+datetime.now().minute),
  286. "Other": []
  287. }
  288. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  289. else:
  290. rougeOB_other_data = load_rouge_data(other_file_path)
  291. rougeOB_other_data["LastRandom"] = int(60*datetime.now().hour+datetime.now().minute)
  292. save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
  293. print(f">> R.show_cursor: {R.show_cursor}")
  294. self.screen.start()
  295. def choose_hero(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
  296. cn_name = roll_btn.get_current_text()
  297. current = hero_cn[cn_name]
  298. if current == "Random":
  299. current = random.choice(random_hero_list)
  300. self.is_random = True
  301. else:
  302. self.is_random = False
  303. R.rouge_hero = current
  304. self.current_hero = current
  305. with open("config.json", "r", encoding="utf-8") as json_file:
  306. mapsetdata = json.load(json_file)
  307. mapsetdata["map_set"] = "rogueMapSet"
  308. mapsetdata["your_hero"] = current
  309. with open("config.json", "w", encoding="utf-8") as json_file:
  310. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  311. if self.is_random:
  312. roll_btn.set_current_text("随机")
  313. else:
  314. roll_btn.set_current_text(hero_dict[self.current_hero]["name"])
  315. hero_update_notify(roll_btn, info_button, self.current_hero)
  316. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  317. choose_btn.shiny_spark = False
  318. choose_btn.action = None
  319. def update_choose_hero_btn(self, roll_button, choose_btn, info_button):
  320. # 拿到当前展示的中文名
  321. cn_name = roll_button.get_current_text()
  322. # 拿到内部 key
  323. key = hero_cn[cn_name]
  324. if self.is_random:
  325. if cn_name != "随机":
  326. choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
  327. choose_btn.shiny_spark = True
  328. choose_btn.action = lambda cn=cn_name: self.choose_hero(roll_button, info_button, choose_btn)
  329. else:
  330. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  331. choose_btn.shiny_spark = False
  332. choose_btn.action = None
  333. return
  334. if R.rouge_hero in {"Surprise"}:
  335. if cn_name == "随机":
  336. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  337. choose_btn.shiny_spark = False
  338. choose_btn.action = None
  339. return
  340. # 拿到是否已解锁
  341. owned = hero_dict[key]["own"]
  342. if owned:
  343. if self.current_hero == key: # 当前
  344. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  345. choose_btn.shiny_spark = False
  346. choose_btn.action = None
  347. else:
  348. choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
  349. choose_btn.shiny_spark = True
  350. choose_btn.action = lambda cn=cn_name: self.choose_hero(roll_button, info_button, choose_btn)
  351. else:
  352. choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
  353. choose_btn.shiny_spark = False
  354. choose_btn.action = None
  355. def choose_diff(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
  356. cn_name = roll_btn.get_current_text()
  357. current = diff_cn[cn_name]
  358. R.difficulty = current
  359. with open("config.json", "r", encoding="utf-8") as json_file:
  360. mapsetdata = json.load(json_file)
  361. mapsetdata["map_set"] = "rogueMapSet"
  362. mapsetdata["rogue_difficulty"] = current
  363. with open("config.json", "w", encoding="utf-8") as json_file:
  364. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  365. roll_btn.set_current_text(diff_dict[R.difficulty]["name"])
  366. diff_update_notify(roll_btn, info_button, R.difficulty)
  367. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  368. choose_btn.shiny_spark = False
  369. choose_btn.action = None
  370. def update_choose_diff_btn(self, roll_button, choose_btn, info_button):
  371. # 拿到当前展示的中文名
  372. cn_name = roll_button.get_current_text()
  373. # 拿到内部 key
  374. key = diff_cn[cn_name]
  375. # 拿到是否已解锁
  376. # owned = (R.pass_status[key] > 0)
  377. owned = diff_dict[key]["unlock"]
  378. if key == "Easy":
  379. owned = True
  380. if owned:
  381. if R.difficulty == key: # 当前
  382. choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
  383. choose_btn.shiny_spark = False
  384. choose_btn.action = None
  385. else:
  386. choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
  387. choose_btn.shiny_spark = True
  388. choose_btn.action = lambda cn=cn_name: self.choose_diff(roll_button, info_button, choose_btn)
  389. else:
  390. choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
  391. choose_btn.shiny_spark = False
  392. choose_btn.action = None
  393. def hero_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
  394. cn_name = board.get_current_text()
  395. current = hero_cn[cn_name]
  396. is_chosen = "<当前选择>" if (current == R.rouge_hero) else ""
  397. owned = "" if hero_dict[current]["own"] else "(通关一次游戏解锁)--"
  398. exp = hero_dict[current]["exp"]
  399. info = hero_dict[current]["info"]
  400. growth = hero_dict[current]["growth"]
  401. observer.set_text(f" {is_chosen}{cn_name} \n {exp}{owned} \n {info} \n {growth} ")
  402. def hero_img_update(board: PygameButtonBackIMGRoll, img: PygameIMG):
  403. cn_name = board.get_current_text()
  404. current = hero_cn[cn_name]
  405. img.update_image(hero_dict[current]["img"])
  406. def diff_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
  407. cn_name = board.get_current_text()
  408. current = diff_cn[cn_name]
  409. is_chosen = "<当前选择>" if (current == R.difficulty) else ""
  410. unlock = "" if (R.pass_status[current] > 0 or current == "Easy") else "(通关一次上一难度解锁)"
  411. info = diff_dict[current]["info"]
  412. condition = diff_dict[current]["condition"]
  413. observer.set_text(f" {is_chosen}{cn_name} \n {info} \n {condition} ")