From 2dae05a43374c3b95028595728ae9ce5ad91d8f0 Mon Sep 17 00:00:00 2001 From: eee555 <2234208506@qq.com> Date: Wed, 9 Oct 2024 23:12:21 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Aready=E3=80=81palying=E7=AD=89?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=EF=BC=8C=E4=BF=9D=E5=AD=98=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.py | 2 +- src/mainWindowGUI.py | 1 + src/mineSweeperGUI.py | 17 ++++++++++++----- src/ui/mineLabel.py | 8 ++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main.py b/src/main.py index 1f6a5c1..57dcc23 100644 --- a/src/main.py +++ b/src/main.py @@ -71,7 +71,7 @@ def find_window(class_name, window_name): # 此时可以改雷数、改格子大小(ctrl+滚轮)、行数、列数(拖拉边框)。 # 'study': 研究状态。截图后进入。应该设计第二种方式进入研究状态,没想好。 # 'show': 游戏中,展示智能分析结果,按住空格进入。 -# 'modify': 调整状态。'ready'下,拖拉边框时进入,拖拉结束后自动转为'ready'。 +# 'modify': 调整状态。'ready'下,拖拉边框时进入,拖拉结束后自动转为'ready'。未使用,拟废弃。 # 'playing': 正在游戏状态、标准模式、不筛选3BV、且没有看概率计算结果,游戏结果是official的。 # 'joking': 正在游戏状态,游戏中看过概率计算结果,游戏结果不是official的。 # 'fail': 游戏失败,踩雷了。 diff --git a/src/mainWindowGUI.py b/src/mainWindowGUI.py index 15e3986..92fb006 100644 --- a/src/mainWindowGUI.py +++ b/src/mainWindowGUI.py @@ -9,6 +9,7 @@ class MainWindow(QtWidgets.QMainWindow): closeEvent_ = QtCore.pyqtSignal() flag_drag_border = False minimum_counter = 0 + def closeEvent(self, event): self.closeEvent_.emit() diff --git a/src/mineSweeperGUI.py b/src/mineSweeperGUI.py index 0eecf52..9a8fe44 100644 --- a/src/mineSweeperGUI.py +++ b/src/mineSweeperGUI.py @@ -49,8 +49,11 @@ def __init__(self, MainWindow, args): self.actionzi_ding_yi.triggered.connect(self.action_CEvent) self.actiongao_ji.triggered.connect(lambda: self.predefined_Board(3)) def save_evf_file_integrated(): - self.dump_evf_file_data() - self.save_evf_file() + if self.game_state != "ready" and self.game_state != "playing" and\ + self.game_state != "show" and self.game_state != "study" and\ + self.game_state != "joking": + self.dump_evf_file_data() + self.save_evf_file() self.action_save.triggered.connect(save_evf_file_integrated) self.action_replay.triggered.connect(self.replay_game) self.actiontui_chu.triggered.connect(QCoreApplication.instance().quit) @@ -284,6 +287,8 @@ def chording_ai(self, i, j): # 0,4, 5, 6, 7, 8, 9, 10代表:标准、win7、 # 经典无猜、强无猜、弱无猜、准无猜、强可猜、弱可猜 # i,j为索引 + if not self.cell_is_in_board(i, j): + return if self.label.ms_board.mouse_state != 5 and self.label.ms_board.mouse_state != 6: return if self.label.ms_board.game_board[i][j] >= 10 or\ @@ -718,7 +723,9 @@ def save_evf_file(self): file_name += "_fail" if not self.label.ms_board.is_fair: file_name += "_cheat" - if not self.checksum_module_ok(): + if bytes(self.label.ms_board.software).decode()[0] != "元": + file_name += "_trans" + elif not self.checksum_module_ok(): file_name += "_fake" self.label.ms_board.save_to_evf_file(file_name) @@ -1397,9 +1404,9 @@ def is_fair(self) -> bool: return False return self.game_state == "win" or self.game_state == "fail" - # def cell_is_in_board(self, i, j): + def cell_is_in_board(self, i, j): # 点在局面内,单位是格不是像素 - # return i >= 0 and i < self.row and j >= 0 and j < self.column + return i >= 0 and i < self.row and j >= 0 and j < self.column def pos_is_in_board(self, i, j) -> bool: # 点在局面内,单位是像素不是格 diff --git a/src/ui/mineLabel.py b/src/ui/mineLabel.py index 64ebc83..50a6a1b 100644 --- a/src/ui/mineLabel.py +++ b/src/ui/mineLabel.py @@ -1,6 +1,5 @@ from PyQt5 import QtWidgets, QtCore -from PyQt5.QtGui import QPolygonF, QPainter, QColor, QPixmap, QFont, QPainterPath -from PyQt5.QtWidgets import QWidget +from PyQt5.QtGui import QPolygonF, QPainter, QPixmap, QPainterPath import ms_toollib as ms from PyQt5.QtCore import QPoint, Qt # from PyQt5.QtSvg import QSvgWidget @@ -112,10 +111,7 @@ def mouseReleaseEvent(self, e): #所以获取释放点相对本标签的偏移量,矫正发射的信号 xx = int(e.localPos().x() - 4) yy = int(e.localPos().y() - 4) - # xx = int((e.localPos().x() - 4) // self.pixSize) - # yy = int((e.localPos().y() - 4) // self.pixSize) - # print('抬起位置{}, {}'.format(xx, yy)) - # print(e.button ()) + if yy < 0 or xx < 0 or yy >= self.row * self.pixSize or\ xx >= self.column * self.pixSize: self.current_x = self.row * self.pixSize