tx · 864xNvJnBUwTCzZirzdsRzE6TPcHiAWuqeka1L9W3xwp 3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV: -0.01000000 Waves 2021.12.09 08:50 [1826307] smart account 3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV > SELF 0.00000000 Waves
{ "type": 13, "id": "864xNvJnBUwTCzZirzdsRzE6TPcHiAWuqeka1L9W3xwp", "fee": 1000000, "feeAssetId": null, "timestamp": 1639029035349, "version": 2, "chainId": 84, "sender": "3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV", "senderPublicKey": "5amLtMwixiEesBDKPy9dkFWntG2fNxhTs5n69JbQE9F7", "proofs": [ "4q8b6C5Xamb1tTMcP5Dfy5yQnoGYjccvu4Yrzy8efWAYCL6gXCxkZRfKE89BK5VB8MtrCShtGAQ6gPwrV65U8bFK" ], "script": "base64:AAIFAAAAAAAAABoIAhIAEgUKAwgICBIDCgEIEgMKAQgSAwoBCAAAAAEAAAAABXNlcGFyAgAAAAF8AAAABQAAAAFpAQAAAAVyZXNldAAAAAAJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgIAAAAKbGFzdGdhbWVpZAIAAAABMAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACAgAAAA9sYXN0Y2hhbGxlbmdlaWQCAAAAATAFAAAAA25pbAAAAAFpAQAAAARtb3ZlAAAAAwAAAAZnYW1laWQAAAAEZnJvbQAAAAJ0bwQAAAAEZ2FtZQkABLUAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1OCkAAAABCQABLAAAAAICAAAABWdhbWUtBQAAAAZnYW1laWQFAAAABXNlcGFyAwkAAAAAAAACBQAAAARnYW1lBQAAAARnYW1lBAAAAAxjYWxsZXJBZHJlc3MJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwMJAAAAAAAAAgUAAAAMY2FsbGVyQWRyZXNzBQAAAAxjYWxsZXJBZHJlc3MEAAAABmlzZ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AkABCIAAAABCQABLAAAAAICAAAACmNoYWxsZW5nZS0FAAAADGNoYWxsZW5kZ2VpZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwCQEAAAARQGV4dHJOYXRpdmUoMTA1OCkAAAABCQABLAAAAAICAAAACmNoYWxsZW5nZS0FAAAADGNoYWxsZW5kZ2VpZAIAAAAABAAAAAljaGFsbGVuZ2UJAAS1AAAAAgkBAAAADGdldGNoYWxsZW5nZQAAAAEFAAAADGNoYWxsZW5kZ2VpZAUAAAAFc2VwYXIDCQAAZgAAAAIJAAGQAAAAAQUAAAAJY2hhbGxlbmdlAAAAAAAAAAAAAwkAAAAAAAACCQABkQAAAAIFAAAACWNoYWxsZW5nZQAAAAAAAAAAAAIAAAAIYXdhaXRpbmcJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkAASwAAAACAgAAAApjaGFsbGVuZ2UtBQAAAAxjaGFsbGVuZGdlaWQJAAS5AAAAAgkABEwAAAACAgAAAAV1bnNldAkABEwAAAACCQABkQAAAAIFAAAACWNoYWxsZW5nZQAAAAAAAAAAAQkABEwAAAACCQABkQAAAAIFAAAACWNoYWxsZW5nZQAAAAAAAAAAAgkABEwAAAACCQABkQAAAAIFAAAACWNoYWxsZW5nZQAAAAAAAAAAAwUAAAADbmlsBQAAAAVzZXBhcgUAAAADbmlsCQAAAgAAAAECAAAAFGNoYWxsZW5nZSBub3QgZXhpc3RzCQAAAgAAAAECAAAAFGNoYWxsZW5nZSBub3QgZXhpc3RzAAAAACDseAY=", "height": 1826307, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4QxjvxHg76BRbog9kQer2hUfmQuaeF7hPWjy7ozWYGLA Next: HymfQyQYfauW4g7s6GCVPJpQRAFbXr2UeYmMEDHhDBby Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | ||
11 | 11 | @Callable(i) | |
12 | - | func | |
12 | + | func move (gameid,from,to) = { | |
13 | 13 | let game = split(getStringValue(("game-" + gameid)), separ) | |
14 | - | if ((game | |
14 | + | if ((game == game)) | |
15 | 15 | then { | |
16 | 16 | let callerAdress = toBase58String(i.caller.bytes) | |
17 | - | if (if ((game[1] == callerAdress)) | |
18 | - | then true | |
19 | - | else (game[2] == callerAdress)) | |
17 | + | if ((callerAdress == callerAdress)) | |
20 | 18 | then { | |
21 | - | let | |
22 | - | then | |
23 | - | else " | |
24 | - | if (( | |
19 | + | let isgame = if ((game[0] == "ongoing")) | |
20 | + | then true | |
21 | + | else throw("not ongoing game") | |
22 | + | if ((isgame == isgame)) | |
25 | 23 | then { | |
26 | - | let tolist = split(to, "") | |
27 | - | let fromlist = split(from, "") | |
28 | - | let figure = fromlist[5] | |
29 | - | let fromx = parseIntValue(fromlist[0]) | |
30 | - | let fromy = parseIntValue(fromlist[1]) | |
31 | - | let tox = parseIntValue(tolist[0]) | |
32 | - | let toy = parseIntValue(tolist[1]) | |
33 | - | let situation = game[8] | |
34 | - | let rows = split(situation, "||") | |
35 | - | let cell = [split(rows[0], "|"), split(rows[1], "|"), split(rows[2], "|"), split(rows[3], "|"), split(rows[4], "|"), split(rows[5], "|"), split(rows[6], "|"), split(rows[7], "|")] | |
36 | - | if (if ((cell[fromx][fromy] == from)) | |
37 | - | then (cell[tox][toy] == to) | |
24 | + | let side = if (if (isgame) | |
25 | + | then if ((game[1] == callerAdress)) | |
26 | + | then true | |
27 | + | else (game[2] == callerAdress) | |
38 | 28 | else false) | |
39 | - | then if ((figure == "p")) | |
40 | - | then if ((side == "w")) | |
41 | - | then if ((tolist[3] == "b")) | |
42 | - | then if (if (((fromy - toy) == 1)) | |
43 | - | then if (((fromx - tox) == 1)) | |
44 | - | then true | |
45 | - | else ((fromx - tox) == 1) | |
46 | - | else false) | |
47 | - | then [StringEntry("-", "-")] | |
48 | - | else throw("incorrect eating") | |
49 | - | else { | |
50 | - | let c = split(cell[fromx][(fromy - 1)], "") | |
51 | - | let freecell = if ((c[3] == "0")) | |
52 | - | then true | |
53 | - | else false | |
54 | - | if (if ((fromx == tox)) | |
55 | - | then if (((fromy - tox) == 1)) | |
29 | + | then if ((game[1] == callerAdress)) | |
30 | + | then "w" | |
31 | + | else "b" | |
32 | + | else throw("not gamer") | |
33 | + | if ((side == side)) | |
34 | + | then { | |
35 | + | let turn = if ((side == game[5])) | |
36 | + | then true | |
37 | + | else throw("not your turn") | |
38 | + | if ((turn == turn)) | |
39 | + | then { | |
40 | + | let situation = split(game[8], "||") | |
41 | + | let cells = [split(situation[0], "|"), split(situation[1], "|"), split(situation[2], "|"), split(situation[3], "|"), split(situation[4], "|"), split(situation[5], "|"), split(situation[6], "|"), split(situation[7], "|")] | |
42 | + | if ((cells == cells)) | |
43 | + | then { | |
44 | + | let froms = split(from, "") | |
45 | + | let tos = split(to, "") | |
46 | + | let fromx = parseIntValue(froms[0]) | |
47 | + | let fromy = parseIntValue(froms[1]) | |
48 | + | let tox = parseIntValue(tos[0]) | |
49 | + | let toy = parseIntValue(tos[1]) | |
50 | + | let iscorrect = if (if ((take(cells[fromx][fromy], 1) == side)) | |
51 | + | then (take(cells[tox][toy], 1) != side) | |
52 | + | else false) | |
56 | 53 | then true | |
57 | - | else if (((fromx - tox) == 2)) | |
58 | - | then freecell | |
59 | - | else false | |
60 | - | else false) | |
61 | - | then [StringEntry("moved", ((("from-" + from) + " to-") + to))] | |
62 | - | else throw("incorrect move") | |
63 | - | } | |
64 | - | else [StringEntry("-", "-")] | |
65 | - | else [StringEntry("-", "-")] | |
66 | - | else throw("not situation") | |
54 | + | else throw("wrong position") | |
55 | + | if ((iscorrect == iscorrect)) | |
56 | + | then { | |
57 | + | let figure = cells[fromx][fromy] | |
58 | + | if (iscorrect) | |
59 | + | then [StringEntry("_", "figure")] | |
60 | + | else [StringEntry("_", "_")] | |
61 | + | } | |
62 | + | else throw("Strict value is not equal to itself.") | |
63 | + | } | |
64 | + | else throw("Strict value is not equal to itself.") | |
65 | + | } | |
66 | + | else throw("Strict value is not equal to itself.") | |
67 | + | } | |
68 | + | else throw("Strict value is not equal to itself.") | |
67 | 69 | } | |
68 | - | else throw("not | |
70 | + | else throw("Strict value is not equal to itself.") | |
69 | 71 | } | |
70 | - | else throw("not | |
72 | + | else throw("Strict value is not equal to itself.") | |
71 | 73 | } | |
72 | - | else throw("not | |
74 | + | else throw("Strict value is not equal to itself.") | |
73 | 75 | } | |
74 | 76 | ||
75 | 77 | ||
96 | 98 | else callerAdress | |
97 | 99 | let gameid = toString((parseIntValue(getStringValue("lastgameid")) + 1)) | |
98 | 100 | [StringEntry(("challenge-" + challengeid), makeString([gameid, conditions[1], conditions[2], conditions[3], callerAdress], separ)), { | |
99 | - | let situation = " | |
101 | + | let situation = "wl|wh|we|wf|wq|we|wh|wl||wp|wp|wp|wp|wp|wp|wp|wp||00|00|00|00|00|00|00|00||00|00|00|00|00|00|00|00||00|00|00|00|00|00|00|00||00|00|00|00|00|00|00|00||bp|bp|bp|bp|bp|bp|bp|bp||bl|bh|be|bf|bq|be|bh|bl" | |
100 | 102 | StringEntry(("game-" + gameid), makeString(["ongoing", white, black, conditions[3], "0", "w", "startblock", "laststepblock", situation], separ)) | |
101 | 103 | }, StringEntry("lastgameid", gameid), ScriptTransfer(i.caller, (pmt.amount - parseIntValue(conditions[3])), unit)] | |
102 | 104 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separ = "|" | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func reset () = [StringEntry("lastgameid", "0"), StringEntry("lastchallengeid", "0")] | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | ||
11 | 11 | @Callable(i) | |
12 | - | func | |
12 | + | func move (gameid,from,to) = { | |
13 | 13 | let game = split(getStringValue(("game-" + gameid)), separ) | |
14 | - | if ((game | |
14 | + | if ((game == game)) | |
15 | 15 | then { | |
16 | 16 | let callerAdress = toBase58String(i.caller.bytes) | |
17 | - | if (if ((game[1] == callerAdress)) | |
18 | - | then true | |
19 | - | else (game[2] == callerAdress)) | |
17 | + | if ((callerAdress == callerAdress)) | |
20 | 18 | then { | |
21 | - | let | |
22 | - | then | |
23 | - | else " | |
24 | - | if (( | |
19 | + | let isgame = if ((game[0] == "ongoing")) | |
20 | + | then true | |
21 | + | else throw("not ongoing game") | |
22 | + | if ((isgame == isgame)) | |
25 | 23 | then { | |
26 | - | let tolist = split(to, "") | |
27 | - | let fromlist = split(from, "") | |
28 | - | let figure = fromlist[5] | |
29 | - | let fromx = parseIntValue(fromlist[0]) | |
30 | - | let fromy = parseIntValue(fromlist[1]) | |
31 | - | let tox = parseIntValue(tolist[0]) | |
32 | - | let toy = parseIntValue(tolist[1]) | |
33 | - | let situation = game[8] | |
34 | - | let rows = split(situation, "||") | |
35 | - | let cell = [split(rows[0], "|"), split(rows[1], "|"), split(rows[2], "|"), split(rows[3], "|"), split(rows[4], "|"), split(rows[5], "|"), split(rows[6], "|"), split(rows[7], "|")] | |
36 | - | if (if ((cell[fromx][fromy] == from)) | |
37 | - | then (cell[tox][toy] == to) | |
24 | + | let side = if (if (isgame) | |
25 | + | then if ((game[1] == callerAdress)) | |
26 | + | then true | |
27 | + | else (game[2] == callerAdress) | |
38 | 28 | else false) | |
39 | - | then if ((figure == "p")) | |
40 | - | then if ((side == "w")) | |
41 | - | then if ((tolist[3] == "b")) | |
42 | - | then if (if (((fromy - toy) == 1)) | |
43 | - | then if (((fromx - tox) == 1)) | |
44 | - | then true | |
45 | - | else ((fromx - tox) == 1) | |
46 | - | else false) | |
47 | - | then [StringEntry("-", "-")] | |
48 | - | else throw("incorrect eating") | |
49 | - | else { | |
50 | - | let c = split(cell[fromx][(fromy - 1)], "") | |
51 | - | let freecell = if ((c[3] == "0")) | |
52 | - | then true | |
53 | - | else false | |
54 | - | if (if ((fromx == tox)) | |
55 | - | then if (((fromy - tox) == 1)) | |
29 | + | then if ((game[1] == callerAdress)) | |
30 | + | then "w" | |
31 | + | else "b" | |
32 | + | else throw("not gamer") | |
33 | + | if ((side == side)) | |
34 | + | then { | |
35 | + | let turn = if ((side == game[5])) | |
36 | + | then true | |
37 | + | else throw("not your turn") | |
38 | + | if ((turn == turn)) | |
39 | + | then { | |
40 | + | let situation = split(game[8], "||") | |
41 | + | let cells = [split(situation[0], "|"), split(situation[1], "|"), split(situation[2], "|"), split(situation[3], "|"), split(situation[4], "|"), split(situation[5], "|"), split(situation[6], "|"), split(situation[7], "|")] | |
42 | + | if ((cells == cells)) | |
43 | + | then { | |
44 | + | let froms = split(from, "") | |
45 | + | let tos = split(to, "") | |
46 | + | let fromx = parseIntValue(froms[0]) | |
47 | + | let fromy = parseIntValue(froms[1]) | |
48 | + | let tox = parseIntValue(tos[0]) | |
49 | + | let toy = parseIntValue(tos[1]) | |
50 | + | let iscorrect = if (if ((take(cells[fromx][fromy], 1) == side)) | |
51 | + | then (take(cells[tox][toy], 1) != side) | |
52 | + | else false) | |
56 | 53 | then true | |
57 | - | else if (((fromx - tox) == 2)) | |
58 | - | then freecell | |
59 | - | else false | |
60 | - | else false) | |
61 | - | then [StringEntry("moved", ((("from-" + from) + " to-") + to))] | |
62 | - | else throw("incorrect move") | |
63 | - | } | |
64 | - | else [StringEntry("-", "-")] | |
65 | - | else [StringEntry("-", "-")] | |
66 | - | else throw("not situation") | |
54 | + | else throw("wrong position") | |
55 | + | if ((iscorrect == iscorrect)) | |
56 | + | then { | |
57 | + | let figure = cells[fromx][fromy] | |
58 | + | if (iscorrect) | |
59 | + | then [StringEntry("_", "figure")] | |
60 | + | else [StringEntry("_", "_")] | |
61 | + | } | |
62 | + | else throw("Strict value is not equal to itself.") | |
63 | + | } | |
64 | + | else throw("Strict value is not equal to itself.") | |
65 | + | } | |
66 | + | else throw("Strict value is not equal to itself.") | |
67 | + | } | |
68 | + | else throw("Strict value is not equal to itself.") | |
67 | 69 | } | |
68 | - | else throw("not | |
70 | + | else throw("Strict value is not equal to itself.") | |
69 | 71 | } | |
70 | - | else throw("not | |
72 | + | else throw("Strict value is not equal to itself.") | |
71 | 73 | } | |
72 | - | else throw("not | |
74 | + | else throw("Strict value is not equal to itself.") | |
73 | 75 | } | |
74 | 76 | ||
75 | 77 | ||
76 | 78 | ||
77 | 79 | @Callable(i) | |
78 | 80 | func startgame (challengeid) = { | |
79 | 81 | let pmt = if ((size(i.payments) == 1)) | |
80 | 82 | then i.payments[0] | |
81 | 83 | else throw("must stake some waves") | |
82 | 84 | if (isDefined(pmt.assetId)) | |
83 | 85 | then throw("works with waves only") | |
84 | 86 | else { | |
85 | 87 | let callerAdress = toBase58String(i.caller.bytes) | |
86 | 88 | let conditions = split(getStringValue(("challenge-" + challengeid)), separ) | |
87 | 89 | if ((size(conditions) > 0)) | |
88 | 90 | then if ((pmt.amount >= parseIntValue(conditions[3]))) | |
89 | 91 | then if ((conditions[0] == "awaiting")) | |
90 | 92 | then { | |
91 | 93 | let black = if ((conditions[2] == "b")) | |
92 | 94 | then conditions[1] | |
93 | 95 | else callerAdress | |
94 | 96 | let white = if ((conditions[2] == "w")) | |
95 | 97 | then conditions[1] | |
96 | 98 | else callerAdress | |
97 | 99 | let gameid = toString((parseIntValue(getStringValue("lastgameid")) + 1)) | |
98 | 100 | [StringEntry(("challenge-" + challengeid), makeString([gameid, conditions[1], conditions[2], conditions[3], callerAdress], separ)), { | |
99 | - | let situation = " | |
101 | + | let situation = "wl|wh|we|wf|wq|we|wh|wl||wp|wp|wp|wp|wp|wp|wp|wp||00|00|00|00|00|00|00|00||00|00|00|00|00|00|00|00||00|00|00|00|00|00|00|00||00|00|00|00|00|00|00|00||bp|bp|bp|bp|bp|bp|bp|bp||bl|bh|be|bf|bq|be|bh|bl" | |
100 | 102 | StringEntry(("game-" + gameid), makeString(["ongoing", white, black, conditions[3], "0", "w", "startblock", "laststepblock", situation], separ)) | |
101 | 103 | }, StringEntry("lastgameid", gameid), ScriptTransfer(i.caller, (pmt.amount - parseIntValue(conditions[3])), unit)] | |
102 | 104 | } | |
103 | 105 | else throw("no challenge awaiting") | |
104 | 106 | else throw("need more money") | |
105 | 107 | else throw("no challenge") | |
106 | 108 | } | |
107 | 109 | } | |
108 | 110 | ||
109 | 111 | ||
110 | 112 | ||
111 | 113 | @Callable(i) | |
112 | 114 | func setchallenge (side) = if (if ((side == "b")) | |
113 | 115 | then true | |
114 | 116 | else (side == "w")) | |
115 | 117 | then { | |
116 | 118 | let pmt = if ((size(i.payments) == 1)) | |
117 | 119 | then i.payments[0] | |
118 | 120 | else throw("must stake some waves") | |
119 | 121 | if (isDefined(pmt.assetId)) | |
120 | 122 | then throw("works with waves only") | |
121 | 123 | else { | |
122 | 124 | let callerAdress = toBase58String(i.caller.bytes) | |
123 | 125 | let challengeid = toString((parseIntValue(getStringValue("lastchallengeid")) + 1)) | |
124 | 126 | [StringEntry(("challenge-" + challengeid), makeString(["awaiting", callerAdress, side, toString(pmt.amount)], separ)), StringEntry("lastchallengeid", challengeid)] | |
125 | 127 | } | |
126 | 128 | } | |
127 | 129 | else throw("invalid side") | |
128 | 130 | ||
129 | 131 | ||
130 | 132 | ||
131 | 133 | @Callable(i) | |
132 | 134 | func unsetchallenge (challendgeid) = { | |
133 | 135 | let callerAdress = toBase58String(i.caller.bytes) | |
134 | 136 | func getchallenge (challendgeid) = match getString(("challenge-" + challendgeid)) { | |
135 | 137 | case a: String => | |
136 | 138 | getStringValue(("challenge-" + challendgeid)) | |
137 | 139 | case _ => | |
138 | 140 | "" | |
139 | 141 | } | |
140 | 142 | ||
141 | 143 | let challenge = split(getchallenge(challendgeid), separ) | |
142 | 144 | if ((size(challenge) > 0)) | |
143 | 145 | then if ((challenge[0] == "awaiting")) | |
144 | 146 | then [StringEntry(("challenge-" + challendgeid), makeString(["unset", challenge[1], challenge[2], challenge[3]], separ))] | |
145 | 147 | else throw("challenge not exists") | |
146 | 148 | else throw("challenge not exists") | |
147 | 149 | } | |
148 | 150 | ||
149 | 151 |
github/deemru/w8io/169f3d6 53.34 ms ◑