tx · A35xkg7yd7RtaA1DB2hywUWCioEbXApN56kCDi4xRr8H 3Mr1J95HgTFuj93Uh61WS1PBrxc5hSx5uE5: -0.05000000 Waves 2024.07.27 12:04 [3212270] smart account 3Mr1J95HgTFuj93Uh61WS1PBrxc5hSx5uE5 > SELF 0.00000000 Waves
{ "type": 13, "id": "A35xkg7yd7RtaA1DB2hywUWCioEbXApN56kCDi4xRr8H", "fee": 5000000, "feeAssetId": null, "timestamp": 1722071141021, "version": 2, "chainId": 84, "sender": "3Mr1J95HgTFuj93Uh61WS1PBrxc5hSx5uE5", "senderPublicKey": "DhKSnv34wE65np8uDd8E6ygEbNsn6fHx9p7q4hJTcgRw", "proofs": [ "4hZ5ySLaNPo4pHcTQc4QNkth653C5KaRfYEvEZRHt2mmbweMMyocbG1BU5Zm7H9ggv36xA1LCBS5HHjCCGc9wseB" ], "script": "base64:AAIFAAAAAAAAAA0IAhIDCgEIEgQKAggIAAAACAAAAAAMQkFJX0NPTlRSQUNUAgAAACMzTjl0S2l4enFUWVduRVhReHJEUTVwQlRHdlFkNnNGc3ZtVgAAAAAMQkFJX0FTU0VUX0lEAQAAACCT4XI4cQSbauiaYx8EJLdkU5csPrxmC4N0r2i7JI3iQgAAAAAGUExBWUVSAgAAAAExAAAAAAJBSQIAAAABMgAAAAAOV0lOTklOR19BTU9VTlQAAAAAAAX14QABAAAABmNoYXJBdAAAAAIAAAADc3RyAAAAAWkJAAGRAAAAAgkABLUAAAACBQAAAANzdHICAAAAAAUAAAABaQEAAAASY2hlY2tJZk1vdmVJc1ZhbGlkAAAAAgAAAAZnYW1lSWQAAAAFYm9hcmQEAAAADGN1cnJlbnRCb2FyZAQAAAAHJG1hdGNoMAkABCIAAAABCQABLAAAAAICAAAADWN1cnJlbnRCb2FyZF8FAAAABmdhbWVJZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAgAAAAkwMDAwMDAwMDAEAAAAD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QAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlebdNRQQ=", "height": 3212270, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BjhesTfFhPwSt7kshZq4BieM3G6R2TG9aPpRDGphDKxK Next: RTZ28Qex1k28Y6UuWwyPaYsGYd4WtUjnRZeBJb2DWDz Diff:
Old | New | Differences | |
---|---|---|---|
112 | 112 | else false | |
113 | 113 | let countMoves = ((((((((firstSelected + secondSelected) + thirdSelected) + fourthSelected) + fifthSelected) + sixthSelected) + seventhSelected) + eighthSelected) + ninthSelected) | |
114 | 114 | let onlyOneMove = (1 >= countMoves) | |
115 | - | if (noOldPositionOverwritten) | |
116 | - | then onlyOneMove | |
117 | - | else false | |
115 | + | if ((countMoves > 1)) | |
116 | + | then throw("More than move made!") | |
117 | + | else if (!(noOldPositionOverwritten)) | |
118 | + | then throw("Former position overwritten!") | |
119 | + | else if (noOldPositionOverwritten) | |
120 | + | then onlyOneMove | |
121 | + | else false | |
118 | 122 | } | |
119 | 123 | ||
120 | 124 | ||
189 | 193 | let parts = split(gameIdAndBoard, "_") | |
190 | 194 | let gameId = parts[0] | |
191 | 195 | let board = parts[1] | |
192 | - | let nextPlayer = match getString(("next_player_" + gameId)) { | |
193 | - | case s: String => | |
194 | - | s | |
195 | - | case _ => | |
196 | - | "" | |
197 | - | } | |
198 | 196 | let moveOfAIIsValid = checkIfMoveIsValid(gameId, board) | |
199 | - | if ((nextPlayer != AI)) | |
200 | - | then throw("Player has to move first") | |
201 | - | else if (!(moveOfAIIsValid)) | |
202 | - | then throw("Illegal move!") | |
203 | - | else { | |
204 | - | let aiHasWon = checkIfPlayerHasWon(gameId, board, AI) | |
205 | - | if (aiHasWon) | |
206 | - | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "ai")] | |
207 | - | else [StringEntry(("currentBoard_" + gameId), board), StringEntry(("next_player_" + gameId), PLAYER)] | |
208 | - | } | |
197 | + | if (!(moveOfAIIsValid)) | |
198 | + | then throw("Illegal move!") | |
199 | + | else { | |
200 | + | let aiHasWon = checkIfPlayerHasWon(gameId, board, AI) | |
201 | + | if (aiHasWon) | |
202 | + | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "ai")] | |
203 | + | else [StringEntry(("currentBoard_" + gameId), board)] | |
204 | + | } | |
209 | 205 | } | |
210 | 206 | ||
211 | 207 | ||
234 | 230 | let gameId = if ((size(game) == 0)) | |
235 | 231 | then toBase58String(i.transactionId) | |
236 | 232 | else game | |
237 | - | let | |
233 | + | let currentBoard = match getString(("currentBoard_" + gameId)) { | |
238 | 234 | case s: String => | |
239 | 235 | s | |
240 | 236 | case _ => | |
241 | - | | |
237 | + | board | |
242 | 238 | } | |
243 | - | if ((nextPlayer != PLAYER)) | |
244 | - | then throw("AI has to move first!") | |
239 | + | let initiator = match getString(("initiator_" + gameId)) { | |
240 | + | case s: String => | |
241 | + | s | |
242 | + | case _ => | |
243 | + | sender | |
244 | + | } | |
245 | + | if ((sender != initiator)) | |
246 | + | then throw("Only initiator is allowed to make moves!") | |
245 | 247 | else { | |
246 | - | let currentBoard = match getString(("currentBoard_" + gameId)) { | |
247 | - | case s: String => | |
248 | - | s | |
249 | - | case _ => | |
250 | - | board | |
251 | - | } | |
252 | - | let initiator = match getString(("initiator_" + gameId)) { | |
253 | - | case s: String => | |
254 | - | s | |
255 | - | case _ => | |
256 | - | sender | |
257 | - | } | |
258 | - | if ((sender != initiator)) | |
259 | - | then throw("Only initiator is allowed to make moves!") | |
248 | + | let moveOfPlayerIsValid = checkIfMoveIsValid(gameId, board) | |
249 | + | if (!(moveOfPlayerIsValid)) | |
250 | + | then throw("Illegal move!") | |
260 | 251 | else { | |
261 | - | let | |
262 | - | if ( | |
263 | - | then | |
252 | + | let playerHasWon = checkIfPlayerHasWon(gameId, board, PLAYER) | |
253 | + | if (playerHasWon) | |
254 | + | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "player"), ScriptTransfer(sender, WINNING_AMOUNT, BAI_ASSET_ID)] | |
264 | 255 | else { | |
265 | - | let playerHasWon = checkIfPlayerHasWon(gameId, board, PLAYER) | |
266 | - | if (playerHasWon) | |
267 | - | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "player"), ScriptTransfer(sender, WINNING_AMOUNT, BAI_ASSET_ID)] | |
268 | - | else { | |
269 | - | let nextMove = invoke(Address(fromBase58String(BAI_CONTRACT)), "registerTaskCallback", [((gameId + "_") + board), "tictactoe", "callback"], [AttachedPayment(BAI_ASSET_ID, 10000000)]) | |
270 | - | [StringEntry(("currentBoard_" + gameId), board), StringEntry(("initiator_" + gameId), toString(sender)), StringEntry(("next_player_" + gameId), AI)] | |
271 | - | } | |
256 | + | let nextMove = invoke(Address(fromBase58String(BAI_CONTRACT)), "registerTaskCallback", [((gameId + "_") + board), "tictactoe", "callback"], [AttachedPayment(BAI_ASSET_ID, 10000000)]) | |
257 | + | [StringEntry(("currentBoard_" + gameId), board), StringEntry(("initiator_" + gameId), toString(sender))] | |
272 | 258 | } | |
273 | 259 | } | |
274 | 260 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let BAI_CONTRACT = "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV" | |
5 | 5 | ||
6 | 6 | let BAI_ASSET_ID = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1' | |
7 | 7 | ||
8 | 8 | let PLAYER = "1" | |
9 | 9 | ||
10 | 10 | let AI = "2" | |
11 | 11 | ||
12 | 12 | let WINNING_AMOUNT = 100000000 | |
13 | 13 | ||
14 | 14 | func charAt (str,i) = split(str, "")[i] | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func checkIfMoveIsValid (gameId,board) = { | |
18 | 18 | let currentBoard = match getString(("currentBoard_" + gameId)) { | |
19 | 19 | case s: String => | |
20 | 20 | s | |
21 | 21 | case _ => | |
22 | 22 | "000000000" | |
23 | 23 | } | |
24 | 24 | let firstSelected = if ((charAt(board, 0) != charAt(currentBoard, 0))) | |
25 | 25 | then 1 | |
26 | 26 | else 0 | |
27 | 27 | let secondSelected = if ((charAt(board, 1) != charAt(currentBoard, 1))) | |
28 | 28 | then 1 | |
29 | 29 | else 0 | |
30 | 30 | let thirdSelected = if ((charAt(board, 2) != charAt(currentBoard, 2))) | |
31 | 31 | then 1 | |
32 | 32 | else 0 | |
33 | 33 | let fourthSelected = if ((charAt(board, 3) != charAt(currentBoard, 3))) | |
34 | 34 | then 1 | |
35 | 35 | else 0 | |
36 | 36 | let fifthSelected = if ((charAt(board, 4) != charAt(currentBoard, 4))) | |
37 | 37 | then 1 | |
38 | 38 | else 0 | |
39 | 39 | let sixthSelected = if ((charAt(board, 5) != charAt(currentBoard, 5))) | |
40 | 40 | then 1 | |
41 | 41 | else 0 | |
42 | 42 | let seventhSelected = if ((charAt(board, 6) != charAt(currentBoard, 6))) | |
43 | 43 | then 1 | |
44 | 44 | else 0 | |
45 | 45 | let eighthSelected = if ((charAt(board, 7) != charAt(currentBoard, 7))) | |
46 | 46 | then 1 | |
47 | 47 | else 0 | |
48 | 48 | let ninthSelected = if ((charAt(board, 8) != charAt(currentBoard, 8))) | |
49 | 49 | then 1 | |
50 | 50 | else 0 | |
51 | 51 | let firstPositionCorrect = if (if ((charAt(board, 0) == charAt(currentBoard, 0))) | |
52 | 52 | then true | |
53 | 53 | else (charAt(board, 0) == "0")) | |
54 | 54 | then true | |
55 | 55 | else false | |
56 | 56 | let secondPositionCorrect = if (if ((charAt(board, 1) == charAt(currentBoard, 1))) | |
57 | 57 | then true | |
58 | 58 | else (charAt(board, 1) == "0")) | |
59 | 59 | then true | |
60 | 60 | else false | |
61 | 61 | let thirdPositionCorrect = if (if ((charAt(board, 2) == charAt(currentBoard, 2))) | |
62 | 62 | then true | |
63 | 63 | else (charAt(board, 2) == "0")) | |
64 | 64 | then true | |
65 | 65 | else false | |
66 | 66 | let fourthPositionCorrect = if (if ((charAt(board, 3) == charAt(currentBoard, 3))) | |
67 | 67 | then true | |
68 | 68 | else (charAt(board, 3) == "0")) | |
69 | 69 | then true | |
70 | 70 | else false | |
71 | 71 | let fifthPositionCorrect = if (if ((charAt(board, 4) == charAt(currentBoard, 4))) | |
72 | 72 | then true | |
73 | 73 | else (charAt(board, 4) == "0")) | |
74 | 74 | then true | |
75 | 75 | else false | |
76 | 76 | let sixthPositionCorrect = if (if ((charAt(board, 5) == charAt(currentBoard, 5))) | |
77 | 77 | then true | |
78 | 78 | else (charAt(board, 5) == "0")) | |
79 | 79 | then true | |
80 | 80 | else false | |
81 | 81 | let seventhPositionCorrect = if (if ((charAt(board, 6) == charAt(currentBoard, 6))) | |
82 | 82 | then true | |
83 | 83 | else (charAt(board, 6) == "0")) | |
84 | 84 | then true | |
85 | 85 | else false | |
86 | 86 | let eighthPositionCorrect = if (if ((charAt(board, 7) == charAt(currentBoard, 7))) | |
87 | 87 | then true | |
88 | 88 | else (charAt(board, 7) == "0")) | |
89 | 89 | then true | |
90 | 90 | else false | |
91 | 91 | let ninthPositionCorrect = if (if ((charAt(board, 8) == charAt(currentBoard, 8))) | |
92 | 92 | then true | |
93 | 93 | else (charAt(board, 8) == "0")) | |
94 | 94 | then true | |
95 | 95 | else false | |
96 | 96 | let noOldPositionOverwritten = if (if (if (if (if (if (if (if (firstPositionCorrect) | |
97 | 97 | then secondPositionCorrect | |
98 | 98 | else false) | |
99 | 99 | then thirdPositionCorrect | |
100 | 100 | else false) | |
101 | 101 | then fourthPositionCorrect | |
102 | 102 | else false) | |
103 | 103 | then fifthPositionCorrect | |
104 | 104 | else false) | |
105 | 105 | then sixthPositionCorrect | |
106 | 106 | else false) | |
107 | 107 | then seventhPositionCorrect | |
108 | 108 | else false) | |
109 | 109 | then eighthPositionCorrect | |
110 | 110 | else false) | |
111 | 111 | then ninthPositionCorrect | |
112 | 112 | else false | |
113 | 113 | let countMoves = ((((((((firstSelected + secondSelected) + thirdSelected) + fourthSelected) + fifthSelected) + sixthSelected) + seventhSelected) + eighthSelected) + ninthSelected) | |
114 | 114 | let onlyOneMove = (1 >= countMoves) | |
115 | - | if (noOldPositionOverwritten) | |
116 | - | then onlyOneMove | |
117 | - | else false | |
115 | + | if ((countMoves > 1)) | |
116 | + | then throw("More than move made!") | |
117 | + | else if (!(noOldPositionOverwritten)) | |
118 | + | then throw("Former position overwritten!") | |
119 | + | else if (noOldPositionOverwritten) | |
120 | + | then onlyOneMove | |
121 | + | else false | |
118 | 122 | } | |
119 | 123 | ||
120 | 124 | ||
121 | 125 | func checkIfPlayerHasWon (gameId,board,player) = { | |
122 | 126 | let currentBoard = match getString(("currentBoard_" + gameId)) { | |
123 | 127 | case s: String => | |
124 | 128 | s | |
125 | 129 | case _ => | |
126 | 130 | "000000000" | |
127 | 131 | } | |
128 | 132 | let winningCombinations = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] | |
129 | 133 | let topRow = if (if ((charAt(currentBoard, winningCombinations[0][0]) == player)) | |
130 | 134 | then (charAt(currentBoard, winningCombinations[0][1]) == player) | |
131 | 135 | else false) | |
132 | 136 | then (charAt(currentBoard, winningCombinations[0][2]) == player) | |
133 | 137 | else false | |
134 | 138 | let middleRow = if (if ((charAt(currentBoard, winningCombinations[1][0]) == player)) | |
135 | 139 | then (charAt(currentBoard, winningCombinations[1][1]) == player) | |
136 | 140 | else false) | |
137 | 141 | then (charAt(currentBoard, winningCombinations[1][2]) == player) | |
138 | 142 | else false | |
139 | 143 | let bottomRow = if (if ((charAt(currentBoard, winningCombinations[2][0]) == player)) | |
140 | 144 | then (charAt(currentBoard, winningCombinations[2][1]) == player) | |
141 | 145 | else false) | |
142 | 146 | then (charAt(currentBoard, winningCombinations[2][2]) == player) | |
143 | 147 | else false | |
144 | 148 | let leftColumn = if (if ((charAt(currentBoard, winningCombinations[3][0]) == player)) | |
145 | 149 | then (charAt(currentBoard, winningCombinations[3][1]) == player) | |
146 | 150 | else false) | |
147 | 151 | then (charAt(currentBoard, winningCombinations[3][2]) == player) | |
148 | 152 | else false | |
149 | 153 | let middleColumn = if (if ((charAt(currentBoard, winningCombinations[4][0]) == player)) | |
150 | 154 | then (charAt(currentBoard, winningCombinations[4][1]) == player) | |
151 | 155 | else false) | |
152 | 156 | then (charAt(currentBoard, winningCombinations[4][2]) == player) | |
153 | 157 | else false | |
154 | 158 | let rightColumn = if (if ((charAt(currentBoard, winningCombinations[5][0]) == player)) | |
155 | 159 | then (charAt(currentBoard, winningCombinations[5][1]) == player) | |
156 | 160 | else false) | |
157 | 161 | then (charAt(currentBoard, winningCombinations[5][2]) == player) | |
158 | 162 | else false | |
159 | 163 | let diagonalOne = if (if ((charAt(currentBoard, winningCombinations[6][0]) == player)) | |
160 | 164 | then (charAt(currentBoard, winningCombinations[6][1]) == player) | |
161 | 165 | else false) | |
162 | 166 | then (charAt(currentBoard, winningCombinations[6][2]) == player) | |
163 | 167 | else false | |
164 | 168 | let diagonalTwo = if (if ((charAt(currentBoard, winningCombinations[7][0]) == player)) | |
165 | 169 | then (charAt(currentBoard, winningCombinations[7][1]) == player) | |
166 | 170 | else false) | |
167 | 171 | then (charAt(currentBoard, winningCombinations[7][2]) == player) | |
168 | 172 | else false | |
169 | 173 | if (if (if (if (if (if (if (topRow) | |
170 | 174 | then true | |
171 | 175 | else middleRow) | |
172 | 176 | then true | |
173 | 177 | else bottomRow) | |
174 | 178 | then true | |
175 | 179 | else leftColumn) | |
176 | 180 | then true | |
177 | 181 | else middleRow) | |
178 | 182 | then true | |
179 | 183 | else rightColumn) | |
180 | 184 | then true | |
181 | 185 | else diagonalOne) | |
182 | 186 | then true | |
183 | 187 | else diagonalTwo | |
184 | 188 | } | |
185 | 189 | ||
186 | 190 | ||
187 | 191 | @Callable(i) | |
188 | 192 | func callback (gameIdAndBoard) = { | |
189 | 193 | let parts = split(gameIdAndBoard, "_") | |
190 | 194 | let gameId = parts[0] | |
191 | 195 | let board = parts[1] | |
192 | - | let nextPlayer = match getString(("next_player_" + gameId)) { | |
193 | - | case s: String => | |
194 | - | s | |
195 | - | case _ => | |
196 | - | "" | |
197 | - | } | |
198 | 196 | let moveOfAIIsValid = checkIfMoveIsValid(gameId, board) | |
199 | - | if ((nextPlayer != AI)) | |
200 | - | then throw("Player has to move first") | |
201 | - | else if (!(moveOfAIIsValid)) | |
202 | - | then throw("Illegal move!") | |
203 | - | else { | |
204 | - | let aiHasWon = checkIfPlayerHasWon(gameId, board, AI) | |
205 | - | if (aiHasWon) | |
206 | - | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "ai")] | |
207 | - | else [StringEntry(("currentBoard_" + gameId), board), StringEntry(("next_player_" + gameId), PLAYER)] | |
208 | - | } | |
197 | + | if (!(moveOfAIIsValid)) | |
198 | + | then throw("Illegal move!") | |
199 | + | else { | |
200 | + | let aiHasWon = checkIfPlayerHasWon(gameId, board, AI) | |
201 | + | if (aiHasWon) | |
202 | + | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "ai")] | |
203 | + | else [StringEntry(("currentBoard_" + gameId), board)] | |
204 | + | } | |
209 | 205 | } | |
210 | 206 | ||
211 | 207 | ||
212 | 208 | ||
213 | 209 | @Callable(i) | |
214 | 210 | func playTTT (game,board) = { | |
215 | 211 | let numberOfPayments = size(i.payments) | |
216 | 212 | if ((numberOfPayments != 1)) | |
217 | 213 | then throw("Payment necessary!") | |
218 | 214 | else { | |
219 | 215 | let payment = i.payments[0] | |
220 | 216 | let fee = payment.amount | |
221 | 217 | let feeAssetId = payment.assetId | |
222 | 218 | let minFee = match getInteger(Address(fromBase58String(BAI_CONTRACT)), "price_tictactoe") { | |
223 | 219 | case n: Int => | |
224 | 220 | n | |
225 | 221 | case _ => | |
226 | 222 | 0 | |
227 | 223 | } | |
228 | 224 | if (if ((feeAssetId != BAI_ASSET_ID)) | |
229 | 225 | then true | |
230 | 226 | else (minFee > fee)) | |
231 | 227 | then throw("Payment of the minimal BAI amount necessary!") | |
232 | 228 | else { | |
233 | 229 | let sender = i.caller | |
234 | 230 | let gameId = if ((size(game) == 0)) | |
235 | 231 | then toBase58String(i.transactionId) | |
236 | 232 | else game | |
237 | - | let | |
233 | + | let currentBoard = match getString(("currentBoard_" + gameId)) { | |
238 | 234 | case s: String => | |
239 | 235 | s | |
240 | 236 | case _ => | |
241 | - | | |
237 | + | board | |
242 | 238 | } | |
243 | - | if ((nextPlayer != PLAYER)) | |
244 | - | then throw("AI has to move first!") | |
239 | + | let initiator = match getString(("initiator_" + gameId)) { | |
240 | + | case s: String => | |
241 | + | s | |
242 | + | case _ => | |
243 | + | sender | |
244 | + | } | |
245 | + | if ((sender != initiator)) | |
246 | + | then throw("Only initiator is allowed to make moves!") | |
245 | 247 | else { | |
246 | - | let currentBoard = match getString(("currentBoard_" + gameId)) { | |
247 | - | case s: String => | |
248 | - | s | |
249 | - | case _ => | |
250 | - | board | |
251 | - | } | |
252 | - | let initiator = match getString(("initiator_" + gameId)) { | |
253 | - | case s: String => | |
254 | - | s | |
255 | - | case _ => | |
256 | - | sender | |
257 | - | } | |
258 | - | if ((sender != initiator)) | |
259 | - | then throw("Only initiator is allowed to make moves!") | |
248 | + | let moveOfPlayerIsValid = checkIfMoveIsValid(gameId, board) | |
249 | + | if (!(moveOfPlayerIsValid)) | |
250 | + | then throw("Illegal move!") | |
260 | 251 | else { | |
261 | - | let | |
262 | - | if ( | |
263 | - | then | |
252 | + | let playerHasWon = checkIfPlayerHasWon(gameId, board, PLAYER) | |
253 | + | if (playerHasWon) | |
254 | + | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "player"), ScriptTransfer(sender, WINNING_AMOUNT, BAI_ASSET_ID)] | |
264 | 255 | else { | |
265 | - | let playerHasWon = checkIfPlayerHasWon(gameId, board, PLAYER) | |
266 | - | if (playerHasWon) | |
267 | - | then [StringEntry(("currentBoard_" + gameId), board), StringEntry(("winner_" + gameId), "player"), ScriptTransfer(sender, WINNING_AMOUNT, BAI_ASSET_ID)] | |
268 | - | else { | |
269 | - | let nextMove = invoke(Address(fromBase58String(BAI_CONTRACT)), "registerTaskCallback", [((gameId + "_") + board), "tictactoe", "callback"], [AttachedPayment(BAI_ASSET_ID, 10000000)]) | |
270 | - | [StringEntry(("currentBoard_" + gameId), board), StringEntry(("initiator_" + gameId), toString(sender)), StringEntry(("next_player_" + gameId), AI)] | |
271 | - | } | |
256 | + | let nextMove = invoke(Address(fromBase58String(BAI_CONTRACT)), "registerTaskCallback", [((gameId + "_") + board), "tictactoe", "callback"], [AttachedPayment(BAI_ASSET_ID, 10000000)]) | |
257 | + | [StringEntry(("currentBoard_" + gameId), board), StringEntry(("initiator_" + gameId), toString(sender))] | |
272 | 258 | } | |
273 | 259 | } | |
274 | 260 | } | |
275 | 261 | } | |
276 | 262 | } | |
277 | 263 | } | |
278 | 264 | ||
279 | 265 | ||
280 | 266 | @Verifier(tx) | |
281 | 267 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
282 | 268 |
github/deemru/w8io/026f985 51.33 ms ◑