From c46d104c05695e2cf6f697b3cde3e9cbac913968 Mon Sep 17 00:00:00 2001
From: eee555 <2234208506@qq.com>
Date: Sat, 10 Aug 2024 00:01:02 +0800
Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=BF=AB=E6=8D=B7=E9=94=AE?=
=?UTF-8?q?=E5=88=87=E6=8D=A2=E9=9A=BE=E5=BA=A6=E5=90=8E=EF=BC=8C=E5=B1=80?=
=?UTF-8?q?=E9=9D=A2=E7=BA=A6=E6=9D=9F=E4=B8=8D=E8=83=BD=E5=8F=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/gameScoreBoard.py | 2 +-
src/gameSettings.py | 34 +++----
src/mineSweeperGUI.py | 31 ++++--
src/minesweeper_master.py | 15 +++
src/ui/en_US.ts | 201 +++++++++++++++++++++++---------------
src/ui/ui_gameSettings.py | 2 +-
uiFiles/ui_gs.ui | 2 +-
7 files changed, 177 insertions(+), 110 deletions(-)
diff --git a/src/gameScoreBoard.py b/src/gameScoreBoard.py
index 158fd5d..b0fc236 100644
--- a/src/gameScoreBoard.py
+++ b/src/gameScoreBoard.py
@@ -232,7 +232,7 @@ def update_namespace(self, ms_board, index_type):
"thrp": ms_board.thrp,
"corr": ms_board.corr,
"ce": ms_board.ce,
- "ce_s": ms_board.ce_s,
+ "ce_s": ms_board.ce_s, # 一直为0
})
diff --git a/src/gameSettings.py b/src/gameSettings.py
index 282bab4..d1d320c 100644
--- a/src/gameSettings.py
+++ b/src/gameSettings.py
@@ -17,18 +17,18 @@
from PyQt5.QtGui import QPixmap
class ui_Form(Ui_Form):
- def __init__(self, game_setting_path, r_path, pix_size):
- # 设置界面的参数,主要从配置文件里来,pix_size除外
- self.game_setting_path = game_setting_path
- self.r_path = r_path
+ def __init__(self, mainWindow):
+ # 设置界面的参数,不能用快捷键修改的从配置文件里来;能用快捷键修改的从mainWindow来
+ self.game_setting_path = mainWindow.game_setting_path
+ self.r_path = mainWindow.r_path
config = configparser.ConfigParser()
- config.read(game_setting_path, encoding='utf-8')
- self.gameMode = config.getint('DEFAULT','gameMode')
+ config.read(self.game_setting_path, encoding='utf-8')
+ self.gameMode = mainWindow.gameMode
self.transparency = config.getint('DEFAULT','transparency')
- self.pixSize = pix_size
- self.row = config.getint("DEFAULT", "row")
- self.column = config.getint("DEFAULT", "column")
- self.mineNum = config.getint("DEFAULT", "mineNum")
+ self.pixSize = mainWindow.pixSize
+ self.row = mainWindow.row
+ self.column = mainWindow.column
+ self.mineNum = mainWindow.mineNum
self.auto_replay = config.getint("DEFAULT", "auto_replay")
self.allow_auto_replay = config.getboolean("DEFAULT", "allow_auto_replay")
@@ -43,19 +43,9 @@ def __init__(self, game_setting_path, r_path, pix_size):
self.filter_forever = config.getboolean("DEFAULT", "filter_forever")
# self.auto_show_score = config.getint("DEFAULT", "auto_show_score") # 自动弹成绩
self.end_then_flag = config.getboolean("DEFAULT", "end_then_flag") # 游戏结束后自动标雷
+ self.board_constraint = mainWindow.board_constraint
+ self.attempt_times_limit = mainWindow.attempt_times_limit
- if (self.row, self.column, self.mineNum) == (8, 8, 10):
- self.board_constraint = config["BEGINNER"]["board_constraint"]
- self.attempt_times_limit = config.getint('BEGINNER', 'attempt_times_limit')
- elif (self.row, self.column, self.mineNum) == (16, 16, 40):
- self.board_constraint = config["INTERMEDIATE"]["board_constraint"]
- self.attempt_times_limit = config.getint('INTERMEDIATE', 'attempt_times_limit')
- elif (self.row, self.column, self.mineNum) == (16, 30, 99):
- self.board_constraint = config["EXPERT"]["board_constraint"]
- self.attempt_times_limit = config.getint('EXPERT', 'attempt_times_limit')
- else:
- self.board_constraint = config["CUSTOM"]["board_constraint"]
- self.attempt_times_limit = config.getint('CUSTOM', 'attempt_times_limit')
self.alter = False
self.Dialog = RoundQDialog()
diff --git a/src/mineSweeperGUI.py b/src/mineSweeperGUI.py
index f317b5d..e286849 100644
--- a/src/mineSweeperGUI.py
+++ b/src/mineSweeperGUI.py
@@ -266,7 +266,10 @@ def mineAreaLeftRelease(self, i, j):
# 正式埋雷开始
self.layMine(i // self.pixSize, j // self.pixSize)
- self.game_state = 'playing'
+ if self.board_constraint:
+ self.game_state = 'joking'
+ else:
+ self.game_state = 'playing'
if self.player_designator[:6] != "[live]":
self.disable_screenshot()
@@ -537,9 +540,9 @@ def gameWin(self): # 成功后改脸和状态变量,停时间
def checksum_module_ok(self):
# 检查校验和模块的签名
# 调试的时候不会自动存录像,除非将此处改为return True
- # return True
- return hashlib.sha256(bytes(metaminesweeper_checksum.get_self_key())).hexdigest() ==\
- '590028493bb58a25ffc76e2e2ad490df839a1f449435c35789d3119ca69e5d4f'
+ return True
+ # return hashlib.sha256(bytes(metaminesweeper_checksum.get_self_key())).hexdigest() ==\
+ # '590028493bb58a25ffc76e2e2ad490df839a1f449435c35789d3119ca69e5d4f'
def save_evf_file(self):
# 搜集本局各种信息,存成evf文件
@@ -819,7 +822,7 @@ def setBoard_and_start(self, row, column, mineNum):
def action_NEvent(self):
# 游戏设置
self.actionChecked('N')
- ui = gameSettings.ui_Form(self.game_setting_path, self.r_path, self.pixSize)
+ ui = gameSettings.ui_Form(self)
ui.Dialog.setModal(True)
ui.Dialog.show()
ui.Dialog.exec_()
@@ -828,7 +831,7 @@ def action_NEvent(self):
self.pixSize = ui.pixSize
for i in range(4):
self.predefinedBoardPara[i]['pix_size'] = ui.pixSize
-
+
self.gameStart()
self.gameMode = ui.gameMode
@@ -845,8 +848,22 @@ def action_NEvent(self):
self.set_country_flag()
self.autosave_video = ui.autosave_video
self.filter_forever = ui.filter_forever
+
self.board_constraint = ui.board_constraint
self.attempt_times_limit = ui.attempt_times_limit
+ if (self.row, self.column, self.mineNum) == (8, 8, 10):
+ self.predefinedBoardPara[1]['attempt_times_limit'] = self.attempt_times_limit
+ self.predefinedBoardPara[1]['board_constraint'] = self.board_constraint
+ elif (self.row, self.column, self.mineNum) == (16, 16, 40):
+ self.predefinedBoardPara[2]['attempt_times_limit'] = self.attempt_times_limit
+ self.predefinedBoardPara[2]['board_constraint'] = self.board_constraint
+ elif (self.row, self.column, self.mineNum) == (16, 30, 99):
+ self.predefinedBoardPara[3]['attempt_times_limit'] = self.attempt_times_limit
+ self.predefinedBoardPara[3]['board_constraint'] = self.board_constraint
+ else:
+ self.predefinedBoardPara[0]['attempt_times_limit'] = self.attempt_times_limit
+ self.predefinedBoardPara[0]['board_constraint'] = self.board_constraint
+
self.end_then_flag = ui.end_then_flag # 游戏结束后自动标雷
# self.importLEDPic(self.pixSize)
@@ -1083,7 +1100,7 @@ def action_OpenFile(self, openfile_name = None):
if isinstance(video, ms.EvfVideo):
self.score_board_manager.with_namespace({
"checksum_ok": self.checksum_guard.valid_checksum(video.raw_data[:-33], video.checksum),
- "is_official": video.is_official, # 此处拼写错误,将修改
+ "is_official": video.is_official,
"is_fair": video.is_fair
})
video.analyse_for_features(["high_risk_guess", "jump_judge", "needless_guess",
diff --git a/src/minesweeper_master.py b/src/minesweeper_master.py
index d613016..d4a02f7 100644
--- a/src/minesweeper_master.py
+++ b/src/minesweeper_master.py
@@ -477,6 +477,21 @@ def main():
# ]
# print2(enumerateChangeBoard2(board, game_board, [(2, 3), (3, 2), (2, 2)])[0])
+
+ constraints = {
+ "sin": math.sin,
+ "tan": math.tan,
+ "cos": math.cos,
+ } # 也许还要加row, column, mine_num, level, mode
+ board_constraint="all([1,2,3])"
+ if "bbbv" in board_constraint:
+ constraints.update({"bbbv": 120})
+ try:
+ expression_flag = safe_eval(board_constraint, globals=constraints)
+ print(expression_flag)
+ except:
+ print("wrong")
+
...
if __name__ == '__main__':
diff --git a/src/ui/en_US.ts b/src/ui/en_US.ts
index 98d3487..b903689 100644
--- a/src/ui/en_US.ts
+++ b/src/ui/en_US.ts
@@ -4,17 +4,17 @@
Form
-
+
游戏设置
Game Settings
-
+
确定
OK
-
+
取消
Cancel
@@ -26,35 +26,35 @@
%
- %
+ %
-
+
结束后标雷
Fill Finished Board With Flags
-
+
标识:
Label:
-
+
比赛后缀:
Tournament:
勾选后永远使用筛选法埋雷,否则会智能改用调整法
- When ticked, always use filtering algorithm to generate boards, otherwise the game will decide to use the adjustment algorithm
+ When ticked, always use filtering algorithm to generate boards, otherwise the game will decide to use the adjustment algorithm
-
+
永远使用筛选法埋雷(不推荐)
Use filtering algorithm (not recommended)
-
+
自动保存录像(推荐)
Auto save video (recommended)
@@ -64,82 +64,82 @@
Country:
-
+
游戏模式:
Mode:
-
+
方格边长:
Zoom:
-
+
标准
Standard
-
+
Win7
Win7
-
+
强无猜
Strong solvable
-
+
弱无猜
Weak solvable
-
+
竞速无猜
Competitive solvable
-
+
准无猜
To be solvable
-
+
强可猜
Strong guessable
-
+
弱可猜
Weak guessable
-
+
自动重开:
Auto restart:
-
+
允许纪录弹窗(推荐)
- Allow popovers for best scores (recommended)
+ Allow popovers for best scores (recommended)
-
+
尝试次数:
Attempts:
-
+
局面约束:
Constraint:
-
+
关于
About
-
+
Space
Space
@@ -199,54 +199,54 @@ p, li { white-space: pre-wrap; }
Mines
-
+
快捷键设置
Shortcuts
-
+
模式:
Mode:
-
+
雷数:
Mines:
-
+
高度:
Height:
-
+
宽度:
Width:
-
+
边长:
Zoom:
-
+
快捷键[4]
Shortcut [4]
-
+
快捷键[5]
Shortcut [5]
-
+
快捷键[6]
Shortcut [6]
允许记录弹窗(推荐)
- Allow popovers for best scores (recommended)
+ Allow popovers for best scores (recommended)
@@ -296,12 +296,12 @@ p, li { white-space: pre-wrap; }
②Anyone can use any part of the project source code in any project, and you are welcome to make valuable comments on the project home page.
-
+
国家或地区:
Country or region:
-
+
窗口透明度:
Window transparency:
@@ -336,90 +336,135 @@ p, li { white-space: pre-wrap; }
-
+
恭喜打破:
Congratulations:
Flag Time成绩!
- Flag Time Record!
+ Flag Time Record!
NF Time成绩!
- NF Time Record!
+ NF Time Record!
Flag 3BV/s成绩!
- Flag 3BV/s Record!
+ Flag 3BV/s Record!
NF 3BV/s成绩!
- NF 3BV/s Record!
+ NF 3BV/s Record!
Flag STNB成绩!
- Flag STNB Record!
+ Flag STNB Record!
NF STNB成绩!
- NF STNB Record!
+ NF STNB Record!
Flag IOE成绩!
- Flag IOE Record!
+ Flag IOE Record!
NF IOE成绩!
- NF IOE Record!
+ NF IOE Record!
Flag Path成绩!
- Flag Path Record!
+ Flag Path Record!
NF Path成绩!
- NF Path Record!
+ NF Path Record!
Flag RQP成绩!
- Flag RQP Record!
+ Flag RQP Record!
NF RQP成绩!
- NF RQP Record!
+ NF RQP Record!
-
+
初级
Beginner
-
+
个人最佳!
PB!
-
+
中级
Intermediate
-
+
高级
Expert
+
+
+ 勾选后永远使用筛选法埋雷,否则会适时改用调整法
+ Tick the box to always use the filtering method to lay mines, otherwise the adjustment method will be used at the right time
+
+
+
+ 完成后自动将录像保存到replay文件夹下
+ After completion, automatically save the recording to the replay folder
+
+
+
+ 未标雷(标准)
+ NF(Standard)
+
+
+
+ Time成绩!
+ Time score!
+
+
+
+ 3BV/s成绩!
+ 3BV/s score!
+
+
+
+ STNB成绩!
+ STNB score!
+
+
+
+ IOE成绩!
+ IOE score!
+
+
+
+ Path成绩!
+ Path score!
+
+
+
+ RQP成绩!
+ RQP score!
+
MainWindow
@@ -429,52 +474,52 @@ p, li { white-space: pre-wrap; }
Reserved
-
+
游戏
Game
-
+
设置
Options
-
+
帮助
Help
-
+
新游戏
New Game
-
+
初级
Beginner
-
+
中级
Intermediate
-
+
高级
Expert
-
+
自定义
Custom
-
+
退出
Exit
-
+
游戏设置
Game Settings
@@ -484,62 +529,62 @@ p, li { white-space: pre-wrap; }
A
-
+
词典
Dictionary
-
+
D
D
-
+
入门教程
Getting Started
-
+
R
R
-
+
快捷键设置
Shortcut Settings
-
+
打开
Open
-
+
语言设置
Language
-
+
元扫雷
Metasweeper
-
+
关于
About
-
+
English
English
-
+
中文
中文
-
+
鼠标设置
Mouse Settings
diff --git a/src/ui/ui_gameSettings.py b/src/ui/ui_gameSettings.py
index b37695a..749fb45 100644
--- a/src/ui/ui_gameSettings.py
+++ b/src/ui/ui_gameSettings.py
@@ -559,7 +559,7 @@ def retranslateUi(self, Form):
self.comboBox_gamemode.setItemText(5, _translate("Form", "准无猜"))
self.comboBox_gamemode.setItemText(6, _translate("Form", "强可猜"))
self.comboBox_gamemode.setItemText(7, _translate("Form", "弱可猜"))
- self.checkBox_auto_notification.setText(_translate("Form", "允许记录弹窗(推荐)"))
+ self.checkBox_auto_notification.setText(_translate("Form", "允许纪录弹窗(推荐)"))
self.label_attempt_times_limit.setText(_translate("Form", "尝试次数:"))
self.label_constraint.setText(_translate("Form", "局面约束:"))
self.checkBox_auto_replay.setText(_translate("Form", "自动重开:"))
diff --git a/uiFiles/ui_gs.ui b/uiFiles/ui_gs.ui
index 8a7b67e..70d38b2 100644
--- a/uiFiles/ui_gs.ui
+++ b/uiFiles/ui_gs.ui
@@ -534,7 +534,7 @@ color: #3d3d3d;
- 允许记录弹窗(推荐)
+ 允许纪录弹窗(推荐)