2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | func cell (cells,row,col) = takeRight(take(cells, (((row * 15) + col) + 1)), 1) |
---|
5 | | - | |
---|
6 | | - | |
---|
7 | | - | func setCell (cells,row,col,val) = ((take(cells, ((row * 15) + col)) + val) + takeRight(cells, (size(cells) - (((row * 15) + col) + 1)))) |
---|
8 | | - | |
---|
9 | | - | |
---|
10 | | - | func checkField (cells,c,row,col) = { |
---|
11 | | - | let targetLines = ((((((((((((((((((((((((((((((((((((if ((col >= 4)) |
---|
12 | | - | then cell(cells, row, (col - 4)) |
---|
13 | | - | else "") + (if ((col >= 3)) |
---|
14 | | - | then cell(cells, row, (col - 3)) |
---|
15 | | - | else "")) + (if ((col >= 2)) |
---|
16 | | - | then cell(cells, row, (col - 2)) |
---|
17 | | - | else "")) + (if ((col >= 1)) |
---|
18 | | - | then cell(cells, row, (col - 1)) |
---|
19 | | - | else "")) + cell(cells, row, col)) + (if ((13 >= col)) |
---|
20 | | - | then cell(cells, row, (col + 1)) |
---|
21 | | - | else "")) + (if ((12 >= col)) |
---|
22 | | - | then cell(cells, row, (col + 2)) |
---|
23 | | - | else "")) + (if ((11 >= col)) |
---|
24 | | - | then cell(cells, row, (col + 3)) |
---|
25 | | - | else "")) + (if ((10 >= col)) |
---|
26 | | - | then cell(cells, row, (col + 4)) |
---|
27 | | - | else "")) + (if ((row >= 4)) |
---|
28 | | - | then cell(cells, (row - 4), col) |
---|
29 | | - | else "")) + (if ((row >= 3)) |
---|
30 | | - | then cell(cells, (row - 3), col) |
---|
31 | | - | else "")) + (if ((row >= 2)) |
---|
32 | | - | then cell(cells, (row - 2), col) |
---|
33 | | - | else "")) + (if ((row >= 1)) |
---|
34 | | - | then cell(cells, (row - 1), col) |
---|
35 | | - | else "")) + cell(cells, row, col)) + (if ((13 >= row)) |
---|
36 | | - | then cell(cells, (row + 1), col) |
---|
37 | | - | else "")) + (if ((12 >= row)) |
---|
38 | | - | then cell(cells, (row + 2), col) |
---|
39 | | - | else "")) + (if ((11 >= row)) |
---|
40 | | - | then cell(cells, (row + 3), col) |
---|
41 | | - | else "")) + (if ((10 >= row)) |
---|
42 | | - | then cell(cells, (row + 4), col) |
---|
43 | | - | else "")) + (if (if ((row >= 4)) |
---|
44 | | - | then (10 >= col) |
---|
45 | | - | else false) |
---|
46 | | - | then cell(cells, (row - 4), (col + 4)) |
---|
47 | | - | else "")) + (if (if ((row >= 3)) |
---|
48 | | - | then (11 >= col) |
---|
49 | | - | else false) |
---|
50 | | - | then cell(cells, (row - 3), (col + 3)) |
---|
51 | | - | else "")) + (if (if ((row >= 2)) |
---|
52 | | - | then (12 >= col) |
---|
53 | | - | else false) |
---|
54 | | - | then cell(cells, (row - 2), (col + 2)) |
---|
55 | | - | else "")) + (if (if ((row >= 1)) |
---|
56 | | - | then (13 >= col) |
---|
57 | | - | else false) |
---|
58 | | - | then cell(cells, (row - 1), (col + 1)) |
---|
59 | | - | else "")) + cell(cells, row, col)) + (if (if ((13 >= row)) |
---|
60 | | - | then (col >= 1) |
---|
61 | | - | else false) |
---|
62 | | - | then cell(cells, (row + 1), (col - 1)) |
---|
63 | | - | else "")) + (if (if ((12 >= row)) |
---|
64 | | - | then (col >= 2) |
---|
65 | | - | else false) |
---|
66 | | - | then cell(cells, (row + 2), (col - 2)) |
---|
67 | | - | else "")) + (if (if ((11 >= row)) |
---|
68 | | - | then (col >= 3) |
---|
69 | | - | else false) |
---|
70 | | - | then cell(cells, (row + 3), (col - 3)) |
---|
71 | | - | else "")) + (if (if ((10 >= row)) |
---|
72 | | - | then (col >= 4) |
---|
73 | | - | else false) |
---|
74 | | - | then cell(cells, (row + 4), (col - 4)) |
---|
75 | | - | else "")) + (if (if ((row >= 4)) |
---|
76 | | - | then (col >= 4) |
---|
77 | | - | else false) |
---|
78 | | - | then cell(cells, (row - 4), (col - 4)) |
---|
79 | | - | else "")) + (if (if ((row >= 3)) |
---|
80 | | - | then (col >= 3) |
---|
81 | | - | else false) |
---|
82 | | - | then cell(cells, (row - 3), (col - 3)) |
---|
83 | | - | else "")) + (if (if ((row >= 2)) |
---|
84 | | - | then (col >= 2) |
---|
85 | | - | else false) |
---|
86 | | - | then cell(cells, (row - 2), (col - 2)) |
---|
87 | | - | else "")) + (if (if ((row >= 1)) |
---|
88 | | - | then (col >= 1) |
---|
89 | | - | else false) |
---|
90 | | - | then cell(cells, (row - 1), (col - 1)) |
---|
91 | | - | else "")) + cell(cells, row, col)) + (if (if ((13 >= row)) |
---|
92 | | - | then (13 >= col) |
---|
93 | | - | else false) |
---|
94 | | - | then cell(cells, (row + 1), (col + 1)) |
---|
95 | | - | else "")) + (if (if ((12 >= row)) |
---|
96 | | - | then (12 >= col) |
---|
97 | | - | else false) |
---|
98 | | - | then cell(cells, (row + 2), (col + 2)) |
---|
99 | | - | else "")) + (if (if ((11 >= row)) |
---|
100 | | - | then (11 >= col) |
---|
101 | | - | else false) |
---|
102 | | - | then cell(cells, (row + 3), (col + 3)) |
---|
103 | | - | else "")) + (if (if ((10 >= row)) |
---|
104 | | - | then (10 >= col) |
---|
105 | | - | else false) |
---|
106 | | - | then cell(cells, (row + 4), (col + 4)) |
---|
107 | | - | else "")) |
---|
108 | | - | if (if ((c != "b")) |
---|
109 | | - | then (c != "w") |
---|
110 | | - | else false) |
---|
111 | | - | then throw("invalid color in check function") |
---|
112 | | - | else match indexOf(targetLines, ((((c + c) + c) + c) + c)) { |
---|
113 | | - | case _: Int => |
---|
114 | | - | true |
---|
115 | | - | case _ => |
---|
116 | | - | false |
---|
117 | | - | } |
---|
118 | | - | } |
---|
119 | | - | |
---|
120 | | - | |
---|
121 | | - | @Callable(i) |
---|
122 | | - | func test (game,row,col,color) = { |
---|
123 | | - | let cells = extract(getString(this, (("game:" + toString(game)) + "_cells"))) |
---|
124 | | - | throw(toString(checkField(cells, color, row, col))) |
---|
125 | | - | } |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | @Callable(i) |
---|
130 | | - | func testSetCell (game,row,col,val) = { |
---|
131 | | - | let cells = extract(getString(this, (("game:" + toString(game)) + "_cells"))) |
---|
132 | | - | let newCells = setCell(cells, row, col, val) |
---|
133 | | - | WriteSet([DataEntry((("game:" + toString(game)) + "_cells"), newCells)]) |
---|
134 | | - | } |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | @Verifier(tx) |
---|
138 | | - | func verify () = true |
---|
139 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|