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