tx · JCAiMj8rGMrTfSuT3YTSsNhpWeBMudoTzZzdCGTscLRG 3N8NLvRGsbGhgoXy7EdigPbAz6N2i7ygBcZ: -0.01700000 Waves 2023.12.14 16:22 [2886444] smart account 3N8NLvRGsbGhgoXy7EdigPbAz6N2i7ygBcZ > SELF 0.00000000 Waves
{ "type": 13, "id": "JCAiMj8rGMrTfSuT3YTSsNhpWeBMudoTzZzdCGTscLRG", "fee": 1700000, "feeAssetId": null, "timestamp": 1702560203414, "version": 2, "chainId": 84, "sender": "3N8NLvRGsbGhgoXy7EdigPbAz6N2i7ygBcZ", "senderPublicKey": "CQoe8BRHR78TuPQLcK3Ykv39w9CeNLhjKdj6TNbJ5FrM", "proofs": [ "491cYvY3A1QHvSkUkhtUttVmCCgS8Mbckq95ygx9Ft7mAVnLTzjMgJTuuPfLhN3ZeXd1de4caV8fHgMXtLT1uZqC" ], "script": "base64:BgIaCAISBgoECAgBCBIDCgEEEgMKAQgSBAoCCAJIAANTRVACAl9fAAdXQVZFU0lEAQQTq9kzAAZXQVZFU0QAgMLXLwAJR0FNRV9OQU1FAglYbWFzIFRyZWUADFJBTkRPTV9SQU5HRQAFAAhOVU1fQkVUUwABAA9NQVhfREVDT1JBVElPTlMADwEMZ2V0U3RyT3JGYWlsAgdhZGRyZXNzA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFB2FkZHJlc3MFA2tleQkAuQkCCQDMCAICCm1hbmRhdG9yeSAJAMwIAgkApQgBBQdhZGRyZXNzCQDMCAICAS4JAMwIAgUDa2V5CQDMCAICDyBpcyBub3QgZGVmaW5lZAUDbmlsAgABDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZm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", "spentComplexity": 0 } View: original | compacted Prev: 21aDeFnoHRnS7syp874NGDYWeiYoVyQBJYSNc56u944U Next: 8xh42kktAgjFWFNQXm2y4Nm3zpvCwAJry7zUqhZj7RnX Diff:
Old | New | Differences | |
---|---|---|---|
12 | 12 | let RANDOM_RANGE = 5 | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | + | ||
16 | + | let MAX_DECORATIONS = 15 | |
15 | 17 | ||
16 | 18 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
17 | 19 | ||
227 | 229 | } | |
228 | 230 | } | |
229 | 231 | ||
230 | - | let $ | |
232 | + | let $t079968063 = { | |
231 | 233 | let $l = HOR_LINES | |
232 | 234 | let $s = size($l) | |
233 | 235 | let $acc0 = $Tuple3(nil, 0, 0) | |
241 | 243 | ||
242 | 244 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
243 | 245 | } | |
244 | - | let areas = $ | |
245 | - | let totalArea = $ | |
246 | + | let areas = $t079968063._1 | |
247 | + | let totalArea = $t079968063._2 | |
246 | 248 | let rand = (toInt(sha256((rsaSign + toBytes(gameId)))) % totalArea) | |
247 | 249 | func check (acc,area) = { | |
248 | 250 | let i = acc._1 | |
286 | 288 | } | |
287 | 289 | ||
288 | 290 | ||
291 | + | func getDecorationIndex (gameId,rsaSign) = (toInt(sha256((toBytes(gameId) + rsaSign))) % MAX_DECORATIONS) | |
292 | + | ||
293 | + | ||
289 | 294 | func generateRandChoice (gameId,rsaSign) = { | |
290 | 295 | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
291 | 296 | if (!(rsaSigValid)) | |
320 | 325 | } | |
321 | 326 | ||
322 | 327 | ||
323 | - | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
328 | + | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord,prizeIndex) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
324 | 329 | then "" | |
325 | - | else randOrEmpty, xCoord, yCoord], "_") | |
330 | + | else randOrEmpty, xCoord, yCoord, prizeIndex], "_") | |
326 | 331 | ||
327 | 332 | ||
328 | - | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty, toString(xCoord), toString(yCoord)) | |
333 | + | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord,prizeIndex) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty, toString(xCoord), toString(yCoord), toString(prizeIndex)) | |
329 | 334 | ||
330 | 335 | ||
331 | - | func finishGameData (origGameData,gameStatus,rand,winByTimeout,xCoord,yCoord) = { | |
332 | - | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand, toString(xCoord), toString(yCoord)) | |
336 | + | func finishGameData (origGameData,gameStatus,rand,winByTimeout,xCoord,yCoord,prizeIndex) = { | |
337 | + | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand, toString(xCoord), toString(yCoord), toString(prizeIndex)) | |
333 | 338 | if (winByTimeout) | |
334 | 339 | then (finishGameData + "_TIMEOUT") | |
335 | 340 | else finishGameData | |
403 | 408 | let commission = feePmt.amount | |
404 | 409 | let winAmount = validateBetAndGetWinAmount(betPmt.amount, internalAssetIdx, playerChoice) | |
405 | 410 | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
406 | - | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "", -1, -1) | |
411 | + | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "", -1, -1, -1) | |
407 | 412 | [IntegerEntry(keyReservationByAssetIdx(internalAssetIdx), increaseReserveAmount(winAmount, internalAssetIdx)), incrementInt(GAMESCOUNTERKEY), StringEntry(gameId, gameData), ScriptTransfer(SERVER, commission, feePmt.assetId)] | |
408 | 413 | } | |
409 | 414 | } | |
437 | 442 | let coords = if (playerWin) | |
438 | 443 | then [-(M4), -(M4)] | |
439 | 444 | else getCoords(gameId, rsaSign) | |
440 | - | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout, (coords[0] / M4), (coords[1] / M4)) | |
445 | + | let prizeIndex = if (playerWin) | |
446 | + | then -1 | |
447 | + | else getDecorationIndex(gameId, rsaSign) | |
448 | + | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout, (coords[0] / M4), (coords[1] / M4), prizeIndex) | |
441 | 449 | ([StringEntry(gameId, newGameData), decreaseReservedAmount(gameId, assetIdx, winAmount)] ++ (if (playerWin) | |
442 | 450 | then [ScriptTransfer(playerAddress, winAmount, assetIdFromStr(ASSETS[assetIdx]))] | |
443 | 451 | else nil)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let WAVESID = base58'WAVES' | |
7 | 7 | ||
8 | 8 | let WAVESD = 100000000 | |
9 | 9 | ||
10 | 10 | let GAME_NAME = "Xmas Tree" | |
11 | 11 | ||
12 | 12 | let RANDOM_RANGE = 5 | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | + | ||
16 | + | let MAX_DECORATIONS = 15 | |
15 | 17 | ||
16 | 18 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
17 | 19 | ||
18 | 20 | ||
19 | 21 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
20 | 22 | ||
21 | 23 | ||
22 | 24 | func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
23 | 25 | ||
24 | 26 | ||
25 | 27 | let allowedAssetsKey = "%s%s__cfg__allowedAssets" | |
26 | 28 | ||
27 | 29 | let assetsDecimalsKey = "%s%s__cfg__assetsDecimals" | |
28 | 30 | ||
29 | 31 | let betDividersKey = "%s%s__cfg__assetsBetDividers" | |
30 | 32 | ||
31 | 33 | let RSAPUBLIC64KEY = "%s%s__cfg__rsaPublic64" | |
32 | 34 | ||
33 | 35 | let SERVERADDRESSKEY = "%s%s__cfg__benzAddress" | |
34 | 36 | ||
35 | 37 | let RANDTIMEFRAMEKEY = "%s%s__cfg__withdrawTimeFrame" | |
36 | 38 | ||
37 | 39 | let GAMESCOUNTERKEY = "%s%s__runtime__gameNum" | |
38 | 40 | ||
39 | 41 | let blockedKey = "%s%s__runtime__contractIsBlocked" | |
40 | 42 | ||
41 | 43 | let reservedAmountsKey = "%s%s__runtime__reservedAmounts" | |
42 | 44 | ||
43 | 45 | func getIntArray (key) = { | |
44 | 46 | let a = getStrOrFail(this, key) | |
45 | 47 | func filler (acc,el) = (acc :+ parseIntValue(el)) | |
46 | 48 | ||
47 | 49 | let $l = split(a, SEP) | |
48 | 50 | let $s = size($l) | |
49 | 51 | let $acc0 = nil | |
50 | 52 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
51 | 53 | then $a | |
52 | 54 | else filler($a, $l[$i]) | |
53 | 55 | ||
54 | 56 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
55 | 57 | then $a | |
56 | 58 | else throw("List size exceeds 10") | |
57 | 59 | ||
58 | 60 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
59 | 61 | } | |
60 | 62 | ||
61 | 63 | ||
62 | 64 | let ASSETS = split(getStrOrFail(this, allowedAssetsKey), SEP) | |
63 | 65 | ||
64 | 66 | let DECIMALS = getIntArray(assetsDecimalsKey) | |
65 | 67 | ||
66 | 68 | let BETDIVIDERS = getIntArray(betDividersKey) | |
67 | 69 | ||
68 | 70 | func keyReservationByAssetStr (assetStr) = ("$RESERVED_AMOUNT_" + assetStr) | |
69 | 71 | ||
70 | 72 | ||
71 | 73 | func keyReservationByAssetIdx (assetIdx) = keyReservationByAssetStr(ASSETS[assetIdx]) | |
72 | 74 | ||
73 | 75 | ||
74 | 76 | let MINFEEWAVES = ((5 * WAVESD) / 1000) | |
75 | 77 | ||
76 | 78 | let idxAssets = 0 | |
77 | 79 | ||
78 | 80 | let idxDecimals = 1 | |
79 | 81 | ||
80 | 82 | let idxDividers = 2 | |
81 | 83 | ||
82 | 84 | let BET1 = 1 | |
83 | 85 | ||
84 | 86 | let BET2 = 2 | |
85 | 87 | ||
86 | 88 | let BET4 = 4 | |
87 | 89 | ||
88 | 90 | let BET8 = 8 | |
89 | 91 | ||
90 | 92 | let BET14 = 14 | |
91 | 93 | ||
92 | 94 | let RATEMULT = 10000 | |
93 | 95 | ||
94 | 96 | let RATE = 40000 | |
95 | 97 | ||
96 | 98 | let BETS = [BET2] | |
97 | 99 | ||
98 | 100 | let IdxGameState = 0 | |
99 | 101 | ||
100 | 102 | let IdxPlayerChoice = 1 | |
101 | 103 | ||
102 | 104 | let IdxPlayerPubKey58 = 2 | |
103 | 105 | ||
104 | 106 | let IdxStartedHeight = 3 | |
105 | 107 | ||
106 | 108 | let IdxWinAmount = 4 | |
107 | 109 | ||
108 | 110 | let IdxAssetId = 5 | |
109 | 111 | ||
110 | 112 | let STATESUBMITTED = "SUBMITTED" | |
111 | 113 | ||
112 | 114 | let STATEWON = "WON" | |
113 | 115 | ||
114 | 116 | let STATELOST = "LOST" | |
115 | 117 | ||
116 | 118 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " key is not specified in this.state")) | |
117 | 119 | ||
118 | 120 | ||
119 | 121 | let RSAPUBLIC = fromBase64String(getStringOrFail(RSAPUBLIC64KEY)) | |
120 | 122 | ||
121 | 123 | let SERVER = addressFromStringValue(getStringOrFail(SERVERADDRESSKEY)) | |
122 | 124 | ||
123 | 125 | let RANDORACLETIMEFRAME = valueOrElse(getInteger(this, RANDTIMEFRAMEKEY), 7200) | |
124 | 126 | ||
125 | 127 | func getIntOr (key,default) = if (isDefined(getInteger(key))) | |
126 | 128 | then getIntegerValue(key) | |
127 | 129 | else default | |
128 | 130 | ||
129 | 131 | ||
130 | 132 | func setInt (key,value) = IntegerEntry(key, value) | |
131 | 133 | ||
132 | 134 | ||
133 | 135 | func incrementInt (key) = setInt(key, (getIntOr(key, -1) + 1)) | |
134 | 136 | ||
135 | 137 | ||
136 | 138 | func changeInt (key,by) = setInt(key, (getIntOr(key, 0) + by)) | |
137 | 139 | ||
138 | 140 | ||
139 | 141 | func assetIdToStr (assetIdOrUnit) = match assetIdOrUnit { | |
140 | 142 | case b: ByteVector => | |
141 | 143 | toBase58String(b) | |
142 | 144 | case _ => | |
143 | 145 | "WAVES" | |
144 | 146 | } | |
145 | 147 | ||
146 | 148 | ||
147 | 149 | func assetIdFromStr (assetIdStr) = if ((assetIdStr == "WAVES")) | |
148 | 150 | then unit | |
149 | 151 | else fromBase58String(assetIdStr) | |
150 | 152 | ||
151 | 153 | ||
152 | 154 | func getAssetBalance (assetIdOrUnit) = match assetIdOrUnit { | |
153 | 155 | case assetId: ByteVector => | |
154 | 156 | assetBalance(this, assetId) | |
155 | 157 | case _ => | |
156 | 158 | wavesBalance(this).available | |
157 | 159 | } | |
158 | 160 | ||
159 | 161 | ||
160 | 162 | func increaseReserveAmount (winAmount,assetIdx) = { | |
161 | 163 | let assetIdStr = ASSETS[assetIdx] | |
162 | 164 | let newReservedAmount = (getIntOr(keyReservationByAssetIdx(assetIdx), 0) + winAmount) | |
163 | 165 | if ((newReservedAmount > getAssetBalance(assetIdFromStr(assetIdStr)))) | |
164 | 166 | then throw((("Insufficient funds on " + GAME_NAME) + " account. Transaction was rejected for your safety.")) | |
165 | 167 | else newReservedAmount | |
166 | 168 | } | |
167 | 169 | ||
168 | 170 | ||
169 | 171 | func decreaseReservedAmount (gameId,assetIdx,winAmount) = if ((0 > (getIntOr(keyReservationByAssetIdx(assetIdx), 0) - winAmount))) | |
170 | 172 | then throw((("Invalid " + GAME_NAME) + " account state - reserved amount is less than 0")) | |
171 | 173 | else changeInt(keyReservationByAssetIdx(assetIdx), -(winAmount)) | |
172 | 174 | ||
173 | 175 | ||
174 | 176 | func validateAndGetAssetIdx (assetIdStr) = { | |
175 | 177 | let idx = indexOf(ASSETS, assetIdStr) | |
176 | 178 | if (!(isDefined(idx))) | |
177 | 179 | then throw("Invalid payment asset") | |
178 | 180 | else value(idx) | |
179 | 181 | } | |
180 | 182 | ||
181 | 183 | ||
182 | 184 | func validateBetAndGetWinAmount (bet,internalAssetIdx,playerChoice) = { | |
183 | 185 | let dicesCount = size(playerChoice) | |
184 | 186 | func checkAmount (a,x) = if (a) | |
185 | 187 | then true | |
186 | 188 | else (bet == ((x * DECIMALS[internalAssetIdx]) / BETDIVIDERS[internalAssetIdx])) | |
187 | 189 | ||
188 | 190 | if (!({ | |
189 | 191 | let $l = BETS | |
190 | 192 | let $s = size($l) | |
191 | 193 | let $acc0 = false | |
192 | 194 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
193 | 195 | then $a | |
194 | 196 | else checkAmount($a, $l[$i]) | |
195 | 197 | ||
196 | 198 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
197 | 199 | then $a | |
198 | 200 | else throw("List size exceeds 5") | |
199 | 201 | ||
200 | 202 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
201 | 203 | })) | |
202 | 204 | then throw("Bet amount is not valid") | |
203 | 205 | else if ((parseInt(playerChoice) == unit)) | |
204 | 206 | then throw("Invalid player's choice") | |
205 | 207 | else if ((dicesCount != NUM_BETS)) | |
206 | 208 | then throw("Invalid length of player's choice") | |
207 | 209 | else fraction(bet, RATE, RATEMULT) | |
208 | 210 | } | |
209 | 211 | ||
210 | 212 | ||
211 | 213 | let HOR_LINES = [[491, 506, 44], [455, 542, 120], [404, 596, 166], [441, 556, 177], [387, 620, 232], [423, 620, 232], [410, 592, 244], [329, 665, 321], [370, 666, 337], [355, 645, 349], [313, 692, 384], [289, 682, 405], [324, 657, 461], [450, 575, 525], [505, 505, 532]] | |
212 | 214 | ||
213 | 215 | let HALF = 5000 | |
214 | 216 | ||
215 | 217 | let M4 = 10000 | |
216 | 218 | ||
217 | 219 | func getCoords (gameId,rsaSign) = { | |
218 | 220 | func calcAreas (acc,ignored) = { | |
219 | 221 | let i = acc._3 | |
220 | 222 | if ((i == 14)) | |
221 | 223 | then acc | |
222 | 224 | else { | |
223 | 225 | let top = HOR_LINES[i] | |
224 | 226 | let bottom = HOR_LINES[(i + 1)] | |
225 | 227 | let area4 = (((((top[1] - top[0]) + bottom[1]) - bottom[0]) * (bottom[2] - top[2])) * 5000) | |
226 | 228 | $Tuple3((acc._1 :+ area4), (acc._2 + area4), (acc._3 + 1)) | |
227 | 229 | } | |
228 | 230 | } | |
229 | 231 | ||
230 | - | let $ | |
232 | + | let $t079968063 = { | |
231 | 233 | let $l = HOR_LINES | |
232 | 234 | let $s = size($l) | |
233 | 235 | let $acc0 = $Tuple3(nil, 0, 0) | |
234 | 236 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
235 | 237 | then $a | |
236 | 238 | else calcAreas($a, $l[$i]) | |
237 | 239 | ||
238 | 240 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
239 | 241 | then $a | |
240 | 242 | else throw("List size exceeds 15") | |
241 | 243 | ||
242 | 244 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
243 | 245 | } | |
244 | - | let areas = $ | |
245 | - | let totalArea = $ | |
246 | + | let areas = $t079968063._1 | |
247 | + | let totalArea = $t079968063._2 | |
246 | 248 | let rand = (toInt(sha256((rsaSign + toBytes(gameId)))) % totalArea) | |
247 | 249 | func check (acc,area) = { | |
248 | 250 | let i = acc._1 | |
249 | 251 | let newArea = (acc._2 + area) | |
250 | 252 | $Tuple3((i + 1), newArea, if (if ((0 > acc._3)) | |
251 | 253 | then (newArea > rand) | |
252 | 254 | else false) | |
253 | 255 | then i | |
254 | 256 | else acc._3) | |
255 | 257 | } | |
256 | 258 | ||
257 | 259 | let j = ( let $l = areas | |
258 | 260 | let $s = size($l) | |
259 | 261 | let $acc0 = $Tuple3(0, 0, -1) | |
260 | 262 | func $f1_1 ($a,$i) = if (($i >= $s)) | |
261 | 263 | then $a | |
262 | 264 | else check($a, $l[$i]) | |
263 | 265 | ||
264 | 266 | func $f1_2 ($a,$i) = if (($i >= $s)) | |
265 | 267 | then $a | |
266 | 268 | else throw("List size exceeds 14") | |
267 | 269 | ||
268 | 270 | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14))._3 | |
269 | 271 | let top = HOR_LINES[j] | |
270 | 272 | let bottom = HOR_LINES[(j + 1)] | |
271 | 273 | let mx04 = ((top[0] + bottom[0]) * HALF) | |
272 | 274 | let mx14 = ((top[1] + bottom[1]) * HALF) | |
273 | 275 | let h4 = ((bottom[2] - top[2]) * M4) | |
274 | 276 | let my4 = ((top[2] + bottom[2]) * HALF) | |
275 | 277 | let randX4 = (mx04 + (toInt(sha256((rsaSign + toBytes(j)))) % (mx14 - mx04))) | |
276 | 278 | let randY4 = ((top[2] * M4) + (toInt(sha256((rsaSign + toBytes(randX4)))) % h4)) | |
277 | 279 | let a4 = ((top[2] * M4) - randY4) | |
278 | 280 | let b4 = ((bottom[2] * M4) - randY4) | |
279 | 281 | let x04 = fraction(((top[0] * b4) - (bottom[0] * a4)), M4, h4) | |
280 | 282 | let x14 = fraction(((top[1] * b4) - (bottom[1] * a4)), M4, h4) | |
281 | 283 | if ((x04 > randX4)) | |
282 | 284 | then [((2 * mx04) - randX4), ((2 * my4) - randY4)] | |
283 | 285 | else if ((randX4 > x14)) | |
284 | 286 | then [((2 * mx14) - randX4), ((2 * my4) - randY4)] | |
285 | 287 | else [randX4, randY4] | |
286 | 288 | } | |
287 | 289 | ||
288 | 290 | ||
291 | + | func getDecorationIndex (gameId,rsaSign) = (toInt(sha256((toBytes(gameId) + rsaSign))) % MAX_DECORATIONS) | |
292 | + | ||
293 | + | ||
289 | 294 | func generateRandChoice (gameId,rsaSign) = { | |
290 | 295 | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
291 | 296 | if (!(rsaSigValid)) | |
292 | 297 | then throw("Invalid RSA signature") | |
293 | 298 | else { | |
294 | 299 | let rand = (toInt(sha256(rsaSign)) % RANDOM_RANGE) | |
295 | 300 | toString((rand + 1)) | |
296 | 301 | } | |
297 | 302 | } | |
298 | 303 | ||
299 | 304 | ||
300 | 305 | func isPlayerWin (playerChoice,randChoise) = { | |
301 | 306 | let s = size(playerChoice) | |
302 | 307 | func check (a,x) = if (a) | |
303 | 308 | then true | |
304 | 309 | else if ((s >= x)) | |
305 | 310 | then (take(drop(playerChoice, (x - 1)), 1) == randChoise) | |
306 | 311 | else false | |
307 | 312 | ||
308 | 313 | let $l = [1, 2, 3, 4, 5] | |
309 | 314 | let $s = size($l) | |
310 | 315 | let $acc0 = false | |
311 | 316 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
312 | 317 | then $a | |
313 | 318 | else check($a, $l[$i]) | |
314 | 319 | ||
315 | 320 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
316 | 321 | then $a | |
317 | 322 | else throw("List size exceeds 5") | |
318 | 323 | ||
319 | 324 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
320 | 325 | } | |
321 | 326 | ||
322 | 327 | ||
323 | - | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
328 | + | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord,prizeIndex) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
324 | 329 | then "" | |
325 | - | else randOrEmpty, xCoord, yCoord], "_") | |
330 | + | else randOrEmpty, xCoord, yCoord, prizeIndex], "_") | |
326 | 331 | ||
327 | 332 | ||
328 | - | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty, toString(xCoord), toString(yCoord)) | |
333 | + | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord,prizeIndex) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty, toString(xCoord), toString(yCoord), toString(prizeIndex)) | |
329 | 334 | ||
330 | 335 | ||
331 | - | func finishGameData (origGameData,gameStatus,rand,winByTimeout,xCoord,yCoord) = { | |
332 | - | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand, toString(xCoord), toString(yCoord)) | |
336 | + | func finishGameData (origGameData,gameStatus,rand,winByTimeout,xCoord,yCoord,prizeIndex) = { | |
337 | + | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand, toString(xCoord), toString(yCoord), toString(prizeIndex)) | |
333 | 338 | if (winByTimeout) | |
334 | 339 | then (finishGameData + "_TIMEOUT") | |
335 | 340 | else finishGameData | |
336 | 341 | } | |
337 | 342 | ||
338 | 343 | ||
339 | 344 | func extractGameData (gameId) = split(match getString(this, gameId) { | |
340 | 345 | case str: String => | |
341 | 346 | str | |
342 | 347 | case _ => | |
343 | 348 | throw((("Game: " + gameId) + " not found.")) | |
344 | 349 | }, "_") | |
345 | 350 | ||
346 | 351 | ||
347 | 352 | @Callable(i) | |
348 | 353 | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != this)) | |
349 | 354 | then throw("not authorized") | |
350 | 355 | else { | |
351 | 356 | func splitter (acc,elem) = { | |
352 | 357 | let tokList = split(elem, ":") | |
353 | 358 | if ((size(tokList) != 3)) | |
354 | 359 | then throw("Invalid asset record") | |
355 | 360 | else $Tuple3((acc._1 :+ tokList[idxAssets]), (acc._2 :+ tokList[idxDecimals]), (acc._3 :+ tokList[idxDividers])) | |
356 | 361 | } | |
357 | 362 | ||
358 | 363 | let r = { | |
359 | 364 | let $l = split_4C(tokensDescriptor, "_") | |
360 | 365 | let $s = size($l) | |
361 | 366 | let $acc0 = $Tuple3(nil, nil, nil) | |
362 | 367 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
363 | 368 | then $a | |
364 | 369 | else splitter($a, $l[$i]) | |
365 | 370 | ||
366 | 371 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
367 | 372 | then $a | |
368 | 373 | else throw("List size exceeds 10") | |
369 | 374 | ||
370 | 375 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
371 | 376 | } | |
372 | 377 | [StringEntry(RSAPUBLIC64KEY, rsaPublic64), StringEntry(SERVERADDRESSKEY, benzAddress), IntegerEntry(RANDTIMEFRAMEKEY, randOracleTimeFrame), StringEntry(allowedAssetsKey, makeString_2C(r._1, SEP)), StringEntry(assetsDecimalsKey, makeString(r._2, SEP)), StringEntry(betDividersKey, makeString(r._3, SEP))] | |
373 | 378 | } | |
374 | 379 | ||
375 | 380 | ||
376 | 381 | ||
377 | 382 | @Callable(i) | |
378 | 383 | func maintenance (blocked) = if ((i.caller != SERVER)) | |
379 | 384 | then throw("not authorized") | |
380 | 385 | else [BooleanEntry(blockedKey, blocked)] | |
381 | 386 | ||
382 | 387 | ||
383 | 388 | ||
384 | 389 | @Callable(i) | |
385 | 390 | func bet (playerChoice) = if (valueOrElse(getBoolean(blockedKey), false)) | |
386 | 391 | then throw("Game is stopped for maintenence") | |
387 | 392 | else { | |
388 | 393 | let gameId = toBase58String(i.transactionId) | |
389 | 394 | if ((1 >= size(i.payments))) | |
390 | 395 | then throw("2 payments must be attached") | |
391 | 396 | else if (isDefined(getString(this, gameId))) | |
392 | 397 | then throw((("Bet for: " + gameId) + " was already made.")) | |
393 | 398 | else { | |
394 | 399 | let betPmt = value(i.payments[0]) | |
395 | 400 | let feePmt = value(i.payments[1]) | |
396 | 401 | if (isDefined(feePmt.assetId)) | |
397 | 402 | then throw("feePmt (2nd payment) assetId must be in Waves") | |
398 | 403 | else if ((MINFEEWAVES > feePmt.amount)) | |
399 | 404 | then throw("feePmt (2nd payment) must be >= 0.005 Waves") | |
400 | 405 | else { | |
401 | 406 | let assetIdStr = assetIdToStr(betPmt.assetId) | |
402 | 407 | let internalAssetIdx = validateAndGetAssetIdx(assetIdStr) | |
403 | 408 | let commission = feePmt.amount | |
404 | 409 | let winAmount = validateBetAndGetWinAmount(betPmt.amount, internalAssetIdx, playerChoice) | |
405 | 410 | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
406 | - | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "", -1, -1) | |
411 | + | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "", -1, -1, -1) | |
407 | 412 | [IntegerEntry(keyReservationByAssetIdx(internalAssetIdx), increaseReserveAmount(winAmount, internalAssetIdx)), incrementInt(GAMESCOUNTERKEY), StringEntry(gameId, gameData), ScriptTransfer(SERVER, commission, feePmt.assetId)] | |
408 | 413 | } | |
409 | 414 | } | |
410 | 415 | } | |
411 | 416 | ||
412 | 417 | ||
413 | 418 | ||
414 | 419 | @Callable(i) | |
415 | 420 | func withdraw (gameId,rsaSign) = { | |
416 | 421 | let gameData = extractGameData(gameId) | |
417 | 422 | let gameState = gameData[IdxGameState] | |
418 | 423 | let playerChoice = gameData[IdxPlayerChoice] | |
419 | 424 | let startedHeight = parseIntValue(gameData[IdxStartedHeight]) | |
420 | 425 | let winAmount = parseIntValue(gameData[IdxWinAmount]) | |
421 | 426 | let assetIdx = parseIntValue(gameData[IdxAssetId]) | |
422 | 427 | let playerPubKey58 = gameData[IdxPlayerPubKey58] | |
423 | 428 | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
424 | 429 | if ((gameState != STATESUBMITTED)) | |
425 | 430 | then throw("Invalid game state for passed gameId") | |
426 | 431 | else if ((i.caller != SERVER)) | |
427 | 432 | then throw("Regular withdraw can be done by server only") | |
428 | 433 | else { | |
429 | 434 | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
430 | 435 | let randChoice = if (winByTimeout) | |
431 | 436 | then take(playerChoice, 1) | |
432 | 437 | else generateRandChoice(gameId, rsaSign) | |
433 | 438 | let playerWin = isPlayerWin(playerChoice, randChoice) | |
434 | 439 | let newGameStatus = if (playerWin) | |
435 | 440 | then STATEWON | |
436 | 441 | else STATELOST | |
437 | 442 | let coords = if (playerWin) | |
438 | 443 | then [-(M4), -(M4)] | |
439 | 444 | else getCoords(gameId, rsaSign) | |
440 | - | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout, (coords[0] / M4), (coords[1] / M4)) | |
445 | + | let prizeIndex = if (playerWin) | |
446 | + | then -1 | |
447 | + | else getDecorationIndex(gameId, rsaSign) | |
448 | + | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout, (coords[0] / M4), (coords[1] / M4), prizeIndex) | |
441 | 449 | ([StringEntry(gameId, newGameData), decreaseReservedAmount(gameId, assetIdx, winAmount)] ++ (if (playerWin) | |
442 | 450 | then [ScriptTransfer(playerAddress, winAmount, assetIdFromStr(ASSETS[assetIdx]))] | |
443 | 451 | else nil)) | |
444 | 452 | } | |
445 | 453 | } | |
446 | 454 | ||
447 | 455 | ||
448 | 456 | @Verifier(tx) | |
449 | 457 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
450 | 458 | then match tx { | |
451 | 459 | case ttx: TransferTransaction => | |
452 | 460 | let assetIdx = validateAndGetAssetIdx(assetIdToStr(ttx.assetId)) | |
453 | 461 | ((getAssetBalance(ttx.assetId) - ttx.amount) >= getIntOr(keyReservationByAssetIdx(assetIdx), 0)) | |
454 | 462 | case stx: SetScriptTransaction => | |
455 | 463 | func checker (acc,asset) = if (acc) | |
456 | 464 | then (getIntOr(keyReservationByAssetStr(asset), 0) == 0) | |
457 | 465 | else false | |
458 | 466 | ||
459 | 467 | let $l = ASSETS | |
460 | 468 | let $s = size($l) | |
461 | 469 | let $acc0 = true | |
462 | 470 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
463 | 471 | then $a | |
464 | 472 | else checker($a, $l[$i]) | |
465 | 473 | ||
466 | 474 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
467 | 475 | then $a | |
468 | 476 | else throw("List size exceeds 10") | |
469 | 477 | ||
470 | 478 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
471 | 479 | case itx: InvokeScriptTransaction => | |
472 | 480 | if ((itx.dApp == this)) | |
473 | 481 | then (itx.function == "constructorV1") | |
474 | 482 | else false | |
475 | 483 | case _ => | |
476 | 484 | false | |
477 | 485 | } | |
478 | 486 | else false | |
479 | 487 |
github/deemru/w8io/026f985 69.10 ms ◑