| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600 |
- import pygame
- import json
- import os
- import random
- from datetime import datetime
- from game.const import game as G
- from game.const import window as W
- from game.const import rouge as R
- from game.sound import sound_player
- from game.utils import local_data_manager as DM
- from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
- from game.ui.menu.component import PygameButton, PygameButtonBackIMG, PygameButtonBackIMGRoll, Particle, PygameIMG
- current_folder_path = os.getcwd()
- 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") # 构建成就文件路径
- rougeOB_data = load_rouge_data(rouge_file_path)
- 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)
- diff_cn = {
- "练习": "Baby",
- "简单": "Easy",
- "困难": "Normal",
- "炼狱": "Hell",
- "炼狱+": "Hell+",
- }
- # diff_HP = {"Easy": 0.7, "Normal": 1, "Hell": 1.2, "Hell+": 1.3}
- # diff_Delta_Defense = {"Easy": -1200, "Normal": 0, "Hell": 800, "Hell+": 1000}
- # diff_speed = {"Easy": 0.9, "Normal": 1, "Hell": 1.05, "Hell+": 1.08}
- # diff_contact = {"Easy": 0.7, "Normal": 1, "Hell": 1.2, "Hell+": 1.3}
- # diff_exp = {"Easy": 1, "Normal": 1.5, "Hell": 2.2, "Hell+": 3}
- diff_dict = {
- "Baby": {"unlock": 1, "name": "练习", "info": "经验效率10%, 怪物血量-50%, 防御-2000", "condition": "纯新手练习难度"},
- "Easy": {"unlock": 1, "name": "简单", "info": "经验效率100%, 怪物血量-30%, 防御-1200", "condition": "最初的起点"},
- "Normal": {"unlock": R.pass_status["Easy"], "name": "困难", "info": "经验效率150%, 怪物血量+0%, 防御+0", "condition": "通关简单难度解锁"},
- "Hell": {"unlock": R.pass_status["Normal"], "name": "炼狱", "info": "经验效率220%, 怪物血量+20%, 防御+800", "condition": "通关困难难度解锁"},
- "Hell+": {"unlock": R.pass_status["Hell"], "name": "炼狱+", "info": "经验效率300%, 怪物血量+30%, 防御+1000", "condition": "通关炼狱难度解锁"},
- }
- diff_list = ["练习", "简单", "困难", "炼狱", "炼狱+"]
- hero_cn = {
- "小倩": "Fox",
- "波波丽": "Boboli",
- "火影": "Naruto_old",
- "阿莎": "Asha",
- "玛莉亚": "Maria",
- "春丽": "Chunli",
- "泰坦": "Titan",
- "克莉斯": "Chris",
- "海王子": "SeaPrince_old",
- "嫦娥": "Witch",
- "随机": "Random",
- }
- hero_dict = {
- "Fox": {
- "own": True, "name": "小倩",
- "exp": f"等级{rougeOB_data['Fox']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Fox']['exp'])}",
- "info": f"技能: 自身血量减少1则糖泡伤害增加{R.FoxSkill(rougeOB_data['Fox']['lv'])}",
- "growth": f"成长: 血量: {R.growth['Fox']['HP']}, 伤害: {R.growth['Fox']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_xq.png").convert_alpha()
- },
- "Boboli": {
- "own": True, "name": "波波丽",
- "exp": f"等级{rougeOB_data['Boboli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Boboli']['exp'])}",
- "info": f"技能: 每次攻击额外造成{int(R.BoboliSkill(rougeOB_data['Boboli']['lv']) * 100)}%真实伤害",
- "growth": f"成长: 血量: {R.growth['Boboli']['HP']}, 伤害: {R.growth['Boboli']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_bbl.png").convert_alpha()
- },
- "Naruto_old": {
- "own": True, "name": "火影",
- "exp": f"等级{rougeOB_data['Naruto_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Naruto_old']['exp'])}",
- "info": f"技能: 首次攻击每只怪物时攻击力变为{int(R.Naruto_oldSkill(rougeOB_data['Naruto_old']['lv']) * 100)}%",
- "growth": f"成长: 血量: {R.growth['Naruto_old']['HP']}, 伤害: {R.growth['Naruto_old']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_hy.png").convert_alpha()
- },
- "Asha": {
- "own": True, "name": "阿莎",
- "exp": f"等级{rougeOB_data['Asha']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Asha']['exp'])}",
- "info": f"技能: 每次糖泡造成伤害恢复血量{R.AshaSkill(rougeOB_data['Asha']['lv']) * 100}%",
- "growth": f"成长: 血量: {R.growth['Asha']['HP']}, 伤害: {R.growth['Asha']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_as.png").convert_alpha()
- },
- "Maria": {
- "own": True, "name": "玛莉亚",
- "exp": f"等级{rougeOB_data['Maria']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Maria']['exp'])}",
- "info": f"技能: 每次造成伤害降低怪物{R.MariaSkill2(rougeOB_data['Maria']['lv'])}防御",
- "growth": f"成长: 血量: {R.growth['Maria']['HP']}, 伤害: {R.growth['Maria']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_mly.png").convert_alpha()
- },
- "Chunli": {
- "own": True, "name": "春丽",
- "exp": f"等级{rougeOB_data['Chunli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chunli']['exp'])}",
- "info": f"技能: 每{R.ChunliSkill(rougeOB_data['Chunli']['lv'])}个糖泡放置一个双倍伤害超级糖泡",
- "growth": f"成长: 血量: {R.growth['Chunli']['HP']}, 伤害: {R.growth['Chunli']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_cl.png").convert_alpha()
- },
- "Titan": {
- "own": True, "name": "泰坦",
- "exp": f"等级{rougeOB_data['Titan']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Titan']['exp'])}",
- "info": f"技能: 初始获得{R.TitanSkill(rougeOB_data['Titan']['lv'])}防御",
- "growth": f"成长: 血量: {R.growth['Titan']['HP']}, 伤害: {R.growth['Titan']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_tt.png").convert_alpha()
- },
- "Chris": {
- "own": True, "name": "克莉斯",
- "exp": f"等级{rougeOB_data['Chris']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chris']['exp'])}",
- "info": f"技能: 灵净{R.ChrisLvSkill(rougeOB_data['Chris']['lv'])}(怪物死后变为光灵协同净化升华)", # 变身光灵, 自动寻敌(区域中)造成3x3 200%伤害, 无击杀则消失, 若无怪物目标则返回克莉丝处恢复1%生命
- "growth": f"成长: 血量: {R.growth['Chris']['HP']}, 伤害: {R.growth['Chris']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_kls.png").convert_alpha()
- },
- "SeaPrince_old": {
- "own": True, "name": "海王子",
- "exp": f"等级{rougeOB_data['SeaPrince_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['SeaPrince_old']['exp'])}",
- "info": f"技能: 初始糖币+{R.SeaPrinceSkill1(rougeOB_data['SeaPrince_old']['lv'])}, 每持有1糖币伤害增加{R.SeaPrinceSkill2(rougeOB_data['SeaPrince_old']['lv'])}",
- "growth": f"成长: 血量: {R.growth['SeaPrince_old']['HP']}, 伤害: {R.growth['SeaPrince_old']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_hwz.png").convert_alpha()
- },
- "Random": {
- "own": False, "name": "随机",
- "exp": f"--",
- "info": f"随机选择一个英雄(含隐藏角色)与引路人",
- "growth": f"--",
- "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
- },
- "Surprise": {
- "own": True, "name": "随机",
- "exp": f"--",
- "info": f"随机选择一个英雄(含隐藏角色)与引路人",
- "growth": f"--",
- "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
- },
- "Witch": {
- "own": True, "name": "嫦娥",
- "exp": f"等级{rougeOB_data['Witch']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Witch']['exp'])}",
- "info": f"[限时体验]",
- "growth": f"成长: 血量: {R.growth['Witch']['HP']}, 伤害: {R.growth['Witch']['Damage']}",
- "img": pygame.image.load(r"res/img/ui/game/icon_witch.png").convert_alpha()
- },
- }
- hero_list = ["小倩", "波波丽", "火影", "阿莎", "玛莉亚", "春丽", "泰坦", "克莉斯", "海王子", "嫦娥", "随机"]
- random_hero_list = ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Chunli", "Titan", "Chris", "SeaPrince_old"] + ["Witch"]*9 + ["Surprise"]*9
- # random_hero_list = ["Surprise"]
- # ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Surprise"]
- # {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"}
- def reload_data():
- global rougeOB_data, diff_dict, hero_dict
- rougeOB_data = load_rouge_data(rouge_file_path)
- rougeOB_achievements = load_rouge_data(rouge_achivements_file_path)
- max_level = 0
- max_diff = "Easy"
- diff_status = {"Baby": 1, "Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
- if rougeOB_achievements["Highest"]["level"] != "":
- max_level = rougeOB_achievements["Highest"]["level"]
- if rougeOB_achievements["Highest"]["diff"] != "":
- max_diff = rougeOB_achievements["Highest"]["diff"]
- if max_level == 20:
- diff_status[max_diff] = 2
- 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
- if max_level >= 15:
- R.pass_status["Hell"] = 1
- elif max_diff == "Normal":
- R.pass_status["Easy"] = 1
- if max_level >= 15:
- R.pass_status["Normal"] = 1
- else:
- if max_level >= 15:
- R.pass_status["Easy"] = 1
- for dif in ["Easy", "Normal", "Hell", "Hell+"]:
- if diff_status[dif] == 2:
- R.pass_status[dif] = 2
- diff_dict = {
- "Baby": {"unlock": 1, "name": "练习", "info": "经验效率10%, 怪物血量-50%, 防御-2000", "condition": "纯新手练习难度"},
- "Easy": {"unlock": 1, "name": "简单", "info": "经验效率100%, 怪物血量-30%, 防御-1200", "condition": "最初的起点"},
- "Normal": {"unlock": R.pass_status["Easy"], "name": "困难", "info": "经验效率150%, 怪物血量+0%, 防御+0", "condition": "通关简单难度解锁"},
- "Hell": {"unlock": R.pass_status["Normal"], "name": "炼狱", "info": "经验效率220%, 怪物血量+20%, 防御+800", "condition": "通关困难难度解锁"},
- "Hell+": {"unlock": R.pass_status["Hell"], "name": "炼狱+", "info": "经验效率300%, 怪物血量+30%, 防御+1000", "condition": "通关炼狱难度解锁"},
- }
- hero_dict = {
- "Fox": {
- "own": True, "name": "小倩",
- "exp": f"等级{rougeOB_data['Fox']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Fox']['exp'])}",
- "info": f"技能: 自身血量减少1则糖泡伤害增加{R.FoxSkill(rougeOB_data['Fox']['lv'])}",
- "growth": f"成长: 血量: 100, 伤害: 50",
- "img": pygame.image.load(r"res/img/ui/game/icon_xq.png").convert_alpha()
- },
- "Boboli": {
- "own": True, "name": "波波丽",
- "exp": f"等级{rougeOB_data['Boboli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Boboli']['exp'])}",
- "info": f"技能: 每次攻击额外造成{int(R.BoboliSkill(rougeOB_data['Boboli']['lv']) * 100)}%真实伤害",
- "growth": f"成长: 血量: 60, 伤害: 90",
- "img": pygame.image.load(r"res/img/ui/game/icon_bbl.png").convert_alpha()
- },
- "Naruto_old": {
- "own": True, "name": "火影",
- "exp": f"等级{rougeOB_data['Naruto_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Naruto_old']['exp'])}",
- "info": f"技能: 首次攻击每只怪物时攻击力变为{int(R.Naruto_oldSkill(rougeOB_data['Naruto_old']['lv']) * 100)}%",
- "growth": f"成长: 血量: 50, 伤害: 100",
- "img": pygame.image.load(r"res/img/ui/game/icon_hy.png").convert_alpha()
- },
- "Asha": {
- "own": True, "name": "阿莎",
- "exp": f"等级{rougeOB_data['Asha']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Asha']['exp'])}",
- "info": f"技能: 每次糖泡造成伤害恢复血量{R.AshaSkill(rougeOB_data['Asha']['lv']) * 100}%",
- "growth": f"成长: 血量: 90, 伤害: 60",
- "img": pygame.image.load(r"res/img/ui/game/icon_as.png").convert_alpha()
- },
- "Maria": {
- "own": True, "name": "玛莉亚",
- "exp": f"等级{rougeOB_data['Maria']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Maria']['exp'])}",
- "info": f"技能: 每次造成伤害降低怪物{R.MariaSkill2(rougeOB_data['Maria']['lv'])}防御",
- "growth": f"成长: 血量: 300, 伤害: 300",
- "img": pygame.image.load(r"res/img/ui/game/icon_mly.png").convert_alpha()
- },
- "Chunli": {
- "own": True, "name": "春丽",
- "exp": f"等级{rougeOB_data['Chunli']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chunli']['exp'])}",
- "info": f"技能: 每{R.ChunliSkill(rougeOB_data['Chunli']['lv'])}个糖泡放置一个双倍伤害超级糖泡",
- "growth": f"成长: 血量: 70, 伤害: 80",
- "img": pygame.image.load(r"res/img/ui/game/icon_cl.png").convert_alpha()
- },
- "Titan": {
- "own": True, "name": "泰坦",
- "exp": f"等级{rougeOB_data['Titan']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Titan']['exp'])}",
- "info": f"技能: 初始获得{R.TitanSkill(rougeOB_data['Titan']['lv'])}防御",
- "growth": f"成长: 血量: 100, 伤害: 100",
- "img": pygame.image.load(r"res/img/ui/game/icon_tt.png").convert_alpha()
- },
- "Chris": {
- "own": True, "name": "克莉斯",
- "exp": f"等级{rougeOB_data['Chris']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Chris']['exp'])}",
- "info": f"技能: 灵净{R.ChrisLvSkill(rougeOB_data['Chris']['lv'])}(怪物死后变为光灵协同净化升华)", # 变身光灵, 自动寻敌(区域中)造成3x3 200%伤害, 无击杀则消失, 若无怪物目标则返回克莉丝处恢复1%生命
- "growth": f"成长: 血量: 100, 伤害: 100",
- "img": pygame.image.load(r"res/img/ui/game/icon_kls.png").convert_alpha()
- },
- "SeaPrince_old": {
- "own": True, "name": "海王子",
- "exp": f"等级{rougeOB_data['SeaPrince_old']['lv']}, 升级还需经验: {current_lv(rougeOB_data['SeaPrince_old']['exp'])}",
- "info": f"技能: 初始糖币+{R.SeaPrinceSkill1(rougeOB_data['SeaPrince_old']['lv'])}, 每持有1糖币伤害增加{R.SeaPrinceSkill2(rougeOB_data['SeaPrince_old']['lv'])}",
- "growth": f"成长: 血量: 80, 伤害: 70",
- "img": pygame.image.load(r"res/img/ui/game/icon_hwz.png").convert_alpha()
- },
- "Random": {
- "own": False, "name": "随机",
- "exp": f"--",
- "info": f"随机选择一个英雄(含隐藏角色)与引路人",
- "growth": f"--",
- "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
- },
- "Surprise": {
- "own": True, "name": "随机",
- "exp": f"--",
- "info": f"随机选择一个英雄(含隐藏角色)与引路人",
- "growth": f"--",
- "img": pygame.image.load(r"res/img/ui/game/icon_random.png").convert_alpha()
- },
- "Witch": {
- "own": True, "name": "嫦娥",
- "exp": f"等级{rougeOB_data['Witch']['lv']}, 升级还需经验: {current_lv(rougeOB_data['Witch']['exp'])}",
- "info": f"[限时体验]",
- "growth": f"成长: 血量: 50, 伤害: 50",
- "img": pygame.image.load(r"res/img/ui/game/icon_witch.png").convert_alpha()
- },
- }
- class ChoosePage:
- def __init__(self):
- self.screen = W.MENU
- 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文件夹存在,如果不存在则创建
- self.rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
- self.other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
- self.rougeOB_achievements = {}
- self.rougeOB_other_data = {}
- self.diff_map = {}
- self.is_random = False
- self.current_diff = None
- self.view_diff = None
- self.current_hero = R.rouge_hero
- self.diff_num = {"Baby": 1, "Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4}
- self.diff_status = {"Baby": 1, "Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
- self.max_diff = "Easy"
- self.init_choose_page()
- self.load_achievements_data()
- def init_choose_page(self):
- DM.init_achievement()
- self.rougeOB_achievements = load_rouge_data(self.rouge_achivements_file_path)
- def load_achievements_data(self):
- if self.rougeOB_achievements["Highest"]["diff"] != "":
- self.max_diff = self.rougeOB_achievements["Highest"]["diff"]
- if self.diff_num[self.max_diff] > 1:
- hero_dict["Random"]["own"] = True
- if self.diff_num[R.difficulty]-1 > self.diff_num[self.max_diff]: # 作弊
- print("作弊!!!")
- R.difficulty = "Easy"
- with open("config.json", "r", encoding="utf-8") as json_file:
- mapsetdata = json.load(json_file)
- mapsetdata["map_set"] = "rogueMapSet"
- mapsetdata["rogue_difficulty"] = "Easy"
- with open("config.json", "w", encoding="utf-8") as json_file:
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
- def draw(self):
- self.screen.buttons.clear()
- # ================================= 信息展示 =================================
- info_button = PygameButton(
- self.screen.screen, "", 0.25, 0.47, 18, "#2a2a2a",
- fg_color=(215,220,217), action=None,
- anchor="center", is_bold=True, fix_shape=(360,120), bg_alpha=159,
- frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
- )
- # ================================= 图片 =================================
- cx, cy = 0.35, 0.7
- img_button = PygameButtonBackIMG(
- self.screen, self.screen.screen, cx, cy, "res/ui/button/img_board.png", "res/ui/button/img_board.png",
- action=None, anchor='center', shiny_spark=False
- )
- img = PygameIMG(self.screen, self.screen.screen, cx, cy, py_img=hero_dict[R.rouge_hero]["img"], anchor='center')
- # ================================= 选择 =================================
- choose_button = PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.13, 0.7, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
- action=None, anchor='center'
- )
- # ================================= 展示框 =================================
- cy = 0.2
- cx = 0.25
- button_blank = 0.13
- roll_button = PygameButtonBackIMGRoll(
- self.screen, self.screen.screen, cx, cy, "res/ui/button/cursor_board.png", hero_list,
- action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
- 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,
- related_button=[info_button, choose_button, img],
- notify_action=[
- lambda x: hero_update_notify(roll_button, x, self.current_hero),
- lambda _: self.update_choose_hero_btn(roll_button, choose_button, info_button),
- lambda _: hero_img_update(roll_button, img)
- ]
- )
- # ================================= 初始化 =================================
- choose_button.action = lambda: self.choose_hero(roll_button, info_button, choose_button) # 追加action
- roll_button.set_current_text(hero_dict[self.current_hero]["name"])
- hero_update_notify(roll_button, info_button, self.current_hero)
- self.update_choose_hero_btn(roll_button, choose_button, info_button)
- # ================================= 添加按钮 =================================
- self.screen.buttons.append(info_button)
- self.screen.buttons.append(choose_button)
- self.screen.buttons.append(roll_button)
- self.screen.buttons.append(img_button)
- self.screen.buttons.append(img)
- # ================================= 上翻页 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- 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)
- )
- # ================================= 下翻页 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- 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)
- )
- # ===================================================================================
- # ===================================================================================
- # ===================================================================================
- # ================================= 信息展示 =================================
- diff_info_button = PygameButton(
- self.screen.screen, "", 0.75, 0.47, 18, "#2a2a2a",
- fg_color=(215,220,217), action=None,
- anchor="center", is_bold=True, fix_shape=(360,100), bg_alpha=159,
- frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
- )
- # ================================= 选择 =================================
- diff_choose_button = PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.87, 0.22, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
- action=None, anchor='center'
- )
- # ================================= 展示框 =================================
- cx, cy = 0.6, 0.2
- button_blank = 0.13
- diff_roll_button = PygameButtonBackIMGRoll(
- self.screen, self.screen.screen, cx, cy, "res/ui/button/cursor_board.png", diff_list,
- action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
- 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,
- related_button=[diff_info_button, diff_choose_button],
- notify_action=[
- lambda x: diff_update_notify(diff_roll_button, x, R.difficulty),
- lambda _: self.update_choose_diff_btn(diff_roll_button, diff_choose_button, diff_info_button)
- ]
- )
- # ================================= 初始化 =================================
- diff_choose_button.action = lambda: self.choose_diff(diff_roll_button, diff_info_button, diff_choose_button) # 追加action
- diff_roll_button.set_current_text(diff_dict[R.difficulty]["name"])
- diff_update_notify(diff_roll_button, diff_info_button, R.difficulty)
- self.update_choose_diff_btn(diff_roll_button, diff_choose_button, diff_info_button)
- # ================================= 添加按钮 =================================
- self.screen.buttons.append(diff_info_button)
- self.screen.buttons.append(diff_choose_button)
- self.screen.buttons.append(diff_roll_button)
- # ================================= 上翻页 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- 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)
- )
- # ================================= 下翻页 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- 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)
- )
- # ================================= 开始 =================================
- self.screen.buttons.append(
- PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.75, 0.64, "res/ui/button/go.png", "res/ui/button/go_press.png",
- action=self.start, anchor='center'
- )
- )
- # ================================= 返回上一级 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- 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')
- )
- def start(self):
- if self.is_random or R.rouge_hero in {"Surprise"}:
- if not self.is_random:
- current = random.choice(random_hero_list)
- R.rouge_hero = current
- self.current_hero = current
- with open("config.json", "r", encoding="utf-8") as json_file:
- mapsetdata = json.load(json_file)
- mapsetdata["map_set"] = "rogueMapSet"
- mapsetdata["your_hero"] = current
- with open("config.json", "w", encoding="utf-8") as json_file:
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
- R.show_cursor = True
- 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")
- print(f">> R.show_cursor: {R.show_cursor}")
- self.screen.start()
- def choose_hero(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
- cn_name = roll_btn.get_current_text()
- current = hero_cn[cn_name]
- if current == "Random":
- current = random.choice(random_hero_list)
- self.is_random = True
- else:
- self.is_random = False
- R.rouge_hero = current
- self.current_hero = current
- with open("config.json", "r", encoding="utf-8") as json_file:
- mapsetdata = json.load(json_file)
- mapsetdata["map_set"] = "rogueMapSet"
- mapsetdata["your_hero"] = current
- with open("config.json", "w", encoding="utf-8") as json_file:
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
- if self.is_random:
- roll_btn.set_current_text("随机")
- else:
- roll_btn.set_current_text(hero_dict[self.current_hero]["name"])
- hero_update_notify(roll_btn, info_button, self.current_hero)
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- def update_choose_hero_btn(self, roll_button, choose_btn, info_button):
- # 拿到当前展示的中文名
- cn_name = roll_button.get_current_text()
- # 拿到内部 key
- key = hero_cn[cn_name]
- if self.is_random:
- if cn_name != "随机":
- choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
- choose_btn.shiny_spark = True
- choose_btn.action = lambda cn=cn_name: self.choose_hero(roll_button, info_button, choose_btn)
- else:
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- return
- if R.rouge_hero in {"Surprise"}:
- if cn_name == "随机":
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- return
- # 拿到是否已解锁
- owned = hero_dict[key]["own"]
- if owned:
- if self.current_hero == key: # 当前
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- else:
- choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
- choose_btn.shiny_spark = True
- choose_btn.action = lambda cn=cn_name: self.choose_hero(roll_button, info_button, choose_btn)
- else:
- choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- def choose_diff(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
- cn_name = roll_btn.get_current_text()
- current = diff_cn[cn_name]
- R.difficulty = current
- with open("config.json", "r", encoding="utf-8") as json_file:
- mapsetdata = json.load(json_file)
- mapsetdata["map_set"] = "rogueMapSet"
- mapsetdata["rogue_difficulty"] = current
- with open("config.json", "w", encoding="utf-8") as json_file:
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
- roll_btn.set_current_text(diff_dict[R.difficulty]["name"])
- diff_update_notify(roll_btn, info_button, R.difficulty)
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- def update_choose_diff_btn(self, roll_button, choose_btn, info_button):
- # 拿到当前展示的中文名
- cn_name = roll_button.get_current_text()
- # 拿到内部 key
- key = diff_cn[cn_name]
- # 拿到是否已解锁
- # owned = (R.pass_status[key] > 0)
- owned = diff_dict[key]["unlock"]
- if key == "Easy":
- owned = True
- if owned:
- if R.difficulty == key: # 当前
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- else:
- choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
- choose_btn.shiny_spark = True
- choose_btn.action = lambda cn=cn_name: self.choose_diff(roll_button, info_button, choose_btn)
- else:
- choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- def hero_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
- cn_name = board.get_current_text()
- current = hero_cn[cn_name]
- is_chosen = "<当前选择>" if (current == R.rouge_hero) else ""
- owned = "" if hero_dict[current]["own"] else "(通关困难1-1后解锁)--"
- exp = hero_dict[current]["exp"]
- info = hero_dict[current]["info"]
- growth = hero_dict[current]["growth"]
- observer.set_text(f" {is_chosen}{cn_name} \n {exp}{owned} \n {info} \n {growth} ")
- def hero_img_update(board: PygameButtonBackIMGRoll, img: PygameIMG):
- cn_name = board.get_current_text()
- current = hero_cn[cn_name]
- img.update_image(hero_dict[current]["img"])
- def diff_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
- cn_name = board.get_current_text()
- current = diff_cn[cn_name]
- is_chosen = "<当前选择>" if (current == R.difficulty) else ""
- unlock = "" if (R.pass_status[current] > 0 or current == "Easy") else "(通关一次上一难度解锁)"
- info = diff_dict[current]["info"]
- condition = diff_dict[current]["condition"]
- observer.set_text(f" {is_chosen}{cn_name} \n {info} \n {condition} ")
|