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