-
Notifications
You must be signed in to change notification settings - Fork 1
/
Undoer.spx
43 lines (39 loc) · 825 Bytes
/
Undoer.spx
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
func undo(op int, id int, val int) {
undoOpList.delete Last
undoIdList.delete Last
undoParamList.delete Last
currentCol = (id - 1) % 19
currentRow = (id - 1) / 19
currentPlayer = val
if op == 0 {
if undoOpList.len == 0 {
hide
}
broadcast "try put chess", true
gameState.set id-1, _Eating
broadcast "eat chesses", true
undoing = 0
} else {
Chess.clone
}
}
onStart => {
undoOpList.delete All
undoIdList.delete All
undoParamList.delete All
undoing = 0
hide
}
onClick => {
if undoOpList.len > 0 {
undoing = 1
undo undoOpList.at(Last).int, undoIdList.at(Last).int, undoParamList.at(Last).int
}
}
onMsg "restore eaten chesses", => {
currentPlayer = 3 - currentPlayer
undo undoOpList.at(Last).int, undoIdList.at(Last).int, undoParamList.at(Last).int
}
onMsg "put chess done", => {
show
}