tx · DBwuZ3GPJMyvVncAu5sSmCcHrhP98xjbcs4GYniyFxHT 3N9UZtJRvvoNgHCjQsWvDUtxiym7KFc7r6f: -0.01400000 Waves 2018.09.29 18:05 [353453] smart account 3N9UZtJRvvoNgHCjQsWvDUtxiym7KFc7r6f > SELF 0.00000000 Waves
{ "type": 13, "id": "DBwuZ3GPJMyvVncAu5sSmCcHrhP98xjbcs4GYniyFxHT", "fee": 1400000, "feeAssetId": null, "timestamp": 1538233547109, "version": 1, "sender": "3N9UZtJRvvoNgHCjQsWvDUtxiym7KFc7r6f", "senderPublicKey": "4BRdUi95rN89kRWamqTcb9Dj9pLpAQbjLt17MPxcgGhG", "proofs": [ "2N8SuSvZNDXB7ZyGMGCeAH855VAnt5d8UhUQ1RZPmCFiYEvbK1tQ3mfa3gbWSg7ZuCF5jbaA29ZaY15zbqAN6TKQ" ], "script": "base64:AQQAAAAJcmVkUHViS2V5AQAAACCcvkAYXSO2dto8Bjx/Z65U0bGrFY5cIkLHdfY5mFVSDwQAAAALZ3JlZW5QdWJLZXkBAAAAIPlfPeSXGejVVO8XgpF607z8UJ46ZmmLUq4Rq0R8IFM8BAAAAApibHVlUHViS2V5AQAAACA97ajD767lxQiKGSbQ60FmHM7Nfb7azWSBD/TaFp3/QAQAAAAHcmVkQWRkcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVGfSoosyZxu2GPr01RED4+I9rSQ9LlF8XgQAAAAJZ3JlZW5BZGRyCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUeYFF8qf7pD+lzgJaCmi860XRkyZFP24HBAAAAAhibHVlQWRkcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVEG1BP9MronfM5Ad2fldCE7DdHowHHByOQQAAAAIY29udHJhY3QIBQAAAAJ0eAAAAAZzZW5kZXIEAAAACXJlZFNpZ25lZAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAA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Wx0aURlZmVuZGVycwcJAAAAAAAAAgUAAAAJYXR0YWNrZXJzBQAAAAlkZWZlbmRlcnMHCQAAAAAAAAIFAAAADG5ld0Zyb21Vbml0cwAAAAAAAAAAAAcJAAAAAAAAAgUAAAAKbmV3VG9Vbml0cwkAAGgAAAACCQAAZQAAAAIJAABkAAAAAgUAAAAJZGVmZW5kZXJzAAAAAAAAAAABBQAAAAlhdHRhY2tlcnMFAAAADm11bHRpRGVmZW5kZXJzBwkAAAAAAAACBQAAAAhkYXRhU2l6ZQAAAAAAAAAAAgcEAAAABG1vdmUDAwMDAwMFAAAABGtpbmcJAAAAAAAAAgUAAAAObXVsdGlBdHRhY2tlcnMFAAAADm11bHRpRGVmZW5kZXJzBwkAAAAAAAACBQAAAAxuZXdGcm9tVW5pdHMAAAAAAAAAAAAHCQAAZwAAAAIAAAAAAAAAAAoJAABkAAAAAgUAAAAJYXR0YWNrZXJzBQAAAAlkZWZlbmRlcnMHCQAAAAAAAAIFAAAACm5ld1RvVW5pdHMJAABoAAAAAgkAAGQAAAACBQAAAAlhdHRhY2tlcnMFAAAACWRlZmVuZGVycwUAAAAObXVsdGlBdHRhY2tlcnMHBQAAAAZsb2NrZWQHCQAAAAAAAAIFAAAACGRhdGFTaXplAAAAAAAAAAADBwMDAwMDBQAAAAN3aW4GBQAAAARsb3N0BgUAAAAEZHJhdwYFAAAABG1vdmUFAAAAC3R1cm5BbGxvd2VkBwYJAAAAAAAAAgUAAAAIZGF0YVNpemUAAAAAAAAAAAwDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAA250eAUAAAAHJG1hdGNoMAYGYzEs+Q==", "chainId": 84, "height": 353453, "spentComplexity": 0 } View: original | compacted Prev: FFeuTxhcLforNgPx4hwX9MJQ1VHLeJ1odLagV1273QS2 Next: 5qLxbdzW9MmvR7qB6wWUK8DrCS3pLsaHJuPjcEZuHnaX Diff:
Old | New | Differences | |
---|---|---|---|
15 | 15 | let dataSize = size(ttx.data) | |
16 | 16 | let fromKey = ttx.data[0].key | |
17 | 17 | let toKey = ttx.data[1].key | |
18 | + | let turnToKey = ttx.data[2].key | |
18 | 19 | let newFromUnits = ttx.data[0].value | |
19 | 20 | let newToUnits = ttx.data[1].value | |
21 | + | let turnToValue = ttx.data[2].value | |
20 | 22 | let turnCorrect = if (if (if (if (if (if (if (if (if (if (if (if ((fromKey == "country1")) | |
21 | 23 | then (toKey == "country2") | |
22 | 24 | else false) | |
88 | 90 | else if ((fromKey == "country12")) | |
89 | 91 | then (toKey == "country11") | |
90 | 92 | else false | |
93 | + | let turnFromKey = ("turn_" + fromKey) | |
94 | + | let turnFromValue = extract(getInteger(contract, turnFromKey)) | |
95 | + | let turnAllowed = (turnFromValue == 0) | |
96 | + | let locked = if ((("turn_" + toKey) == turnToKey)) | |
97 | + | then (turnToValue == 1) | |
98 | + | else false | |
91 | 99 | let fromUnits = extract(getInteger(contract, fromKey)) | |
92 | 100 | let toUnits = extract(getInteger(contract, toKey)) | |
93 | 101 | let redAttackers = (fromUnits % 100) | |
95 | 103 | let blueAttackers = (((fromUnits - (greenAttackers * 100)) - redAttackers) / 10000) | |
96 | 104 | let redDefenders = (toUnits % 100) | |
97 | 105 | let greenDefenders = (((toUnits - redDefenders) % 10000) / 100) | |
98 | - | let blueDefenders = (((toUnits - (greenDefenders * 100)) - redDefenders) / 10000) | |
106 | + | let blueDefenders = ((((toUnits - (greenDefenders * 100)) - redDefenders) % 1000000) / 10000) | |
107 | + | let whiteDefenders = ((((toUnits - (blueDefenders * 10000)) - (greenDefenders * 100)) - redDefenders) / 1000000) | |
99 | 108 | let attackers = ((redAttackers + greenAttackers) + blueAttackers) | |
100 | 109 | let defenders = ((redDefenders + greenDefenders) + blueDefenders) | |
101 | 110 | let king = if (if (if ((redAttackers > 0)) | |
111 | 120 | else false | |
112 | 121 | let multiAttackers = (fromUnits / attackers) | |
113 | 122 | let multiDefenders = (toUnits / defenders) | |
114 | - | let win = if (if (if (if (king) | |
123 | + | let win = if (if (if (if (if (if (king) | |
115 | 124 | then (multiAttackers != multiDefenders) | |
116 | 125 | else false) | |
117 | 126 | then (attackers > defenders) | |
119 | 128 | then (newFromUnits == 0) | |
120 | 129 | else false) | |
121 | 130 | then (newToUnits == ((attackers - defenders) * multiAttackers)) | |
131 | + | else false) | |
132 | + | then locked | |
133 | + | else false) | |
134 | + | then (dataSize == 3) | |
122 | 135 | else false | |
123 | - | let lost = if (if (if (if (king) | |
136 | + | let lost = if (if (if (if (if (king) | |
124 | 137 | then (multiAttackers != multiDefenders) | |
125 | 138 | else false) | |
126 | 139 | then (defenders > attackers) | |
128 | 141 | then (newFromUnits == 0) | |
129 | 142 | else false) | |
130 | 143 | then (newToUnits == ((defenders - attackers) * multiDefenders)) | |
144 | + | else false) | |
145 | + | then (dataSize == 2) | |
131 | 146 | else false | |
132 | - | let draw = if (if (if (if (king) | |
147 | + | let draw = if (if (if (if (if (king) | |
133 | 148 | then (multiAttackers != multiDefenders) | |
134 | 149 | else false) | |
135 | 150 | then (attackers == defenders) | |
137 | 152 | then (newFromUnits == 0) | |
138 | 153 | else false) | |
139 | 154 | then (newToUnits == (((defenders + 1) - attackers) * multiDefenders)) | |
155 | + | else false) | |
156 | + | then (dataSize == 2) | |
140 | 157 | else false | |
141 | - | let move = if (if (if (if (king) | |
158 | + | let move = if (if (if (if (if (if (king) | |
142 | 159 | then (multiAttackers == multiDefenders) | |
143 | 160 | else false) | |
144 | 161 | then (newFromUnits == 0) | |
146 | 163 | then (10 >= (attackers + defenders)) | |
147 | 164 | else false) | |
148 | 165 | then (newToUnits == ((attackers + defenders) * multiAttackers)) | |
166 | + | else false) | |
167 | + | then locked | |
168 | + | else false) | |
169 | + | then (dataSize == 3) | |
149 | 170 | else false | |
150 | 171 | if (if (if (if (if (win) | |
151 | 172 | then true | |
154 | 175 | else draw) | |
155 | 176 | then true | |
156 | 177 | else move) | |
157 | - | then | |
178 | + | then turnAllowed | |
158 | 179 | else false) | |
159 | 180 | then true | |
160 | 181 | else (dataSize == 12) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 1 #-} | |
2 | 2 | {-# CONTENT_TYPE EXPRESSION #-} | |
3 | 3 | let redPubKey = base58'BYrrqVpD5uuz7cndnPwuUxuYFUK6Bovu6yfoV8seY6Px' | |
4 | 4 | let greenPubKey = base58'HnSkSntD7ihFgZpLNmHgdVnVmCYxJLC96eNbubTXsWju' | |
5 | 5 | let bluePubKey = base58'5Ak4HQK3cnkwe6XVUXwpCYeSAARwruKyAmsmegePUPvo' | |
6 | 6 | let redAddr = Address(base58'3MyP3hrK8SBvtXtggNWdsry8KuGdrv1sFrV') | |
7 | 7 | let greenAddr = Address(base58'3MzzYQCC8Ks86exHaWV2VpaANbNLPRDunNJ') | |
8 | 8 | let blueAddr = Address(base58'3MuuWYr3DyjEkncbNU1tUeFbyvcyZng9gz4') | |
9 | 9 | let contract = tx.sender | |
10 | 10 | let redSigned = sigVerify(tx.bodyBytes, tx.proofs[0], redPubKey) | |
11 | 11 | let greenSigned = sigVerify(tx.bodyBytes, tx.proofs[0], greenPubKey) | |
12 | 12 | let blueSigned = sigVerify(tx.bodyBytes, tx.proofs[0], bluePubKey) | |
13 | 13 | match tx { | |
14 | 14 | case ttx: DataTransaction => | |
15 | 15 | let dataSize = size(ttx.data) | |
16 | 16 | let fromKey = ttx.data[0].key | |
17 | 17 | let toKey = ttx.data[1].key | |
18 | + | let turnToKey = ttx.data[2].key | |
18 | 19 | let newFromUnits = ttx.data[0].value | |
19 | 20 | let newToUnits = ttx.data[1].value | |
21 | + | let turnToValue = ttx.data[2].value | |
20 | 22 | let turnCorrect = if (if (if (if (if (if (if (if (if (if (if (if ((fromKey == "country1")) | |
21 | 23 | then (toKey == "country2") | |
22 | 24 | else false) | |
23 | 25 | then true | |
24 | 26 | else if ((fromKey == "country2")) | |
25 | 27 | then if ((toKey == "country1")) | |
26 | 28 | then true | |
27 | 29 | else (toKey == "country3") | |
28 | 30 | else false) | |
29 | 31 | then true | |
30 | 32 | else if ((fromKey == "country3")) | |
31 | 33 | then if (if ((toKey == "country2")) | |
32 | 34 | then true | |
33 | 35 | else (toKey == "country4")) | |
34 | 36 | then true | |
35 | 37 | else (toKey == "country5") | |
36 | 38 | else false) | |
37 | 39 | then true | |
38 | 40 | else if ((fromKey == "country4")) | |
39 | 41 | then if ((toKey == "country3")) | |
40 | 42 | then true | |
41 | 43 | else (toKey == "country8") | |
42 | 44 | else false) | |
43 | 45 | then true | |
44 | 46 | else if ((fromKey == "country5")) | |
45 | 47 | then if ((toKey == "country3")) | |
46 | 48 | then true | |
47 | 49 | else (toKey == "country10") | |
48 | 50 | else false) | |
49 | 51 | then true | |
50 | 52 | else if ((fromKey == "country6")) | |
51 | 53 | then (toKey == "country7") | |
52 | 54 | else false) | |
53 | 55 | then true | |
54 | 56 | else if ((fromKey == "country7")) | |
55 | 57 | then if ((toKey == "country6")) | |
56 | 58 | then true | |
57 | 59 | else (toKey == "country8") | |
58 | 60 | else false) | |
59 | 61 | then true | |
60 | 62 | else if ((fromKey == "country8")) | |
61 | 63 | then if (if ((toKey == "country4")) | |
62 | 64 | then true | |
63 | 65 | else (toKey == "country7")) | |
64 | 66 | then true | |
65 | 67 | else (toKey == "country9") | |
66 | 68 | else false) | |
67 | 69 | then true | |
68 | 70 | else if ((fromKey == "country9")) | |
69 | 71 | then if ((toKey == "country8")) | |
70 | 72 | then true | |
71 | 73 | else (toKey == "country10") | |
72 | 74 | else false) | |
73 | 75 | then true | |
74 | 76 | else if ((fromKey == "country10")) | |
75 | 77 | then if (if ((toKey == "country5")) | |
76 | 78 | then true | |
77 | 79 | else (toKey == "country10")) | |
78 | 80 | then true | |
79 | 81 | else (toKey == "country11") | |
80 | 82 | else false) | |
81 | 83 | then true | |
82 | 84 | else if ((fromKey == "country11")) | |
83 | 85 | then if ((toKey == "country10")) | |
84 | 86 | then true | |
85 | 87 | else (toKey == "country12") | |
86 | 88 | else false) | |
87 | 89 | then true | |
88 | 90 | else if ((fromKey == "country12")) | |
89 | 91 | then (toKey == "country11") | |
90 | 92 | else false | |
93 | + | let turnFromKey = ("turn_" + fromKey) | |
94 | + | let turnFromValue = extract(getInteger(contract, turnFromKey)) | |
95 | + | let turnAllowed = (turnFromValue == 0) | |
96 | + | let locked = if ((("turn_" + toKey) == turnToKey)) | |
97 | + | then (turnToValue == 1) | |
98 | + | else false | |
91 | 99 | let fromUnits = extract(getInteger(contract, fromKey)) | |
92 | 100 | let toUnits = extract(getInteger(contract, toKey)) | |
93 | 101 | let redAttackers = (fromUnits % 100) | |
94 | 102 | let greenAttackers = (((fromUnits - redAttackers) % 10000) / 100) | |
95 | 103 | let blueAttackers = (((fromUnits - (greenAttackers * 100)) - redAttackers) / 10000) | |
96 | 104 | let redDefenders = (toUnits % 100) | |
97 | 105 | let greenDefenders = (((toUnits - redDefenders) % 10000) / 100) | |
98 | - | let blueDefenders = (((toUnits - (greenDefenders * 100)) - redDefenders) / 10000) | |
106 | + | let blueDefenders = ((((toUnits - (greenDefenders * 100)) - redDefenders) % 1000000) / 10000) | |
107 | + | let whiteDefenders = ((((toUnits - (blueDefenders * 10000)) - (greenDefenders * 100)) - redDefenders) / 1000000) | |
99 | 108 | let attackers = ((redAttackers + greenAttackers) + blueAttackers) | |
100 | 109 | let defenders = ((redDefenders + greenDefenders) + blueDefenders) | |
101 | 110 | let king = if (if (if ((redAttackers > 0)) | |
102 | 111 | then redSigned | |
103 | 112 | else false) | |
104 | 113 | then true | |
105 | 114 | else if ((greenAttackers > 0)) | |
106 | 115 | then greenSigned | |
107 | 116 | else false) | |
108 | 117 | then true | |
109 | 118 | else if ((blueAttackers > 0)) | |
110 | 119 | then blueSigned | |
111 | 120 | else false | |
112 | 121 | let multiAttackers = (fromUnits / attackers) | |
113 | 122 | let multiDefenders = (toUnits / defenders) | |
114 | - | let win = if (if (if (if (king) | |
123 | + | let win = if (if (if (if (if (if (king) | |
115 | 124 | then (multiAttackers != multiDefenders) | |
116 | 125 | else false) | |
117 | 126 | then (attackers > defenders) | |
118 | 127 | else false) | |
119 | 128 | then (newFromUnits == 0) | |
120 | 129 | else false) | |
121 | 130 | then (newToUnits == ((attackers - defenders) * multiAttackers)) | |
131 | + | else false) | |
132 | + | then locked | |
133 | + | else false) | |
134 | + | then (dataSize == 3) | |
122 | 135 | else false | |
123 | - | let lost = if (if (if (if (king) | |
136 | + | let lost = if (if (if (if (if (king) | |
124 | 137 | then (multiAttackers != multiDefenders) | |
125 | 138 | else false) | |
126 | 139 | then (defenders > attackers) | |
127 | 140 | else false) | |
128 | 141 | then (newFromUnits == 0) | |
129 | 142 | else false) | |
130 | 143 | then (newToUnits == ((defenders - attackers) * multiDefenders)) | |
144 | + | else false) | |
145 | + | then (dataSize == 2) | |
131 | 146 | else false | |
132 | - | let draw = if (if (if (if (king) | |
147 | + | let draw = if (if (if (if (if (king) | |
133 | 148 | then (multiAttackers != multiDefenders) | |
134 | 149 | else false) | |
135 | 150 | then (attackers == defenders) | |
136 | 151 | else false) | |
137 | 152 | then (newFromUnits == 0) | |
138 | 153 | else false) | |
139 | 154 | then (newToUnits == (((defenders + 1) - attackers) * multiDefenders)) | |
155 | + | else false) | |
156 | + | then (dataSize == 2) | |
140 | 157 | else false | |
141 | - | let move = if (if (if (if (king) | |
158 | + | let move = if (if (if (if (if (if (king) | |
142 | 159 | then (multiAttackers == multiDefenders) | |
143 | 160 | else false) | |
144 | 161 | then (newFromUnits == 0) | |
145 | 162 | else false) | |
146 | 163 | then (10 >= (attackers + defenders)) | |
147 | 164 | else false) | |
148 | 165 | then (newToUnits == ((attackers + defenders) * multiAttackers)) | |
166 | + | else false) | |
167 | + | then locked | |
168 | + | else false) | |
169 | + | then (dataSize == 3) | |
149 | 170 | else false | |
150 | 171 | if (if (if (if (if (win) | |
151 | 172 | then true | |
152 | 173 | else lost) | |
153 | 174 | then true | |
154 | 175 | else draw) | |
155 | 176 | then true | |
156 | 177 | else move) | |
157 | - | then | |
178 | + | then turnAllowed | |
158 | 179 | else false) | |
159 | 180 | then true | |
160 | 181 | else (dataSize == 12) | |
161 | 182 | case ntx: TransferTransaction => | |
162 | 183 | true | |
163 | 184 | case _ => | |
164 | 185 | true | |
165 | 186 | } |
github/deemru/w8io/026f985 31.03 ms ◑