-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_situation.py
79 lines (66 loc) · 2.58 KB
/
edit_situation.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
'''
Author: Paoger
Date: 2023-12-16 18:43:36
LastEditors: Paoger
LastEditTime: 2023-12-18 17:08:38
Description:
Copyright (c) 2023 by Paoger, All Rights Reserved.
'''
from kivymd.app import MDApp
from piecewidget2 import PieceWidget2
from global_var import g_const_S_P_ORDEER
def edit_situation_clear():
#print("******edit_situation_clear begin******")
app = MDApp.get_running_app()
#候选棋子集归位
for child in app.root.ids['id_screditsituiation'].ids.id_chessboard2.children[:]:
if isinstance(child,PieceWidget2) and child.bx != child.old_x and child.by != child.old_y:
child.movexy(0,0,'B')
#print("******edit_situation_clear end******")
def edit_situation_full():
print("******edit_situation_full begin******")
app = MDApp.get_running_app()
#先归位
edit_situation_clear()
childs = []
for child in app.root.ids['id_screditsituiation'].ids.id_chessboard2.children[:]:
if isinstance(child,PieceWidget2) :
childs.append(child)
full_situation='000a141e28323c46500c4803172b3f5309131d27313b454f59114d061a2e4256'
for i in range(0,32,1):
#print(f'{i=}')
if i < 16:#红
for item in childs:
#print(f"{item}")
if item.camp == 'w' and item.identifier == g_const_S_P_ORDEER[i]:
#棋子到达位置
endxy = full_situation[i*2:i*2+2]
#print(f"{endxy=}")
exy = int(endxy,16)
ex = exy // 10
ey = exy % 10
#print(f"{ex=},{ey=}")
item.movexy(ex,ey,'F')
childs.remove(item)#从列表中删除
break
else :#黑
for item in childs:
#print(f"{item}")
if item.camp == 'b' and item.identifier == g_const_S_P_ORDEER[i]:
#棋子到达位置
endxy = full_situation[i*2:i*2+2]
#print(f"{endxy=}")
exy = int(endxy,16)
ex = exy // 10
ey = exy % 10
#print(f"{ex=},{ey=}")
item.movexy(ex,ey,'F')
childs.remove(item)#从列表中删除
break
print("******edit_situation_full end******")
def edit_situation_cancle():
#print("******edit_situation_cancle begin******")
app = MDApp.get_running_app()
app.root.current_heroes = ""
app.root.current = "screenMain"
#print("******edit_situation_cancle end******")