tx · 5uLGfSw1hpNrPzcAmFhwN9DgJEwxqmQr5kCLRGHMrtsB 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.01000000 Waves 2023.01.10 16:26 [2398899] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "5uLGfSw1hpNrPzcAmFhwN9DgJEwxqmQr5kCLRGHMrtsB", "fee": 1000000, "feeAssetId": null, "timestamp": 1673357267666, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "2zPJjkfh8jrVZW59pUEeE3kVexZFdsHVHB4tr22kSAxDPebj3mcCB1L7u45wN4B143Y1gH75GpYoVY2PFeeBztNu" ], "script": "base64:BgIVCAISCQoHCAgBCAgIARIECgIBARIAGgAJc2VwYXJhdG9yAgFfAAdrR29hbFAxAgZnb2FsUDEAB2tHb2FsUDICBmdvYWxQMgALa0RlZmxlY3Rpb24CCmRlZmxlY3Rpb24ACGtWZXJ0ZXgxAgd2ZXJ0ZXgxAAhrVmVydGV4MgIHdmVydGV4MgAIa1ZlcnRleDMCB3ZlcnRleDMAB2tNYXhCZXQCBm1heEJldAEJcmFuZG9taXplAgVieXRlcwVyYW5nZQQEaGFzaAkA9wMBBQVieXRlcwQFaW5kZXgJALEJAQUEaGFzaAkAagIFBWluZGV4BQVyYW5nZQEIZ2V0UG9pbnQBBWJ5dGVzBAF4CQEJcmFuZG9taXplAgkAyQECBQVieXRlcwkAaQIJAMgBAQUFYnl0ZXMAAgBkBAF5CQEJcmFuZG9taXplAgkAzAECBQVieXRlcwkAaQIJAMgBAQUFYnl0ZXMAAgBkCQCUCgIFAXgFAXkBEWdldEdvYWxMaW5lUG9pbnRzAAQCcDEJALUJAgkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUHa0dvYWxQMQUJc2V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AgCCAUCcDECXzIFA25pbAkAzAgCCQCRAwIIBQFpCHBheW1lbnRzAAAFA25pbAMJAAACBQNyZXMFA3JlcwUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAHyEf6w=", "height": 2398899, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BaKhAD5RipGUyouCee65jYzkxiULD75dML129Q86xZzk Next: DYFuVVcPjdoGKxuJm7q9scAnevLJVBChBQhqdgF9NwAT Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | 6 | let kGoalP1 = "goalP1" | |
7 | 7 | ||
8 | 8 | let kGoalP2 = "goalP2" | |
9 | 9 | ||
10 | 10 | let kDeflection = "deflection" | |
11 | 11 | ||
12 | 12 | let kVertex1 = "vertex1" | |
13 | 13 | ||
14 | 14 | let kVertex2 = "vertex2" | |
15 | 15 | ||
16 | 16 | let kVertex3 = "vertex3" | |
17 | 17 | ||
18 | 18 | let kMaxBet = "maxBet" | |
19 | 19 | ||
20 | 20 | func randomize (bytes,range) = { | |
21 | 21 | let hash = sha256(bytes) | |
22 | 22 | let index = toInt(hash) | |
23 | 23 | (index % range) | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func getPoint (bytes) = { | |
28 | 28 | let x = randomize(take(bytes, (size(bytes) / 2)), 100) | |
29 | 29 | let y = randomize(takeRight(bytes, (size(bytes) / 2)), 100) | |
30 | 30 | $Tuple2(x, y) | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getGoalLinePoints () = { | |
35 | 35 | let p1 = split(getStringValue(this, kGoalP1), separator) | |
36 | 36 | let p2 = split(getStringValue(this, kGoalP2), separator) | |
37 | 37 | $Tuple2($Tuple2(parseIntValue(p1[0]), parseIntValue(p1[1])), $Tuple2(parseIntValue(p2[0]), parseIntValue(p2[1]))) | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getDeflection () = getIntegerValue(this, kDeflection) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func getMaxBet () = getIntegerValue(this, kMaxBet) | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func getPolygonPoints () = { | |
48 | 48 | let p1 = split(getStringValue(this, kVertex1), separator) | |
49 | 49 | let p2 = split(getStringValue(this, kVertex2), separator) | |
50 | 50 | let p3 = split(getStringValue(this, kVertex3), separator) | |
51 | 51 | $Tuple3($Tuple2(parseIntValue(p1[0]), parseIntValue(p1[1])), $Tuple2(parseIntValue(p2[0]), parseIntValue(p2[1])), $Tuple2(parseIntValue(p3[0]), parseIntValue(p3[1]))) | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getLine (p1,p2) = { | |
56 | 56 | let a = (p2._2 - p1._2) | |
57 | 57 | let b = (p1._1 - p2._1) | |
58 | 58 | let c = ((p1._2 * (p2._1 + p1._1)) - (p1._1 * (p1._2 + p2._2))) | |
59 | 59 | $Tuple3(a, b, c) | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getOrthoLine (p1,nVec) = { | |
64 | 64 | let a = nVec._2 | |
65 | 65 | let b = -(nVec._1) | |
66 | 66 | let c = ((nVec._1 * p1._2) - (nVec._2 * p1._1)) | |
67 | 67 | $Tuple3(a, b, c) | |
68 | 68 | } | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func getVec (start,end) = { | |
72 | 72 | let x = (end._1 - start._1) | |
73 | 73 | let y = (end._2 - start._2) | |
74 | 74 | $Tuple2(x, y) | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func mulVectors (vA,vB) = ((vA._1 * vB._2) - (vA._2 * vB._1)) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func getLineLength (p1,p2) = { | |
82 | 82 | let a = pow((p2._1 - p1._1), 0, 2, 0, 0, DOWN) | |
83 | 83 | let b = pow((p2._2 - p1._2), 0, 2, 0, 0, DOWN) | |
84 | 84 | sqrt((a + b), 0, 0, DOWN) | |
85 | 85 | } | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func calcCrosses (accum,nextValue) = { | |
89 | 89 | let vp1p2 = getVec(nextValue[0]._1, nextValue[0]._2) | |
90 | 90 | let vp1p3 = getVec(nextValue[0]._1, nextValue[1]._1) | |
91 | 91 | let vp1p4 = getVec(nextValue[0]._1, nextValue[1]._2) | |
92 | 92 | let vp3p4 = getVec(nextValue[1]._1, nextValue[1]._2) | |
93 | 93 | let vp3p1 = getVec(nextValue[1]._1, nextValue[0]._1) | |
94 | 94 | let vp3p2 = getVec(nextValue[1]._1, nextValue[0]._2) | |
95 | 95 | let v1 = mulVectors(vp3p4, vp3p1) | |
96 | 96 | let v2 = mulVectors(vp3p4, vp3p2) | |
97 | 97 | let v3 = mulVectors(vp1p2, vp1p3) | |
98 | 98 | let v4 = mulVectors(vp1p2, vp1p4) | |
99 | 99 | if (if ((0 > (v1 * v2))) | |
100 | 100 | then (0 > (v3 * v4)) | |
101 | 101 | else false) | |
102 | 102 | then (accum + 1) | |
103 | 103 | else accum | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | func isInside (p1,segment1,segment2,segment3) = { | |
108 | 108 | let segmentRay = $Tuple2(p1, $Tuple2(p1._1, 0)) | |
109 | 109 | let arr = [[segmentRay, segment1], [segmentRay, segment2], [segmentRay, segment3]] | |
110 | 110 | let count = { | |
111 | 111 | let $l = arr | |
112 | 112 | let $s = size($l) | |
113 | 113 | let $acc0 = 0 | |
114 | 114 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
115 | 115 | then $a | |
116 | 116 | else calcCrosses($a, $l[$i]) | |
117 | 117 | ||
118 | 118 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
119 | 119 | then $a | |
120 | 120 | else throw("List size exceeds 3") | |
121 | 121 | ||
122 | 122 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
123 | 123 | } | |
124 | 124 | ((count % 2) == 1) | |
125 | 125 | } | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | func isPointInLine (p1,line) = ((((p1._1 * line._1) + (p1._2 * line._2)) + line._3) == 0) | |
129 | 129 | ||
130 | 130 | ||
131 | 131 | func isPointInDeflection (p1,line) = { | |
132 | 132 | let $t059546056 = line | |
133 | 133 | let a1 = $t059546056._1 | |
134 | 134 | let b1 = $t059546056._2 | |
135 | 135 | let c1 = $t059546056._3 | |
136 | 136 | let $t060596194 = getOrthoLine(p1, $Tuple2(a1, b1)) | |
137 | 137 | let aNorm = $t060596194._1 | |
138 | 138 | let bNorm = $t060596194._2 | |
139 | 139 | let cNorm = $t060596194._3 | |
140 | 140 | let d = mulVectors($Tuple2(a1, b1), $Tuple2(aNorm, bNorm)) | |
141 | 141 | let dx = mulVectors($Tuple2(-(c1), b1), $Tuple2(-(cNorm), bNorm)) | |
142 | 142 | let dy = mulVectors($Tuple2(a1, -(c1)), $Tuple2(aNorm, -(cNorm))) | |
143 | 143 | let xRes = fraction(1, dx, d) | |
144 | 144 | let yRes = fraction(1, dy, d) | |
145 | 145 | let lineLen = getLineLength(p1, $Tuple2(xRes, yRes)) | |
146 | 146 | (getDeflection() >= lineLen) | |
147 | 147 | } | |
148 | 148 | ||
149 | 149 | ||
150 | 150 | func isPointInPolygon (p1,vertex1,vertex2,vertex3) = { | |
151 | 151 | let segment1 = $Tuple2(vertex1, vertex2) | |
152 | 152 | let segment2 = $Tuple2(vertex2, vertex3) | |
153 | 153 | let segment3 = $Tuple2(vertex3, vertex1) | |
154 | 154 | if (if (if ((p1 == vertex1)) | |
155 | 155 | then true | |
156 | 156 | else (p1 == vertex2)) | |
157 | 157 | then true | |
158 | 158 | else (p1 == vertex3)) | |
159 | 159 | then true | |
160 | 160 | else isInside(p1, segment1, segment2, segment3) | |
161 | 161 | } | |
162 | 162 | ||
163 | 163 | ||
164 | 164 | func calcRewardMultiplier (inLine,inPolygon,inDeflection) = if (if (inLine) | |
165 | 165 | then inPolygon | |
166 | 166 | else false) | |
167 | 167 | then 10 | |
168 | 168 | else if (if (inDeflection) | |
169 | 169 | then inPolygon | |
170 | 170 | else false) | |
171 | 171 | then 8 | |
172 | 172 | else if (inLine) | |
173 | 173 | then 6 | |
174 | 174 | else if (inPolygon) | |
175 | 175 | then 4 | |
176 | 176 | else if (inDeflection) | |
177 | 177 | then 2 | |
178 | 178 | else 1 | |
179 | 179 | ||
180 | 180 | ||
181 | 181 | func validatePayment (paymentAsset,paymentAmount) = if (if ((paymentAsset == unit)) | |
182 | 182 | then (getMaxBet() >= paymentAmount) | |
183 | 183 | else false) | |
184 | 184 | then unit | |
185 | 185 | else throw("Incorrect payment") | |
186 | 186 | ||
187 | 187 | ||
188 | 188 | @Callable(i) | |
189 | 189 | func setLotteryParams (goalP1,goalP2,deflection,vertex1,vertex2,vertex3,maxBet) = [StringEntry(kGoalP1, goalP1), StringEntry(kGoalP2, goalP2), IntegerEntry(kDeflection, deflection), StringEntry(kVertex1, vertex1), StringEntry(kVertex2, vertex2), StringEntry(kVertex3, vertex3), IntegerEntry(kMaxBet, maxBet)] | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
193 | 193 | @Callable(i) | |
194 | 194 | func tryToWin (p1x,p1y) = { | |
195 | 195 | let $t089109028 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
196 | 196 | let paymentAsset = $t089109028._1 | |
197 | 197 | let paymentAmount = $t089109028._2 | |
198 | 198 | valueOrElse(validatePayment(paymentAsset, paymentAmount), { | |
199 | 199 | let p1 = $Tuple2(p1x, p1y) | |
200 | 200 | let $t092589379 = getGoalLinePoints() | |
201 | 201 | let p2 = $t092589379._1 | |
202 | 202 | let p3 = $t092589379._2 | |
203 | 203 | let $t093849483 = getPolygonPoints() | |
204 | 204 | let p4 = $t093849483._1 | |
205 | 205 | let p5 = $t093849483._2 | |
206 | 206 | let p6 = $t093849483._3 | |
207 | 207 | let $t094889580 = getLine(p2, p3) | |
208 | 208 | let a1 = $t094889580._1 | |
209 | 209 | let b1 = $t094889580._2 | |
210 | 210 | let c1 = $t094889580._3 | |
211 | 211 | let inLine = isPointInLine(p1, $Tuple3(a1, b1, c1)) | |
212 | 212 | let inPolygon = isPointInPolygon(p1, p4, p5, p6) | |
213 | 213 | let inDeflection = isPointInDeflection(p1, $Tuple3(a1, b1, c1)) | |
214 | 214 | if (if (if (inLine) | |
215 | 215 | then true | |
216 | 216 | else inDeflection) | |
217 | 217 | then true | |
218 | 218 | else inPolygon) | |
219 | 219 | then { | |
220 | 220 | let multiplier = calcRewardMultiplier(inLine, inPolygon, inDeflection) | |
221 | 221 | let reward = (paymentAmount * multiplier) | |
222 | 222 | [IntegerEntry("multiplier", multiplier), ScriptTransfer(i.originCaller, reward, unit)] | |
223 | 223 | } | |
224 | 224 | else nil | |
225 | 225 | }) | |
226 | 226 | } | |
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | 230 | @Callable(i) | |
231 | 231 | func startGame () = { | |
232 | 232 | let p1 = getPoint(i.transactionId) | |
233 | 233 | let res = invoke(this, "tryToWin", [p1._1, p1._2], [i.payments[0]]) | |
234 | 234 | if ((res == res)) | |
235 | 235 | then nil | |
236 | 236 | else throw("Strict value is not equal to itself.") | |
237 | 237 | } | |
238 | 238 | ||
239 | 239 |
github/deemru/w8io/169f3d6 75.85 ms ◑