-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathx_chessapp.py
3192 lines (2623 loc) · 152 KB
/
x_chessapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
Author: Paoger
Date: 2023-11-23 16:21:31
LastEditors: Paoger
LastEditTime: 2024-02-10 20:30:16
Description:
Copyright (c) 2024 by Paoger, All Rights Reserved.
'''
'''
Author: Paoger
Date: 2023-10-30 10:18:15
LastEditors: Paoger
LastEditTime: 2024-01-01 13:15:24
Description:
Copyright (c) 2023 by Paoger, All Rights Reserved.
'''
#from kivy.utils import platform
#from kivy.config import Config
#if platform == "win":
# Config.set('graphics','resizable', False) # 窗体可变设置为False
import os
import glob
import time
import binascii
from treelib import Tree
import configparser
import shutil
from kivy.logger import Logger
from kivy.utils import platform
from kivy.lang import Builder
from kivy.metrics import dp
from kivy.core.window import Window
from kivy.properties import StringProperty
from kivy.uix.dropdown import DropDown
from kivy.uix.screenmanager import RiseInTransition
from kivy.clock import Clock
from functools import partial
from kivymd.app import MDApp
from kivymd.uix.bottomsheet import MDListBottomSheet
from kivymd.uix.menu import MDDropdownMenu
from kivymd.uix.filemanager import MDFileManager
from kivymd.toast import toast
from kivymd.utils import asynckivy
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
#全局变量 棋盘的初始局面,此值不应改变
from global_var import g_const_INIT_SITUATION,g_const_S_P_ORDEER
from x_chess_cfg import get_theLast_Path,save_theLast_Path,save_engine_settings,get_engine_settings
from situation import init_g_init_situation,xqfinit2xchessinit,print_situation,check_situation
#from myScreen import ScreenMain,ScreenMoves,ScreenEditSituation,ScreenInputFileName,ScreenMergeXQF,ScreenInfo,ScreenSetEngine,ScreenMenu,ScreenSelectFile
import myScreen
from selectedmaskwidget import SelectedMaskWidget
from piecewidget import PieceWidget
from piece import Piece
from onelinelistwithid import OneLineListWithId
from onelinelistfiles import OneLineListFiles
from onelinelistpathwithfile import OneLineListPathWithFile
from onelinelistpath import OneLineListPath
from chessboard import Chessboard
from chessboard2 import Chessboard2
from piecewidget2 import PieceWidget2
from movesnote import Movesnote
from mymdtextfield import MyMDTextField
from tree2txt import tree2txt
from tree2xqf import saveMovestreeToXQF
from edit_situation import edit_situation_clear,edit_situation_full,edit_situation_cancle
from tree2xqf import saveFileXQF
from mergexqf import mergexqf2tree
from selectfile import toUperLevelDirWithFile
from selectpath import toUperLevelDir
from situation import print_situation,sit2Fen
#from xqlight_ai import XQlight_moves
from uci_engine import UCIEngine
Logger.info('X-Chess X_ChessApp: This is a info message:X_ChessApp will run.')
Logger.debug('X-Chess X_ChessApp: This is a debug message:X_ChessApp will run.')
class X_ChessApp(MDApp):
Logger.debug('X-Chess X_ChessApp: 001')
#配置文件名
cfgFileName = None
#Toolbar menu打开的子菜单
#menu = None
#最近一次选择的路径
last_sel_path = ""
#当前打开的棋谱文件名
chessmovesfilename = ""
#保存打开的xqf文件头【0:2048],便于保存或另存
xqfFile2048 = ""
gameover = False
#招法树
moves_tree = Tree()
#初始局面该谁走,固定的
init_camp = 'w'#默认该红走
#当前局面该谁走,动态的
next_camp = 'w'#默认该红走
#当前所选棋子
selected_piece = None
#棋子移动前位置上的标识
selectedmask1 = None
#棋子移动后位置上的标识
selectedmask2 = None
#dialog = None
#文件浏览器,目前winddows下使用,andriod由于11以上存在闪退,所以暂不用
#在cfg.ini做配置,如果FM==KIVYMD则使用kivy md filemanager,否则用自己造的轮子
#[UI]
#FM=KIVYMD
ui_fm = None
file_manager = None
cfg_info = configparser.ConfigParser()
engine_name = 'xqpy'#xqpy:内置XQ引擎 uci:uci协议引擎
uci_engine = None #引擎进程
uci_engine_location = None#内置:inner 外置:outer
#用来保存selectfile.id_btnok on_release绑定的函数
selectfile_btnok_bind = []
sel_filename = None #用来保存选择file页面中选择的file
#用来保存selectpath.id_btnok on_release绑定的函数
selectpath_btnok_bind = []
sel_path = None #用来保存选择path页面中选择的path
#用来保存screeninputinfo.id_btnok on_release绑定的函数
screeninputinfo_btnok_bind = []
#用来保存screeninputinfo.id_btncancle on_release绑定的函数
screeninputinfo_btncancle_bind = []
#分析模式,当处于有限分析模式时,手工分析及AI执黑、执红都不可选
ai_analyzing = False
#分析当前局面,无限分析
show_ai_move_infinite = False
#二者都为真,电脑对弈
ai_black = False#AI不执黑
ai_red = False#AI不执红
Logger.debug('X-Chess X_ChessApp: 004')
def __init__(self, **kwargs):
super().__init__(**kwargs)
Logger.debug('X-Chess X_ChessApp init: begin')
if platform != 'android': # "win" linux ...:
self.cfgFileName = os.path.join(os.getcwd(),'cfg/cfg.ini')
else:#android
from android.storage import primary_external_storage_path
SD_CARD = primary_external_storage_path()
xc_version = ""
conf_info = configparser.ConfigParser()
if len(conf_info.read(os.path.join(os.getcwd(),'cfg/cfg.ini'),encoding='gbk')) != 0:
xc_version = conf_info.get("XC","version")
fn = os.path.join(SD_CARD,f'X-Chess/cfg/cfg{xc_version}.ini')
if os.path.exists(fn):
self.cfgFileName = fn
else:
self.cfgFileName = os.path.join(os.getcwd(),'cfg/cfg.ini')
Logger.debug(f'X-Chess X_ChessApp init: {self.cfgFileName=}')
self.icon = 'x-chess.png'
#Material design 3 style
self.theme_cls.material_style = "M3"
self.theme_cls.theme_style = "Dark" #"Dark" Light
#self.theme_cls.primary_palette = "Orange"
self.chessmovesfilename = "新建局面"
self.title = f"X-Chess 新建局面"
self.next_camp = 'w'
self.init_camp = 'w'
self.gameover = False
self.xqfFile2048 = '58510a00000000000000000000000000000a141e28323c46500c4803172b3f5309131d27313b454f59114d061a2e425600000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
init_situation='000a141e28323c46500c4803172b3f5309131d27313b454f59114d061a2e4256'
#将初始局面字符串初始化到全局变量g_const_INIT_SITUATION
init_g_init_situation(init_situation)
self.last_sel_path = get_theLast_Path()
# 读取 INI 文件
#self.cfg_info.read(os.path.join(os.getcwd(),'cfg/cfg.ini'),encoding='gbk')
self.cfg_info.read(self.cfgFileName,encoding='gbk')
if (f"UI" in self.cfg_info) and (f"FM" in self.cfg_info['UI']):
self.ui_fm = self.cfg_info['UI']['FM']
Logger.debug(f'X-Chess X_ChessApp init: {self.ui_fm=}')
#初始化engine_name = 'xqpy'#xqpy:内置XQ引擎 uci:uci协议引擎
if (f"ENGINE" in self.cfg_info) and (f"engine_name" in self.cfg_info['ENGINE']):
self.engine_name = self.cfg_info['ENGINE']['engine_name']
Logger.debug(f'X-Chess X_ChessApp init: {self.engine_name=}')
#初始化 uci_engine_location 内置:inner 外置:outer
if (f"ENGINE" in self.cfg_info) and (f"engine_location" in self.cfg_info['ENGINE']):
self.uci_engine_location = self.cfg_info['ENGINE']['engine_location']
Logger.debug(f'X-Chess X_ChessApp init: {self.uci_engine_location=}')
if platform != 'android':#简记01
Window.bind(on_keyboard=self.events)
Logger.debug('X-Chess X_ChessApp init: end')
def build(self):
Logger.debug('X-Chess X_ChessApp build: begin')
parent = Builder.load_file("./main.kv")
parent.ids['id_screenmain'].ids['id_movesnote'].hint_text= self.title
#identifier让其默认生成,If identifier is absent, a UUID will be generated automatically.
self.moves_tree.remove_subtree(nid=None)#清空以前的树
self.moves_tree = Tree()
nroot = self.moves_tree.create_node(tag=os.path.basename(self.chessmovesfilename),
data={'sp':'18','ep':'20','flag':'f0','rsv':'ff',
'notelen':'00000000','note':"",
'situation':g_const_INIT_SITUATION,'pieceWidget':None}) # 根节点
#self.root.ids.id_moveslist.clear_widgets()
#由于使用多个kv文件,导致self.root.ids不能访问到子kv模块中的ID,所以
parent.ids['id_screenmoves'].ids.id_moveslist.clear_widgets()
parent.ids['id_screenmoves'].ids.id_movesbranch.clear_widgets()
#把根节点加入到招法列表中的第一项
parent.ids['id_screenmoves'].ids.id_moveslist.add_widget(OneLineListWithId(id=nroot.identifier,text=nroot.tag,font_style="H6"))#bg_color = [0,1,1,1])
mainbgimg = self.cfg_info['UI']['mainbgimg']
Logger.debug(f'X-Chess X_ChessApp build: {mainbgimg=}')
if mainbgimg == 'DIY':
mainbgimg_fn = None
if platform != 'android':
mainbgimg_fn = os.path.join(os.getcwd(),'img/background.png')
else:
from android.storage import primary_external_storage_path
SD_CARD = primary_external_storage_path()
mainbgimg_fn = os.path.join(SD_CARD,'X-Chess/img/background.png')
Logger.debug(f'X-Chess X_ChessApp build: {mainbgimg_fn=}')
if os.path.exists(mainbgimg_fn):
parent.ids['id_screenmain'].ids.id_backgroundimg.source = mainbgimg_fn
if platform == 'android':
#安卓中由于输入法会遮挡注解信息,所以否则只读,通过专用的编辑界面进行编辑
parent.ids['id_screenmain'].ids['id_movesnote'].readonly = True
#MDDropdownMenu在android >= 11 闪退,so暂且把菜单改成按钮放在首页上,以及菜单Screen吧
# menu_items = [
# {
# "viewclass": "OneLineListItem",
# "text": "新建局面",
# "height": dp(48),
# "on_release": lambda x="新建": self.new_situation(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "编辑局面",
# "height": dp(48),
# "on_release": lambda x="编辑": self.edit_situation(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "打开棋谱",
# "height": dp(48),
# "on_release": lambda x="Open": self.open_XQFFile(x),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "保存棋谱",
# "height": dp(48),
# "on_release": lambda x="": self.saveXQF(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "另存棋谱",
# "height": dp(48),
# "on_release": lambda x="": self.saveAs(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "合并XQF",
# "height": dp(48),
# "on_release": lambda x="编辑": self.mergeXQF(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "xqf==>txt",
# "height": dp(48),
# "on_release": lambda x="xqf2txt": self.xqf2txt(x),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "退到初始",
# "height": dp(48),
# "on_release": lambda x="初始局面": self.back_init(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "自动路演",
# "height": dp(48),
# "on_release": lambda x="自动路演": self.auto_roadshow(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "引擎设置",
# "height": dp(48),
# "on_release": lambda x="引擎设置": self.set_engine(),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "Test",
# "height": dp(48),
# "on_release": lambda x="Test": self.test_callback(x),
# },
# {
# "viewclass": "OneLineListItem",
# "text": "退出",
# "height": dp(48),
# "on_release": lambda x="Quit": self.stop(),
# },
# ]
#
# self.menu = MDDropdownMenu(
# caller = parent.ids['id_screenmain'].ids['id_btnmenu'],
# items=menu_items,
# width_mult=4,
# )
#
# 暂且把菜单改成按钮放在首页上,以及菜单Screen
Logger.debug('X-Chess X_ChessApp build: end')
return parent
def on_start(self):
super().on_start()
Logger.debug('X-Chess X_ChessApp on_start: begin')
self.root.current_heroes = "" #"" ["hero"]
self.root.current = "ScreenWelcome"
Logger.debug('X-Chess X_ChessApp on_start: end')
def inputinfo_backto(self,instance=None,screenname=None):
Logger.debug(f'X-Chess X_ChessApp inputinfo_backto: {screenname=}')
self.root.transition = RiseInTransition()
self.root.current_heroes = ""
self.root.current = screenname
def set_inputinfo(self,instance=None,screenname=None,screenid=None,textid=None):
Logger.debug(f'X-Chess X_ChessApp set_inputinfo: begin')
Logger.debug(f'X-Chess X_ChessApp inputinfo_backto: {screenname=},{screenid=},{textid}')
self.root.ids[screenid].ids[textid].text = self.root.ids['id_screeninputinfo'].ids['id_input_info'].text
self.root.transition = RiseInTransition()
self.root.current_heroes = ""
self.root.current = screenname
if screenid == 'id_screenmain':
#print('User defocused')
#app = MDApp.get_running_app()
#招法树必须先有
if self.moves_tree.root != None:
#更新当前节点的注释
#MDList的最后一个item
id = self.root.ids['id_screenmoves'].ids.id_moveslist.children[0].id
if id != None:
node = self.moves_tree.get_node(id)
notelen = node.data['notelen']
#print(f"before note==>{node.data['note']}")
#print(f"before notelen==>{notelen}")
Logger.debug(f"X-Chess ChessApp set_inputinfo:before note==>{node.data['note']}")
node.data['note'] = self.root.ids['id_screeninputinfo'].ids['id_input_info'].text
#print(f"after note==>{self.text=},{node.data['note']}")
#一顿骚操作
s = f"{len(self.root.ids['id_screeninputinfo'].ids['id_input_info'].text.encode('gbk')):x}" # 10==>a
#print(f"{len(self.text.encode('gbk'))=},{s=}")
s = f"{s:0>8}"#a==>0000000a
notelen = f'{s[6:8]}{s[4:6]}{s[2:4]}{s[0:2]}' #0000000a==>0a000000
node.data['notelen'] = notelen
#print(f"after notelen==>{notelen}")
Logger.debug(f"X-Chess ChessApp set_inputinfo:after note==>{node.data['note']}")
Logger.debug(f'X-Chess X_ChessApp set_inputinfo: end')
def input_noteedit(self):
Logger.debug("X-Chess X-ChessApp:input_noteedit begin")
#if platform == 'android':
self.root.transition = RiseInTransition()
self.root.current_heroes = ""
self.root.current = "ScreenInputInfo"
self.root.ids['id_screeninputinfo'].ids['id_input_info'].hint_text= "请输入棋谱注解"
self.root.ids['id_screeninputinfo'].ids['id_input_info'].text = self.root.ids['id_screenmain'].ids['id_movesnote'].text
#先把id_btn_ok之前的绑定清空了,再重新绑定
for cb in self.screeninputinfo_btnok_bind:
self.root.ids['id_screeninputinfo'].ids.id_btn_ok.funbind('on_release', cb)
self.screeninputinfo_btnok_bind = []
new_cb = partial(self.set_inputinfo,screenname='screenMain',screenid='id_screenmain',textid='id_movesnote')
self.screeninputinfo_btnok_bind.append(new_cb)
self.root.ids['id_screeninputinfo'].ids.id_btn_ok.fbind('on_release', new_cb)
#先把id_btn_cancle之前的绑定清空了,再重新绑定
for cb in self.screeninputinfo_btncancle_bind:
self.root.ids['id_screeninputinfo'].ids.id_btn_cancle.funbind('on_release', cb)
self.screeninputinfo_btncancle_bind = []
new_cb = partial(self.inputinfo_backto,screenname='screenMain')
self.screeninputinfo_btncancle_bind.append(new_cb)
self.root.ids['id_screeninputinfo'].ids.id_btn_cancle.fbind('on_release', new_cb)
#else:
# pass
Logger.debug("X-Chess X-ChessApp:input_noteedit end")
def input_engineoption_edit(self):
Logger.debug("X-Chess X-ChessApp:input_engineoption_edit begin")
#if platform == 'android':
self.root.transition = RiseInTransition()
self.root.current_heroes = ""
self.root.current = "ScreenInputInfo"
self.root.ids['id_screeninputinfo'].ids['id_input_info'].hint_text= "请输入引擎参数"
self.root.ids['id_screeninputinfo'].ids['id_input_info'].text = self.root.ids['id_screensetengine'].ids['id_uci_options'].text
Logger.debug(f"X-Chess X-ChessApp input_engineoption_edit: {self.root.ids['id_screensetengine'].ids['id_uci_options'].text=}")
#先把id_btn_ok之前的绑定清空了,再重新绑定
for cb in self.screeninputinfo_btnok_bind:
self.root.ids['id_screeninputinfo'].ids.id_btn_ok.funbind('on_release', cb)
self.screeninputinfo_btnok_bind = []
new_cb = partial(self.set_inputinfo,screenname='screenSetEngine',screenid='id_screensetengine',textid='id_uci_options')
self.screeninputinfo_btnok_bind.append(new_cb)
self.root.ids['id_screeninputinfo'].ids.id_btn_ok.fbind('on_release', new_cb)
#先把id_btn_cancle之前的绑定清空了,再重新绑定
for cb in self.screeninputinfo_btncancle_bind:
self.root.ids['id_screeninputinfo'].ids.id_btn_cancle.funbind('on_release', cb)
self.screeninputinfo_btncancle_bind = []
new_cb = partial(self.inputinfo_backto,screenname='screenSetEngine')
self.screeninputinfo_btncancle_bind.append(new_cb)
self.root.ids['id_screeninputinfo'].ids.id_btn_cancle.fbind('on_release', new_cb)
#else:
# pass
Logger.debug("X-Chess X-ChessApp:input_engineoption_edit end")
def new_situation(self):
Logger.debug("X-Chess X-ChessApp:******new_situation begin******")
#self.menu.dismiss()
self.chessmovesfilename = "新建局面"
self.title = f"X-Chess 新建局面"
self.root.ids['id_screenmain'].ids['id_movesnote'].hint_text= self.title
self.root.ids['id_screenmain'].ids['id_movesnote'].text = ""
self.root.ids['id_screenmain'].ids['id_movesnote'].cancel_selection()
self.root.ids['id_screenmain'].ids['id_movesnote_input'].text = ""
self.root.ids['id_screenmain'].ids['id_movesnote_input'].cancel_selection()
self.next_camp = 'w'
self.init_camp = 'w'
self.gameover = False
self.root.ids['id_screenmain'].ids.id_chessboard.red_bottom = True
self.xqfFile2048 = '58510a00000000000000000000000000000a141e28323c46500c4803172b3f5309131d27313b454f59114d061a2e425600000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
init_situation='000a141e28323c46500c4803172b3f5309131d27313b454f59114d061a2e4256'
#将初始局面字符串初始化到全局变量g_const_INIT_SITUATION
init_g_init_situation(init_situation)
#identifier让其默认生成,If identifier is absent, a UUID will be generated automatically.
self.moves_tree.remove_subtree(nid=None)#清空以前的树
self.moves_tree = Tree()
nroot = self.moves_tree.create_node(tag=os.path.basename(self.chessmovesfilename),
data={'sp':'18','ep':'20','flag':'f0','rsv':'ff',
'notelen':'00000000','note':"",
'situation':g_const_INIT_SITUATION,'pieceWidget':None}) # 根节点
#print("1111111111")
#for i in self.root.ids:
# print(f"id:{i}")
#print("22222222")
#self.root.ids.id_moveslist.clear_widgets()
#由于使用多个kv文件,导致self.root.ids不能访问到子kv模块中的ID,所以
self.root.ids['id_screenmoves'].ids.id_moveslist.clear_widgets()
self.root.ids['id_screenmoves'].ids.id_movesbranch.clear_widgets()
#把根节点加入到招法列表中的第一项
self.root.ids['id_screenmoves'].ids.id_moveslist.add_widget(OneLineListWithId(id=nroot.identifier,text=nroot.tag,font_style="H6"))#bg_color = [0,1,1,1])
#按棋谱g_const_INIT_SITUATION摆棋子
self.root.ids['id_screenmain'].ids.id_chessboard.piece_by_chessmanual()
#toast("新建局面ok")
Logger.debug("X-Chess X-ChessApp:******new_situation end******")
def file_manager_open(self):
#self.file_manager.show(os.path.expanduser("~"))
# show the available disks first, then the files contained in them. Works correctly on: Windows, Linux, OSX, Android. Not tested on iOS.
#self.file_manager.show_disks()
""" if self.last_sel_path == "":
if platform == "android":
from android.storage import primary_external_storage_path
SD_CARD = primary_external_storage_path()
self.last_sel_path = os.path.join(SD_CARD)
elif platform == "win":
self.last_sel_path = os.path.expanduser("~")
else:
self.last_sel_path = os.path.expanduser("~")
#当前目录
#app_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'xqf')
toast(self.last_sel_path)
self.file_manager.show(self.last_sel_path) """
if self.last_sel_path == "":
if platform == "android":
#exs = os.getenv('EXTERNAL_STORAGE')
#Logger.debug(f'X-Chess X_ChessApp: {exs=}')
##toast(exs)
#appdata = os.getenv('APPDATA')
##toast(appdata)
#Logger.debug(f'X-Chess X_ChessApp: {appdata=}')
##创建一个目录,试试
#from android.storage import primary_external_storage_path
#Logger.debug(f'X-Chess X_ChessApp: {primary_external_storage_path()=}')
#x_chess_xqf = os.path.join(primary_external_storage_path(),'x_chess_xqf')
#if not os.path.exists(x_chess_xqf):
# os.makedirs(x_chess_xqf)
#self.last_sel_path = x_chess_xqf
#self.last_sel_path = os.path.join(os.getcwd(),'xqf')
from android.storage import primary_external_storage_path
SD_CARD = primary_external_storage_path()
mypath = os.path.join(SD_CARD,'X-Chess/xqf')
if not os.path.exists(mypath):
try:
os.makedirs(mypath)
except Exception as e:
Logger.debug(f"X-Chess UCIEngine:subprocess Exception: {str(e)}")
finally:
pass
self.last_sel_path = os.path.join(SD_CARD,'X-Chess/xqf')
self.file_manager.show(self.last_sel_path)
else:
self.file_manager.show_disks()
else:
#toast(self.last_sel_path)
self.file_manager.show(self.last_sel_path)
# output manager to the screen
self.manager_open = True
def events(self, instance, keyboard, keycode, text, modifiers):
'''Called when buttons are pressed on the mobile device.'''
if keyboard in (1001, 27):
if self.manager_open:
self.file_manager.back()
return True
def exit_manager(self, *args):
'''Called when the user reaches the root of the directory tree.'''
self.manager_open = False
self.file_manager.close()
def toUperLevelDirWithFile(self):
toUperLevelDirWithFile(self.root.ids['id_screenselectfile'].ids['id_cur_path'].text)
def cdSubDir(self):#进入子目录
if self.root.ids['id_screenselectfile'].ids['id_subdir'].text == "":
return
async def onebyone(self,filename):
self.root.ids['id_screenselectfile'].ids.id_file_list.add_widget(OneLineListFiles(text=f"{filename}",font_style="Overline"))
#await asynckivy.sleep(0.1)
#end onebyone
self.sel_filename = None
seachdir = os.path.join(self.root.ids['id_screenselectfile'].ids['id_cur_path'].text,
f"{self.root.ids['id_screenselectfile'].ids['id_subdir'].text}")
Logger.debug(f"X-Chess OneLineListPath:on_touch_up {seachdir=}")
self.root.ids['id_screenselectfile'].ids['id_cur_path'].text = seachdir
seachdir = self.root.ids['id_screenselectfile'].ids['id_cur_path'].text
#Logger.debug(f"X-Chess X-ChessApp:OneLineListPathWithFile {seachdir=}")
seachdir = os.path.join(seachdir,'*')
#Logger.debug(f"X-Chess X-ChessApp:OneLineListPathWithFile {seachdir=}")
subdirs = [name for name in glob.glob(seachdir) if os.path.isdir(name)]
self.root.ids['id_screenselectfile'].ids.id_dir_list.clear_widgets()
for sd in subdirs:
last_level_dir = os.path.basename(sd)
self.root.ids['id_screenselectfile'].ids.id_dir_list.add_widget(OneLineListPathWithFile(text=f"{last_level_dir}",font_style="Overline"))
seachdir = self.root.ids['id_screenselectfile'].ids['id_cur_path'].text
filetype = self.root.ids['id_screenselectfile'].ids['id_filetype'].text
filetype = filetype.split('.')
seachdir = os.path.join(seachdir,f'*.{filetype[1]}')
#Logger.debug(f"X-Chess X-ChessApp:OneLineListPathWithFile {seachdir=}")
files = [name for name in glob.glob(seachdir) if os.path.isfile(name)]
self.root.ids['id_screenselectfile'].ids.id_file_list.clear_widgets()
for file in files:
filename = os.path.basename(file)
#self.root.ids['id_screenselectfile'].ids.id_file_list.add_widget(OneLineListFiles(text=f"{filename}",font_style="Overline"))
asynckivy.start(onebyone(self,filename=filename))
def open_XQFFile(self):
#由于MDFileManager在android11之上闪退,换了flyer.filechoose也是问题多多,so
#if platform == 'android':
if self.ui_fm != 'KIVYMD':
self.root.current_heroes = ""
self.root.current = "ScreenSelectFile"
self.sel_filename = None
self.root.ids['id_screenselectfile'].ids['id_cur_path'].text = self.last_sel_path
self.root.ids['id_screenselectfile'].ids['id_subdir'].text = ""
filetype = '.xqf'
self.root.ids['id_screenselectfile'].ids['id_filetype'].text = f"文件类型{filetype}"
seachdir = self.root.ids['id_screenselectfile'].ids['id_cur_path'].text
Logger.debug(f"X-Chess X-ChessApp:open_XQFFile {seachdir=}")
seachdir = os.path.join(seachdir,'*')
Logger.debug(f"X-Chess X-ChessApp:open_XQFFile {seachdir=}")
subdirs = [name for name in glob.glob(seachdir) if os.path.isdir(name)]
self.root.ids['id_screenselectfile'].ids.id_dir_list.clear_widgets()
for sd in subdirs:
last_level_dir = os.path.basename(sd)
self.root.ids['id_screenselectfile'].ids.id_dir_list.add_widget(OneLineListPathWithFile(text=f"{last_level_dir}",font_style="Overline"))
seachdir = self.root.ids['id_screenselectfile'].ids['id_cur_path'].text
seachdir = os.path.join(seachdir,f'*{filetype}')
Logger.debug(f"X-Chess X-ChessApp:open_XQFFile {seachdir=}")
files = [name for name in glob.glob(seachdir) if os.path.isfile(name)]
self.root.ids['id_screenselectfile'].ids.id_file_list.clear_widgets()
for file in files:
filename = os.path.basename(file)
self.root.ids['id_screenselectfile'].ids.id_file_list.add_widget(OneLineListFiles(text=f"{filename}",font_style="Overline"))
#self.root.ids['id_screenselectfile'].ids.id_btn_ok.bind(
# on_release=lambda instance:self.open_SelectedXQFFile(instance))
#先把之前的绑定清空了
for cb in self.selectfile_btnok_bind:
self.root.ids['id_screenselectfile'].ids.id_btn_ok.funbind('on_release', cb)
self.selectfile_btnok_bind = []
new_cb = partial(self.open_SelectedXQFFile)
self.selectfile_btnok_bind.append(new_cb)
self.root.ids['id_screenselectfile'].ids.id_btn_ok.fbind('on_release', new_cb)
else:
self.manager_open = False
self.file_manager = MDFileManager(
exit_manager=self.exit_manager,#用户到达目录树根目录时调用的函数
select_path=lambda path:self.select_xqf_path(path=path), #选择文件/目录时调用的函数
icon_selection_button="pencil",
selector='file',#只选择文件
ext=['.xqf']
)
self.file_manager_open()
def open_SelectedXQFFile(self,instance):
if self.sel_filename != None:
self.back_mainScreen()
self.last_sel_path = os.path.dirname(self.sel_filename)
save_theLast_Path(self.last_sel_path)
self.chessmovesfilename = self.sel_filename
file_name = os.path.basename(self.chessmovesfilename)
self.title = f"X-Chess {file_name[:-4]}"
self.root.ids['id_screenmain'].ids['id_movesnote'].hint_text= self.title
self.root.ids['id_screenmain'].ids['id_movesnote'].text= ""
self.root.ids['id_screenmain'].ids['id_movesnote'].cancel_selection()
self.root.ids['id_screenmain'].ids['id_movesnote_input'].text= ""
self.root.ids['id_screenmain'].ids['id_movesnote_input'].cancel_selection()
self.gameover = False
self.root.ids['id_screenmain'].ids.id_chessboard.red_bottom = True
self.root.ids['id_screenmoves'].ids.id_moveslist.clear_widgets()
self.root.ids['id_screenmoves'].ids.id_movesbranch.clear_widgets()
self.readXQFFile(self.sel_filename)
self.back_mainScreen()
def select_xqf_path(self, path: str):
'''
It will be called when you click on the file name
or the catalog selection button.
:param path: path to the selected directory or file;
'''
self.last_sel_path = os.path.dirname(path)
save_theLast_Path(self.last_sel_path)
self.chessmovesfilename = path
file_name = os.path.basename(self.chessmovesfilename)
self.title = f"X-Chess {file_name[:-4]}"
self.root.ids['id_screenmain'].ids['id_movesnote'].hint_text= self.title
self.gameover = False
self.root.ids['id_screenmain'].ids.id_chessboard.red_bottom = True
self.exit_manager()
#print(f"{path=}")
#将选择结果显示回显到屏幕上
#toast(path)
self.root.ids['id_screenmoves'].ids.id_moveslist.clear_widgets()
self.root.ids['id_screenmoves'].ids.id_movesbranch.clear_widgets()
self.readXQFFile(path)
#创建招法树
#此函数要在draw_init_situation之后执行,否则node中记录的widget为空
def generate_moves_tree(self,chess_moves):
Logger.debug("X-Chess X-ChessApp:******generate_moves_tree begin******")
sx = sy = ex = ey = None
moveslen = len(chess_moves) #用来判断是否跳出循环
#print(f"棋谱长度:{moveslen=},记录:{chess_moves=}")
#空着批注的长度
note = ""
#第5-8字节:为一个32位整数(x86格式,高字节在后),表明本步批注的大小
s = f'{chess_moves[14:16]}{chess_moves[12:14]}{chess_moves[10:12]}{chess_moves[8:10]}'
notelen = int(s,16)
#print(f"{notelen=},{chess_moves[8:16]},{chess_moves[16:16+notelen*2]=}")
if notelen > 0:
byte_str = binascii.unhexlify(chess_moves[16:16+notelen*2])
note = byte_str.decode("gbk")
#print(f"note:{note}")
#identifier让其默认生成,If identifier is absent, a UUID will be generated automatically.
self.moves_tree = self.moves_tree.remove_subtree(nid=None)#清空以前的树
self.moves_tree = Tree()
#flag = int(chess_moves[4:6],16)
flag = chess_moves[4:6]#使用16进制字符串
nroot = self.moves_tree.create_node(tag=os.path.basename(self.chessmovesfilename),
data={'sp':'18','ep':'20','flag':flag,'rsv':'ff',
'notelen':chess_moves[8:16],'note':note,
'situation':g_const_INIT_SITUATION,'pieceWidget':None}) # 根节点
#把根节点加入到招法列表中的第一项
self.root.ids['id_screenmoves'].ids.id_moveslist.add_widget(OneLineListWithId(id=nroot.identifier,text=nroot.tag,font_style="H6"))#bg_color = [0,1,1,1])
#tv = ChessTreeView(root_options=dict(text=self.chessmovesfilename,font_size=10,color=[0,0,0,1]),
# hide_root=True,
# indent_level=8)
#tv.size_hint = 1, None
#tv.bind(minimum_height = tv.setter('height'))
#tv.bind(minimum_width = tv.setter('width'))
#print(f"nroot id==>{nroot.identifier}")
i = 1#循环次数,便于调试
istart = 16 + notelen * 2
#print(f"{istart=}")
branchStack = [] #当前招法链枝点链表,后进先出
branchStack.append(nroot)
#tvbranchStack = [] #当前招法链枝点链表,后进先出
#tvbranchStack.append(None)
#f0branchStack = []#中间压入的f0节点,需要在出现 f0-->00时,全部从branchStack中删除
n0 = nroot
#tvn0 = None
while istart < moveslen:
#print(f"*** {i=} ***")
#保存当前招法走后的局面
realtime_situation = {}
#print(f"cur {istart=}")
p = Piece(None,None,None,None)
mn = ""
#棋子开始位置
startxy = chess_moves[istart:istart+2]
#print(f"{startxy=}")
sxy = int(startxy,16) - 24
sx = sxy // 10
sy = sxy % 10
#print(f"{sx=},{sy=}")
#棋子到达位置
endxy = chess_moves[istart+2:istart+4]
#print(f"{endxy=}")
exy = int(endxy,16) - 32
ex = exy // 10
ey = exy % 10
#print(f"{ex=},{ey=}")
#print(f"{chess_moves[istart:istart+2]}{chess_moves[istart+2:istart+4]}==({sx},{sy})-->({ex},{ey})")
if i == 1:#获取该谁走棋
p = n0.data['situation'][f'{sx},{sy}']
self.next_camp = p.camp
self.init_camp = p.camp
print(f"该{self.next_camp=}走棋")
# 走子前局面保存在其父节点中的data['situation']
# print_situation("******走子前局面******",n0.data['situation'])
if (f"{sx},{sy}" in n0.data['situation']) and isinstance(n0.data['situation'][f'{sx},{sy}'],Piece):
#当前招法走子前的棋子实例,其x,y与sx,sy相同
p = n0.data['situation'][f'{sx},{sy}']
#print(f"网点:({sx},{sy}),棋子:{p.camp=},{p.identifier=},{p.x=},{p.y=},{p.pieceWidget=}")
#print(f"网点:({sx},{sy}),棋子:{p}")
#获取招法名称
mn =p.getMoveName(ex,ey,n0.data['situation'])
#print(f"{mn=}")
#使用 copy 模块中的 deepcopy() 方法来创建原始 dictionary 的一个新的深度拷贝。深度拷贝为 dictionary 中的所有易变对象创建一个新的拷贝,
#而不仅仅是创建对它们的引用。这意味着对新的 dictionary 中的易变对象所做的改变将不会影响到原来的 dictionary
#深拷贝导致widget会被再次创建,
#realtime_situation = copy.deepcopy(n0.data['situation'])
#实现自我的深层拷贝:内部的对象的重新创建
for m in range(0,9,1):#x坐标
for n in range(0,10,1):#y坐标
if (f"{m},{n}" in n0.data['situation']) and isinstance(n0.data['situation'][f'{m},{n}'],Piece):
p0 = n0.data['situation'][f'{m},{n}']
#创建新的对象
p1 = Piece(p0.camp,p0.identifier,p0.x,p0.y,p0.pieceWidget)
#此时p0 与 p1相同,指向相同的棋子Widget
realtime_situation[f'{m},{n}'] = p1
#print_situation("******deepcopy 后 realtime_situation******",realtime_situation)
# #更新 实时局面 realtime_situation
#起点置空
realtime_situation[f'{sx},{sy}'] = None
#终点指向新的Piece实例,其x,y为ex ey
realtime_situation[f'{ex},{ey}'] = Piece(p.camp,p.identifier,ex,ey,p.pieceWidget)
#print_situation("******更新后 realtime_situation******",realtime_situation)
else:#todo 一般不会,除非异常,待完善代码结构
print(f"异常了,当前局面{n0.data['situation']}中({sx},{sy})处没有棋子")
print_situation("******异常局面******",n0.data['situation'])
toast(f"异常了,当前局面{n0.data['situation']}中({sx},{sy})处没有棋子")
break
#print_situation("******走子后局面 realtime_situation******",realtime_situation)
#movesname = f"{i: <3}{mn}-{chess_moves[istart:istart+2]}{chess_moves[istart+2:istart+4]}-{chess_moves[istart+4:istart+6]}"
movesname = mn
#print(f"{movesname=}")
#获取当前招法的分支标记
#flag = int(chess_moves[istart+4:istart+6],16)
#print(f"{flag=},{chess_moves[istart+4:istart+6]}")
flag = chess_moves[istart+4:istart+6]
#print(f"{flag=}")
note = ""
#批注的长度
s = f'{chess_moves[istart+14:istart+16]}{chess_moves[istart+12:istart+14]}{chess_moves[istart+10:istart+12]}{chess_moves[istart+8:istart+10]}'
notelen = int(s,16)
if notelen > 0:
byte_str = binascii.unhexlify(chess_moves[istart+16:istart+16+notelen*2])
note = byte_str.decode("gbk")
#print(f"note:{note}")
n = self.moves_tree.create_node(tag=movesname,parent = n0.identifier,
data={'sp':chess_moves[istart:istart+2],'ep':chess_moves[istart+2:istart+4],'flag':flag,'rsv':'00',
'notelen':chess_moves[istart+8:istart+16],'note':note,
'situation':realtime_situation,'pieceWidget':p.pieceWidget,'sx':sx,'sy':sy,'ex':ex,'ey':ey
})
#Logger.debug(f"X-Chess X-ChessApp:{movesname}=={n.identifier}")
#tvn = tv.add_node(TreeViewLabelWithId(id=n.identifier,text=f"{i: <3}{mn}",font_size=10,color=[0,0,0,1],is_open=False),tvn0)
#print(f"current n0:{n0.tag},flag:{n0.data['flag']}")
#print(f"n:{n.tag},flag:{n.data['flag']}")#,note:{n.data['note']}
#print_situation("******走子后局面******",n.data['situation'])
#str = ""
#for item in branchStack:
# str = f"{str}{item.tag}==>"
#print(f"之前叉点链表:{str}")
#str = ""
#for item in tvbranchStack:
# if item != None:
# str = f"{str}{item.text}==>"
# else:
# str = f"{str}None==>"
#print(f"之前叉点链表:{str}")
#print(f"{n.data['flag']=},{n0.data['flag']=}")
#判断该节点是否有分支
if flag == 'f0':#240:#0xf0 中间节点,或者说其同级的最后一个
n0 = n
#tvn0 = tvn
elif flag == 'ff':#255 : #0xff 分支节点
#如果其父级是f0(f0同级的最后一个),需要将其父级也压入堆栈
if n0.data['flag'] == 'f0':#240:
#f0branchStack.append(n0)
branchStack.append(n0)
#tvbranchStack.append(tvn0)
branchStack.append(n)#将该节点压入枝点链表,后进先出
#tvbranchStack.append(tvn)
n0 = n
#tvn0 = tvn
elif flag == '00':#00:
##如果其父级是f0(f0同级的最后一个),将之前压入的f0节点从branchStack中删除
#if (n0.data['flag'] == 240): #and (n0 == branchStack[len(branchStack)-1]):
# #branchStack.pop()
# for item in f0branchStack:
# branchStack.remove(item)
# f0branchStack.clear()
#print("000000")
#print(f"{n0.tag=},{branchStack[len(branchStack)-1].tag}")
#从branchStack倒数,把之前压入的f0都弹出,直到遇到ff为止,并且把ff的也弹出
if (n0.data['flag'] == 'f0') : #240
while True:
#print(f"{len(branchStack)=}")
if len(branchStack) == 0:
break
if len(branchStack) > 0 and branchStack[len(branchStack)-1].data['flag'] == 'ff': #255 0xff 分支节点
#print("22222")
branchStack.pop()#弹出最后一个
#tvbranchStack.pop()
break
if len(branchStack) > 0:
branchStack.pop()#弹出最后一个
#tvbranchStack.pop()
else:
branchStack.pop()#弹出最后一个
#tvbranchStack.pop()
if len(branchStack) > 0:
n0 = branchStack[len(branchStack)-1]
else:#到根节点
n0 = nroot
#print(f"{len(tvbranchStack)=}")
#if len(tvbranchStack) > 0:
# tvn0 = tvbranchStack[len(tvbranchStack)-1]
#else:#到根节点
# tvn0 = None
elif flag == '0f': #15:#15=0x0f,0f经验证是兄弟中所有单身汉中非最小的那些单身汉
"""
── 49 红炮8平9-2422-f0
├── 50 黑车1平4-2147-ff
│ └── 51 红炮9进4-1a26-0f
└── 52 红兵9进1-1c25-00
└── 285红炮4进4-4b57-f0
└── 286黑车9平7-695d-f0
├── 287红相3退5-584a-0f
├── 288红相3进5-544a-ff