|
|
@@ -1,26 +1,26 @@
|
|
|
import random
|
|
|
import json
|
|
|
import os
|
|
|
-# import psutil
|
|
|
import win32gui
|
|
|
import tkinter as tk
|
|
|
import sys
|
|
|
import logging
|
|
|
import rougetask
|
|
|
import rougesetting
|
|
|
-# import cProfile
|
|
|
+import pygame
|
|
|
import requests
|
|
|
-
|
|
|
+import concurrent.futures
|
|
|
from datetime import datetime, timedelta
|
|
|
-# from memory_profiler import profile
|
|
|
-# import easygui as eg
|
|
|
|
|
|
-from game import control
|
|
|
+from game import rogue_control
|
|
|
+from game.rogue_control import Control
|
|
|
from game.algo import rougeGen
|
|
|
from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
|
|
|
from game.algo import utils as util
|
|
|
+from game.algo import rougeGen as RG
|
|
|
+from game.const import window as W, color as C, game as G
|
|
|
from game.const import rouge as R
|
|
|
-from game.const import game as G
|
|
|
+
|
|
|
|
|
|
current_folder_path = os.getcwd()
|
|
|
|
|
|
@@ -49,18 +49,79 @@ def check_rouge_ob_data(data):
|
|
|
save_encrypt_single_rouge_file(data, "rougeOB")
|
|
|
|
|
|
|
|
|
-class App:
|
|
|
- def __init__(self, master):
|
|
|
-
|
|
|
- self.master = master
|
|
|
- master.geometry("960x640")
|
|
|
- master.configure(bg='#7E587E')
|
|
|
- master.title("QQTRogue二测β2.3.1(底层逻辑:永恒; 肉鸽算法开发与设计:100の雨女; 唯一官方群756422783免费下载; 擅自售卖皆属剽窃!)")
|
|
|
+class PygameButton:
|
|
|
+ def __init__(self, screen, text, relx, rely, font_size, bg_color, fg_color=(255,255,255), action=None, anchor='center'):
|
|
|
+ self.screen = screen
|
|
|
+ self.text = text
|
|
|
+ self.lines = text.split('\n')
|
|
|
+ self.font = pygame.font.SysFont("Microsoft YaHei", font_size)
|
|
|
+ self.bg_color_normal = pygame.Color(bg_color)
|
|
|
+ # 计算 hover 颜色:加深 20%
|
|
|
+ h = self.bg_color_normal
|
|
|
+ self.bg_color_hover = pygame.Color(max(0, int(h.r*0.8)), max(0, int(h.g*0.8)), max(0, int(h.b*0.8)))
|
|
|
+ self.fg_color = fg_color
|
|
|
+ self.action = action
|
|
|
+ self.relx = relx
|
|
|
+ self.rely = rely
|
|
|
+ self.anchor = anchor # 'center', 'topleft'
|
|
|
+ self.hovered = False
|
|
|
+ self._render()
|
|
|
+
|
|
|
+ def _render(self):
|
|
|
+ # 渲染多行文本
|
|
|
+ self.text_surfs = [self.font.render(line, True, self.fg_color) for line in self.lines]
|
|
|
+ widths = [surf.get_width() for surf in self.text_surfs]
|
|
|
+ heights = [surf.get_height() for surf in self.text_surfs]
|
|
|
+ total_width = max(widths)
|
|
|
+ total_height = sum(heights) + (len(heights)-1) * 5
|
|
|
+ sw, sh = self.screen.get_size()
|
|
|
+ x = int(sw * self.relx)
|
|
|
+ y = int(sh * self.rely)
|
|
|
+ # 根据锚点决定位置
|
|
|
+ if self.anchor == 'center':
|
|
|
+ topleft = (x - total_width//2 - 10, y - total_height//2 - 5)
|
|
|
+ elif self.anchor == 'topleft':
|
|
|
+ topleft = (x, y)
|
|
|
+ else:
|
|
|
+ topleft = (x - total_width//2 - 10, y - total_height//2 - 5)
|
|
|
+ self.bg_rect = pygame.Rect(topleft[0], topleft[1], total_width + 20, total_height + 10)
|
|
|
+ # 计算每行文本位置
|
|
|
+ self.text_positions = []
|
|
|
+ offset_y = self.bg_rect.y + 5
|
|
|
+ for surf in self.text_surfs:
|
|
|
+ line_x = self.bg_rect.x + (self.bg_rect.width - surf.get_width())//2 if self.anchor=='center' else self.bg_rect.x + 10
|
|
|
+ self.text_positions.append((line_x, offset_y))
|
|
|
+ offset_y += surf.get_height() + 5
|
|
|
+
|
|
|
+ def draw(self):
|
|
|
+ # 绘制背景
|
|
|
+ color = self.bg_color_hover if self.hovered else self.bg_color_normal
|
|
|
+ pygame.draw.rect(self.screen, color, self.bg_rect)
|
|
|
+ # 绘制文本
|
|
|
+ for surf, pos in zip(self.text_surfs, self.text_positions):
|
|
|
+ self.screen.blit(surf, pos)
|
|
|
+
|
|
|
+ def handle_event(self, event):
|
|
|
+ if event.type == pygame.MOUSEMOTION:
|
|
|
+ self.hovered = self.bg_rect.collidepoint(event.pos)
|
|
|
+ elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
|
|
|
+ if self.hovered and self.action:
|
|
|
+ self.action()
|
|
|
+
|
|
|
+
|
|
|
+class Menu:
|
|
|
+
|
|
|
+ def __init__(self, screen):
|
|
|
+ self.screen = screen
|
|
|
+ self.buttons = []
|
|
|
+ self._init_data()
|
|
|
+ self._create_buttons()
|
|
|
+
|
|
|
+ def _init_data(self):
|
|
|
rougeOB_data = {}
|
|
|
rougeOB_achivements = []
|
|
|
self.current_hero = "Fox"
|
|
|
self.current_difficulty = "Easy"
|
|
|
-
|
|
|
user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
|
|
|
qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
|
|
|
os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
|
|
|
@@ -191,11 +252,11 @@ class App:
|
|
|
|
|
|
for hero in ["Fox", "Boboli", "Naruto_old", "Asha", "Maria"]:
|
|
|
rougeOB_data[hero]["lv"] = R.current_lv(rougeOB_data[hero]["exp"])
|
|
|
- Fox_info = "小倩: 等级"+str(rougeOB_data["Fox"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Fox"]["exp"]) + ", 技能: 自身血量减少1则糖泡伤害增加"+str(R.FoxSkill(rougeOB_data["Fox"]["lv"]))
|
|
|
- Boboli_info = "波波丽: 等级"+str(rougeOB_data["Boboli"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Boboli"]["exp"]) + ", 技能: 每次攻击额外造成"+str(int(R.BoboliSkill(rougeOB_data["Boboli"]["lv"])*100))+"%真实伤害"
|
|
|
- Naruto_old_info = "火影: 等级"+str(rougeOB_data["Naruto_old"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Naruto_old"]["exp"]) + ", 技能: 首次攻击每只怪物时攻击力变为"+str(int(R.Naruto_oldSkill(rougeOB_data["Naruto_old"]["lv"])*100))+"%"
|
|
|
- Asha_info = "阿莎: 等级"+str(rougeOB_data["Asha"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Asha"]["exp"]) + ", 技能: 每次糖泡造成伤害恢复血量"+str(R.AshaSkill(rougeOB_data["Asha"]["lv"])*100)+"%"
|
|
|
- Maria_info = "玛莉亚: 等级"+str(rougeOB_data["Maria"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Maria"]["exp"]) + ", 技能: 每次造成伤害降低怪物近身"+str(R.MariaSkill(rougeOB_data["Maria"]["lv"])*100)+"%(最高50%)与"+str(R.MariaSkill2(rougeOB_data["Maria"]["lv"]))+"防御"
|
|
|
+ self.Fox_info = "小倩: 等级"+str(rougeOB_data["Fox"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Fox"]["exp"]) + ", 技能: 自身血量减少1则糖泡伤害增加"+str(R.FoxSkill(rougeOB_data["Fox"]["lv"]))
|
|
|
+ self.Boboli_info = "波波丽: 等级"+str(rougeOB_data["Boboli"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Boboli"]["exp"]) + ", 技能: 每次攻击额外造成"+str(int(R.BoboliSkill(rougeOB_data["Boboli"]["lv"])*100))+"%真实伤害"
|
|
|
+ self.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))+"%"
|
|
|
+ self.Asha_info = "阿莎: 等级"+str(rougeOB_data["Asha"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Asha"]["exp"]) + ", 技能: 每次糖泡造成伤害恢复血量"+str(R.AshaSkill(rougeOB_data["Asha"]["lv"])*100)+"%"
|
|
|
+ self.Maria_info = "玛莉亚: 等级"+str(rougeOB_data["Maria"]["lv"])+", 升级还需经验:"+current_lv(rougeOB_data["Maria"]["exp"]) + ", 技能: 每次造成伤害降低怪物近身"+str(R.MariaSkill(rougeOB_data["Maria"]["lv"])*100)+"%(最高50%)与"+str(R.MariaSkill2(rougeOB_data["Maria"]["lv"]))+"防御"
|
|
|
|
|
|
# 第一次打开
|
|
|
if not os.path.exists(rouge_achivements_file_path):
|
|
|
@@ -239,7 +300,7 @@ class App:
|
|
|
diff_status[data["DIFF"]] = 2
|
|
|
|
|
|
if max_level > 0:
|
|
|
- record_text = "最高挑战纪录: 通关<"+ self.diff_dic[max_diff] +str((max_level -1)//5+1)+ "-" + str((max_level-1)%5+1) + ">; 使用英雄: " + self.hero_dic[max_level_hero]
|
|
|
+ record_text = f"最高挑战纪录: 通关<{self.diff_dic[max_diff]}{(max_level -1)//5+1}-{(max_level-1)%5+1}>; 使用英雄: {self.hero_dic[max_level_hero]}"
|
|
|
else:
|
|
|
record_text = "暂无挑战记录"
|
|
|
|
|
|
@@ -270,173 +331,94 @@ class App:
|
|
|
if diff_status[dif] == 2:
|
|
|
R.pass_status[dif] = 2
|
|
|
|
|
|
- # 开始游戏
|
|
|
- self.button0 = tk.Button(master, text= "进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: "+ self.hero_dic[self.current_hero] + ")", command=lambda: self.button_general_start(self.current_hero, self.current_difficulty), bg="#C68E17", font=("Microsoft YaHei", 20))
|
|
|
- self.button0.place(relx=0.5, rely=0.29, anchor='center')
|
|
|
+ def _create_buttons(self):
|
|
|
+ # 主界面按钮
|
|
|
+ self.buttons.clear()
|
|
|
+ # "进入游戏"
|
|
|
+ text = f"进入游戏 \n (当前难度: {R.difficulty}; 当前英雄: {R.cursor_skin})"
|
|
|
+ self.buttons.append(PygameButton(self.screen, text, 0.5, 0.29, 20, "#C68E17", action=self._start_game))
|
|
|
+ # "继续游戏"
|
|
|
+ if os.path.exists(os.path.join(os.path.expanduser("~\\Documents"), "QQTPVE", "rougeOBLastGame.rougedata")):
|
|
|
+ last = load_rouge_data(os.path.join(os.path.expanduser("~\\Documents"), "QQTPVE", "rougeOBLastGame.rougedata"))
|
|
|
+ lvl = ((last["current_level"]+2)//2 -1)//5+1
|
|
|
+ stage = ((last["current_level"]+2)//2 -1)%5+1
|
|
|
+ text_c = f"继续游戏 (关卡: {lvl}-{stage}) \n (难度: {self.diff_dic[last['difficulty']]}; 英雄: {self.hero_dic[last['rouge_hero']]})"
|
|
|
+ self.buttons.append(PygameButton(self.screen, text_c, 0.5, 0.44, 18, "#C68E17", action=lambda: self._continue_game(last)))
|
|
|
+ # 任务系统
|
|
|
+ self.buttons.append(PygameButton(self.screen, "任务系统", 0.16, 0.16, 24, "#C68E17", action=self._open_task))
|
|
|
+ # 陈列馆
|
|
|
+ self.buttons.append(PygameButton(self.screen, "陈列馆", 0.16, 0.28, 18, "#C68E17", action=self._open_setting))
|
|
|
+ # 难度选择
|
|
|
+ for diff, rel in [("Easy", 0.1), ("Normal", 0.18), ("Hell", 0.26), ("Hell+", 0.34)]:
|
|
|
+ enabled = R.pass_status.get(diff, 0) > 0
|
|
|
+ text = f"● 选择{self.diff_dic[diff]}难度" if enabled else f"○ {self.diff_dic[diff]}难度(未解锁)"
|
|
|
+ color = "#C47451" if enabled else "#614051"
|
|
|
+ action = lambda d=diff: self._choose_diff(d) if enabled else None
|
|
|
+ self.buttons.append(PygameButton(self.screen, text, 0.75, rel, 12, color, action=action))
|
|
|
+ # ================================= 英雄选择 =================================
|
|
|
+ heroes = ["Fox", "Boboli", "Naruto_old", "Asha", "Maria", "Surprise"]
|
|
|
+ x_position = 0.07
|
|
|
+ y_positions = [0.64, 0.70, 0.76, 0.82, 0.88, 0.49]
|
|
|
+ for hero, y in zip(heroes, y_positions):
|
|
|
+ text = f"● 选择{self.hero_dic[hero]}"
|
|
|
+ self.buttons.append(PygameButton(self.screen, text, x_position, y, 12, "#C47451", action=lambda h=hero: self._choose_hero(h), anchor="topleft"))
|
|
|
+ # 随机开局
|
|
|
+ self.buttons.append(PygameButton(self.screen, "● 随机开局", x_position, 0.94, 12, "#C47451", action=lambda: self._choose_hero("Random"), anchor="topleft"))
|
|
|
+ # 英雄信息提示
|
|
|
+ infos = [getattr(self, attr) for attr in ['Fox_info','Boboli_info','Naruto_old_info','Asha_info','Maria_info']]
|
|
|
+ for info, y in zip(infos, y_positions):
|
|
|
+ self.buttons.append(PygameButton(self.screen, info, 0.2, y, 12, "#E6A9EC", fg_color=(0,0,0), anchor="topleft"))
|
|
|
+ # ==========================================================================
|
|
|
+ # 最高记录
|
|
|
+ record = getattr(self, 'record_text', "暂无挑战记录")
|
|
|
+ self.buttons.append(PygameButton(self.screen, record, 0.5, 0.56, 14, "#7E354D", fg_color=(255,255,255)))
|
|
|
+
|
|
|
+ # 各个按钮动作方法
|
|
|
+ def _start_game(self):
|
|
|
+ self.screen = None
|
|
|
+ rougeGen.main_func()
|
|
|
+ rogue_control.Control()
|
|
|
|
|
|
- # 继续游戏
|
|
|
- if os.path.exists(last_game_file_path):
|
|
|
- last_game_file = load_rouge_data(last_game_file_path)
|
|
|
- self.button000 = tk.Button(master, text= "继续游戏 (关卡: " + str(((last_game_file["current_level"]+2)//2 -1)//5+1) + "-" + str(((last_game_file["current_level"]+2)//2-1)%5+1) + "结束) \n (难度: " + self.diff_dic[last_game_file["difficulty"]] + "; 英雄: "+ self.hero_dic[last_game_file["rouge_hero"]] + ")",
|
|
|
- command=lambda: self.button_continue(last_game_file, last_game_file_path), bg="#C68E17", font=("Microsoft YaHei", 18))
|
|
|
- self.button000.place(relx=0.5, rely=0.44, anchor='center')
|
|
|
+ def _continue_game(self, last):
|
|
|
+ # 同原tk逻辑,将last数据写入R然后启动Control
|
|
|
+ rogue_control.Control(is_continue=True)
|
|
|
|
|
|
- # 任务系统
|
|
|
- self.button_task = tk.Button(master, text= "任务系统", command=lambda: self.button_task_start(), bg="#C68E17", font=("Microsoft YaHei", 24))
|
|
|
- self.button_task.place(relx=0.16, rely=0.16, anchor='center')
|
|
|
-
|
|
|
- # 选择皮肤
|
|
|
- self.button_task = tk.Button(master, text= "陈列馆", command=lambda: self.button_setting_start(), bg="#C68E17", font=("Microsoft YaHei", 18))
|
|
|
- self.button_task.place(relx=0.16, rely=0.28, anchor='center')
|
|
|
-
|
|
|
- # 选择简单
|
|
|
- self.button_easy = tk.Button(master, text="● 选择简单难度", command=lambda: self.button_choose_diff("Easy"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button_easy.place(relx=0.75, rely=0.1, anchor='w')
|
|
|
-
|
|
|
- # 选择普通
|
|
|
- if max_diff in ["Normal", "Hell", "Hell+"] or max_level >= 15:
|
|
|
- self.button_normal = tk.Button(master, text="● 选择困难难度", command=lambda: self.button_choose_diff("Normal"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button_normal.place(relx=0.75, rely=0.18, anchor='w')
|
|
|
- # 选择随机
|
|
|
- if abs(60*datetime.now().hour+datetime.now().minute - int(rougeOB_other_data["LastRandom"])) >= 3:
|
|
|
- self.button5 = tk.Button(master, text="● 随机开局", command=lambda: self.button_choose_hero("Random"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button5.place(relx=0.07, rely=0.95, anchor='w')
|
|
|
- else:
|
|
|
- self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12))
|
|
|
- self.button5.place(relx=0.07, rely=0.95, anchor='w')
|
|
|
- # 提示用
|
|
|
- if abs(60*datetime.now().hour+datetime.now().minute - rougeOB_other_data["LastRandom"]) >= 3:
|
|
|
- self.button109 = tk.Button(master, text="随机选择上列英雄,并获得<引路人>(本选项冷却时间3分钟)", bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button109.place(relx=0.2, rely=0.95, anchor='w')
|
|
|
- else:
|
|
|
- last_time = rougeOB_other_data["LastRandom"]
|
|
|
- self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(选项冷却中-下次开启-"+ f"{((last_time + 3) // 60) % 24:02d}:{(last_time + 3) % 60:02d}" +")", bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button109.place(relx=0.2, rely=0.95, anchor='w')
|
|
|
- else:
|
|
|
- self.button_normal = tk.Button(master, text="○ 困难难度(通关简单后解锁)", bg="#614051", font=("Microsoft YaHei", 12))
|
|
|
- self.button_normal.place(relx=0.75, rely=0.18, anchor='w')
|
|
|
- # 选择随机
|
|
|
- self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12))
|
|
|
- self.button5.place(relx=0.07, rely=0.95, anchor='w')
|
|
|
- self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(通关一次简单难度后开启)", bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button109.place(relx=0.2, rely=0.95, anchor='w')
|
|
|
-
|
|
|
- # 选择炼狱
|
|
|
- if max_diff in ["Hell", "Hell+"] or (max_diff == "Normal" and max_level >= 15):
|
|
|
- self.button_hell = tk.Button(master, text="● 选择炼狱难度", command=lambda: self.button_choose_diff("Hell"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button_hell.place(relx=0.75, rely=0.26, anchor='w')
|
|
|
- else:
|
|
|
- self.button_hell = tk.Button(master, text="○ 炼狱难度(通关困难后解锁)", bg="#614051", font=("Microsoft YaHei", 12))
|
|
|
- self.button_hell.place(relx=0.75, rely=0.26, anchor='w')
|
|
|
+ def _open_task(self):
|
|
|
+ from rougetask import Task
|
|
|
+ Task(pygame.display.set_mode((800, 600)))
|
|
|
|
|
|
- # 选择炼狱+
|
|
|
- if max_diff == "Hell+" or (max_diff == "Hell" and max_level >= 15):
|
|
|
- self.button_hell_plus = tk.Button(master, text="● 选择炼狱+难度", command=lambda: self.button_choose_diff("Hell+"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button_hell_plus.place(relx=0.75, rely=0.34, anchor='w')
|
|
|
- else:
|
|
|
- self.button_hell_plus = tk.Button(master, text="○ 炼狱+难度(通关炼狱后解锁)", bg="#614051", font=("Microsoft YaHei", 12))
|
|
|
- self.button_hell_plus.place(relx=0.75, rely=0.34, anchor='w')
|
|
|
-
|
|
|
- # 选择Fox
|
|
|
- self.button1 = tk.Button(master, text="● 选择小倩", command=lambda: self.button_choose_hero("Fox"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button1.place(relx=0.07, rely=0.65, anchor='w')
|
|
|
-
|
|
|
- # 选择Boboli
|
|
|
- self.button2 = tk.Button(master, text="● 选择波波丽", command=lambda: self.button_choose_hero("Boboli"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button2.place(relx=0.07, rely=0.71, anchor='w')
|
|
|
-
|
|
|
- # 选择Naruto_old
|
|
|
- self.button3 = tk.Button(master, text="● 选择火影", command=lambda: self.button_choose_hero("Naruto_old"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button3.place(relx=0.07, rely=0.77, anchor='w')
|
|
|
-
|
|
|
- # 选择Asha
|
|
|
- self.button4 = tk.Button(master, text="● 选择阿莎", command=lambda: self.button_choose_hero("Asha"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button4.place(relx=0.07, rely=0.83, anchor='w')
|
|
|
-
|
|
|
- # 选择Maria
|
|
|
- self.button5 = tk.Button(master, text="● 选择玛莉亚", command=lambda: self.button_choose_hero("Maria"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button5.place(relx=0.07, rely=0.89, anchor='w')
|
|
|
-
|
|
|
- # 选择???
|
|
|
- self.button6 = tk.Button(master, text="● 选择???", command=lambda: self.button_choose_hero("Surprise"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- self.button6.place(relx=0.07, rely=0.5, anchor='w')
|
|
|
-
|
|
|
- # 选择随机
|
|
|
- # if abs(60*datetime.now().hour+datetime.now().minute - int(rougeOB_other_data["LastRandom"])) >= 3:
|
|
|
- # self.button5 = tk.Button(master, text="● 随机开局", command=lambda: self.button_choose_hero("Random"), bg="#C47451", font=("Microsoft YaHei", 12))
|
|
|
- # self.button5.place(relx=0.07, rely=0.95, anchor='w')
|
|
|
- # else:
|
|
|
- # self.button5 = tk.Button(master, text="● 随机开局", bg="#614051", font=("Microsoft YaHei", 12))
|
|
|
- # self.button5.place(relx=0.07, rely=0.95, anchor='w')
|
|
|
-
|
|
|
- # 通关成就展示
|
|
|
- self.button100 = tk.Button(master, text=record_text, bg="#7E354D", font=("Microsoft YaHei", 14))
|
|
|
- self.button100.place(relx=0.5, rely=0.56, anchor='center')
|
|
|
-
|
|
|
- # 提示用
|
|
|
- self.button101 = tk.Button(master, text=Fox_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button101.place(relx=0.2, rely=0.65, anchor='w')
|
|
|
-
|
|
|
- # 提示用
|
|
|
- self.button102 = tk.Button(master, text=Boboli_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button102.place(relx=0.2, rely=0.71, anchor='w')
|
|
|
-
|
|
|
- # 提示用
|
|
|
- self.button103 = tk.Button(master, text=Naruto_old_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button103.place(relx=0.2, rely=0.77, anchor='w')
|
|
|
-
|
|
|
- # 提示用
|
|
|
- self.button104 = tk.Button(master, text=Asha_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button104.place(relx=0.2, rely=0.83, anchor='w')
|
|
|
-
|
|
|
- # 提示用
|
|
|
- self.button105 = tk.Button(master, text=Maria_info, bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- self.button105.place(relx=0.2, rely=0.89, anchor='w')
|
|
|
-
|
|
|
- # 提示用
|
|
|
- # if abs(60*datetime.now().hour+datetime.now().minute - rougeOB_other_data["LastRandom"]) >= 3:
|
|
|
- # self.button109 = tk.Button(master, text="随机选择上列英雄,并获得<引路人>(本选项冷却时间3分钟)", bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- # self.button109.place(relx=0.2, rely=0.95, anchor='w')
|
|
|
- # else:
|
|
|
- # last_time = rougeOB_other_data["LastRandom"]
|
|
|
- # self.button109 = tk.Button(master, text="随机选择上列英雄并获得<引路人>(选项冷却中-下次开启-"+ f"{((last_time + 3) // 60) % 24:02d}:{(last_time + 3) % 60:02d}" +")", bg="#E6A9EC", font=("Microsoft YaHei", 12))
|
|
|
- # self.button109.place(relx=0.2, rely=0.95, anchor='w')
|
|
|
-
|
|
|
- # 通用开局
|
|
|
- def button_general_start(self, hero, difficulty):
|
|
|
+ def _open_setting(self):
|
|
|
+ from rougesetting import Setting
|
|
|
+ Setting(pygame.display.set_mode((800, 600)))
|
|
|
+
|
|
|
+ def _choose_diff(self, diff):
|
|
|
+ R.difficulty = diff
|
|
|
+ self._create_buttons()
|
|
|
+
|
|
|
+ def _choose_hero(self, hero):
|
|
|
if hero == "Random":
|
|
|
hero = random.choice(["Fox","Boboli","Naruto_old","Asha","Maria","Surprise"])
|
|
|
- R.show_cursor = True
|
|
|
- user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
|
|
|
- qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
|
|
|
- os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
|
|
|
- other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
|
|
|
- if not os.path.exists(other_file_path):
|
|
|
- rougeOB_other_data = {"Bomb": [],
|
|
|
- "Pet": [],
|
|
|
- "Hat": [],
|
|
|
- "LastRandom": int(60*datetime.now().hour+datetime.now().minute),
|
|
|
- "Other": []}
|
|
|
- save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
|
|
|
- else:
|
|
|
- rougeOB_other_data = load_rouge_data(other_file_path)
|
|
|
- rougeOB_other_data["LastRandom"] = int(60*datetime.now().hour+datetime.now().minute)
|
|
|
- save_encrypt_single_rouge_file(rougeOB_other_data, "rougeOBOther")
|
|
|
-
|
|
|
- with open("config.json", "r", encoding="utf-8") as json_file:
|
|
|
- mapsetdata = json.load(json_file)
|
|
|
- mapsetdata["map_set"] = "rogueMapSet"
|
|
|
- mapsetdata["your_hero"] = hero
|
|
|
- R.difficulty = difficulty
|
|
|
- with open("config.json", "w", encoding="utf-8") as json_file:
|
|
|
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
|
|
|
- self.master.destroy()
|
|
|
- rougeGen.main_func()
|
|
|
- control.Control()
|
|
|
+ R.cursor_skin = hero
|
|
|
+ self._create_buttons()
|
|
|
+
|
|
|
+ def run(self):
|
|
|
+ clock = pygame.time.Clock()
|
|
|
+ while True:
|
|
|
+ for event in pygame.event.get():
|
|
|
+ if event.type == pygame.QUIT:
|
|
|
+ pygame.quit()
|
|
|
+ sys.exit()
|
|
|
+ for btn in self.buttons:
|
|
|
+ btn.handle_event(event)
|
|
|
+ self.screen.fill((30,30,30))
|
|
|
+ for btn in self.buttons:
|
|
|
+ btn.draw()
|
|
|
+ pygame.display.flip()
|
|
|
+ clock.tick(30)
|
|
|
|
|
|
# 读取上次存档
|
|
|
def button_continue(self, last_data, last_path):
|
|
|
- self.master.destroy()
|
|
|
+ # self.master.destroy()
|
|
|
R.continuing_game = True
|
|
|
G.CURRENT_LEVEL = last_data["current_level"]
|
|
|
R.map_json_dic = last_data["map_json_dic"]
|
|
|
@@ -487,52 +469,7 @@ class App:
|
|
|
else:
|
|
|
print("???")
|
|
|
|
|
|
- control.Control(is_continue=True)
|
|
|
-
|
|
|
- # 任务系统
|
|
|
- def button_task_start(self):
|
|
|
- self.master.destroy()
|
|
|
- app_task = tk.Tk()
|
|
|
- rougetask.Task(app_task)
|
|
|
-
|
|
|
- # 选择皮肤
|
|
|
- def button_setting_start(self):
|
|
|
- self.master.destroy()
|
|
|
- app_setting = tk.Tk()
|
|
|
- rougesetting.Setting(app_setting)
|
|
|
-
|
|
|
- # 通用英雄
|
|
|
- def button_choose_hero(self, hero):
|
|
|
- self.current_hero = hero
|
|
|
- with open("config.json", "r", encoding="utf-8") as json_file:
|
|
|
- mapsetdata = json.load(json_file)
|
|
|
- mapsetdata["map_set"] = "rogueMapSet"
|
|
|
- mapsetdata["your_hero"] = hero
|
|
|
- with open("config.json", "w", encoding="utf-8") as json_file:
|
|
|
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
|
|
|
- if hero == "Random":
|
|
|
- self.button0.config(text="进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: 随机)")
|
|
|
- print("已选择随机")
|
|
|
- else:
|
|
|
- self.button0.config(text="进入游戏" + " \n (当前难度: " + self.diff_dic[self.current_difficulty] + "; 当前英雄: " + self.hero_dic[self.current_hero] + ")")
|
|
|
- print("已选择" + hero)
|
|
|
-
|
|
|
- # 选择难度
|
|
|
- def button_choose_diff(self, diff):
|
|
|
- self.current_difficulty = diff
|
|
|
- R.difficulty = self.current_difficulty
|
|
|
- with open("config.json", "r", encoding="utf-8") as json_file:
|
|
|
- mapsetdata = json.load(json_file)
|
|
|
- mapsetdata["map_set"] = "rogueMapSet"
|
|
|
- with open("config.json", "w", encoding="utf-8") as json_file:
|
|
|
- json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
|
|
|
-
|
|
|
- if self.current_hero == "Random":
|
|
|
- self.button0.config(text=f"进入游戏 \n (当前难度: {self.diff_dic[self.current_difficulty]}; 当前英雄: 随机)")
|
|
|
- print("已选择随机")
|
|
|
- else:
|
|
|
- self.button0.config(text=f"进入游戏 \n (当前难度: {self.diff_dic[self.current_difficulty]}; 当前英雄: {self.hero_dic[self.current_hero]})")
|
|
|
- print("已选择" + diff)
|
|
|
+ rogue_control.Control(is_continue=True)
|
|
|
|
|
|
|
|
|
def show_prompt():
|
|
|
@@ -573,6 +510,55 @@ def check_window_exists():
|
|
|
return False
|
|
|
|
|
|
|
|
|
+class Launcher:
|
|
|
+ def __init__(self):
|
|
|
+ pygame.init()
|
|
|
+ self.screen = pygame.display.set_mode(W.WINDOW_SIZE)
|
|
|
+ pygame.display.set_caption(W.WINDOW_CAPTION)
|
|
|
+ self.cfg_json = {}
|
|
|
+ self.display_flags = None
|
|
|
+ self.init_config()
|
|
|
+ # 预加载资源
|
|
|
+ self.preload_resources()
|
|
|
+ # 启动菜单
|
|
|
+ self.menu = Menu(self.screen)
|
|
|
+ self.menu.run()
|
|
|
+
|
|
|
+ def init_config(self):
|
|
|
+ try:
|
|
|
+ with open("config.json", encoding="utf-8") as f:
|
|
|
+ self.cfg_json = json.load(f)
|
|
|
+ except json.JSONDecodeError:
|
|
|
+ with open("config.json", encoding="utf-8_sig") as f:
|
|
|
+ self.cfg_json = json.load(f)
|
|
|
+ if not self.cfg_json["frame_screen"]:
|
|
|
+ self.display_flags = pygame.NOFRAME
|
|
|
+ if self.cfg_json["full_screen"]:
|
|
|
+ self.display_flags = pygame.FULLSCREEN | pygame.HWSURFACE | pygame.DOUBLEBUF
|
|
|
+ try:
|
|
|
+ if self.cfg_json["v_sync"] and self.cfg_json["frame_screen"] and not self.cfg_json["full_screen"]:
|
|
|
+ self.display_flags = pygame.HWSURFACE | pygame.DOUBLEBUF
|
|
|
+ # self.display_flags = pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.OPENGL
|
|
|
+ elif self.cfg_json["v_sync"] and not self.cfg_json["frame_screen"]:
|
|
|
+ self.display_flags |= pygame.HWSURFACE | pygame.DOUBLEBUF
|
|
|
+ elif self.cfg_json["v_sync"] and self.cfg_json["full_screen"]:
|
|
|
+ self.display_flags = pygame.FULLSCREEN | pygame.HWSURFACE | pygame.DOUBLEBUF
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+
|
|
|
+ def init_window(self):
|
|
|
+ self.screen = pygame.display.set_mode(W.WINDOW_SIZE, flags=self.display_flags)
|
|
|
+ pygame.display.set_icon(pygame.image.load("res/img/ui/icon.png").convert_alpha())
|
|
|
+ for i in range(10):
|
|
|
+ file_name = "itemNum_0_" + str(i) + ".png"
|
|
|
+ img = pygame.image.load("res/img/ui/number/" + file_name).convert_alpha()
|
|
|
+ G.NUMBER_IMG.append(img)
|
|
|
+
|
|
|
+ def preload_resources(self):
|
|
|
+ with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
+ executor.submit(Control.preload)
|
|
|
+
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
|
# # 定义日志文件路径
|
|
|
# # log_file_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "program.log")
|
|
|
@@ -586,7 +572,4 @@ if __name__ == "__main__":
|
|
|
print("=========== start ==============")
|
|
|
if check_window_exists():
|
|
|
show_prompt()
|
|
|
-
|
|
|
- root = tk.Tk()
|
|
|
- app = App(root)
|
|
|
- root.mainloop()
|
|
|
+ Launcher()
|