tx · DbnTosmNCwAQ8mH1cKGQUoNRfNUq2rTMy2RuzgCdUG11 3MpdJJV3WyZufiGHRtb7xbY2Vsc2pBFcJYZ: -0.01400000 Waves 2021.05.31 09:48 [1549505] smart account 3MpdJJV3WyZufiGHRtb7xbY2Vsc2pBFcJYZ > SELF 0.00000000 Waves
{ "type": 13, "id": "DbnTosmNCwAQ8mH1cKGQUoNRfNUq2rTMy2RuzgCdUG11", "fee": 1400000, "feeAssetId": null, "timestamp": 1622443714980, "version": 2, "chainId": 84, "sender": "3MpdJJV3WyZufiGHRtb7xbY2Vsc2pBFcJYZ", "senderPublicKey": "ALG9JVGNn9aCL68dbg1AmW6yDQv1b8EDLq99pQS8L1k6", "proofs": [ "2Wt8CqnbggujyHkU9JKqS8v5E9gE25gFX6gbZg64ZCZPUJ5XVbPEDJb8AwjS9uNZYhHjWWp7L6nvNdBQbLB2h6C7" ], "script": "base64:AAIDAAAAAAAAAAYIARIAEgAAAAAWAAAAAApkQXBwQWRkcmVzAgAAACtGOURDR2lZZ1Q4eXZCcTFBUUZjU3BHRzRwOHNkek56OW1aY3pEdko0NUxMAAAAAAt0aWNrZXRBc3NldAEAAAAgRhz1lSBi1eJGtOgMmCIyAWadBG7dHU2jIBGpv2KvKCwAAAAADHRva2VuQXNzZXRJZAIAAAAsNWloOWpkNEtWOWtTZXk1NXl2S01nTFNIY3dzWVlrUTRwUkRKdFJOb3hVaHkAAAAADXVzZUdhcmxpY0NvaW4HAAAAAA10b2tlbnNQZXJQbGF5AAAAAAAF9eEAAAAAAA1sb3R0ZXJ5YW1vdW50AgAAAAdfYW1vdW50AAAAABJsb3R0ZXJ5cHJvYmFiaWxpdHkCAAAADF9wcm9iYWJpbGl0eQAAAAAZbG90dGVyeXByb2JhYmlsaXR5ZGVjaW1hbAIAAAAUX3Byb2JhYmlsaXR5X2RlY2ltYWwAAAAAFWxvdHRlcnlXaW5uaW5nQWRkcmVzcwIAAAAQX3dpbm5pbmdfYWRkcmVzcwAAAAAMbG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GF5aW5nITxwPgkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAUbGFzdEhhc2hSYW5kb21OdW1iZXIFAAAACnJhbmROdW1iZXIFAAAAA25pbAQAAAALd2luVHJhbnNmZXIJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIFAAAACXdyaXRlU2V0cwkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAADbmlsCQAAAgAAAAEJAAEsAAAAAgkAASwAAAACAgAAAAlZb3UgbmVlZCAJAAJYAAAAAQUAAAALdGlja2V0QXNzZXQCAAAAEyB0byBwbGF5IHRoaXMgZ2FtZS4AAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmyDKW8", "height": 1549505, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G8bK2ZaSX37upiKuYhyCcHr1nRyKzptmxDxmn9ZYLQVo Next: 61W2Qh6J57UYbQYbaqVk5Y3TJX965P6DvQxJNe8dh2Uc Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let dAppAddres = "F9DCGiYgT8yvBq1AQFcSpGG4p8sdzNz9mZczDvJ45LL" | |
5 | 5 | ||
6 | - | let | |
6 | + | let ticketAsset = base58'5ih9jd4KV9kSey55yvKMgLSHcwsYYkQ4pRDJtRNoxUhy' | |
7 | 7 | ||
8 | - | let | |
8 | + | let tokenAssetId = "5ih9jd4KV9kSey55yvKMgLSHcwsYYkQ4pRDJtRNoxUhy" | |
9 | 9 | ||
10 | - | let | |
10 | + | let useGarlicCoin = false | |
11 | 11 | ||
12 | - | let | |
12 | + | let tokensPerPlay = 100000000 | |
13 | 13 | ||
14 | - | let | |
14 | + | let lotteryamount = "_amount" | |
15 | 15 | ||
16 | - | let | |
16 | + | let lotteryprobability = "_probability" | |
17 | 17 | ||
18 | - | let | |
18 | + | let lotteryprobabilitydecimal = "_probability_decimal" | |
19 | 19 | ||
20 | - | let | |
20 | + | let lotteryWinningAddress = "_winning_address" | |
21 | 21 | ||
22 | - | let | |
22 | + | let lotteryPrice = "_price" | |
23 | 23 | ||
24 | - | let | |
24 | + | let lotteryPrices = "_lottery_prices" | |
25 | 25 | ||
26 | - | let | |
26 | + | let lotteryAssetId = "_lottery_asset_id" | |
27 | 27 | ||
28 | - | let | |
28 | + | let countOfPrices = "_count_prices" | |
29 | 29 | ||
30 | - | let | |
30 | + | let lastHashRandomNumber = "last_spin_random_hash" | |
31 | 31 | ||
32 | - | let | |
32 | + | let allowSizeLottery = 2 | |
33 | 33 | ||
34 | - | let | |
34 | + | let totalPricesInPool = "total_prizes_pool" | |
35 | 35 | ||
36 | - | let | |
36 | + | let tokenAId = "f2MzwrmN5wiMn5DwbBL33247fdsf432FV9kSe" | |
37 | 37 | ||
38 | - | let | |
38 | + | let tokenBId = "f1MzwrmN4wiMn4DwbBL43242fsdf434Ffsdfs" | |
39 | 39 | ||
40 | - | let PLACEBETWIN = "PLACEBETWIN" | |
41 | - | ||
42 | - | let gameCounterLabel = "G_GAMECOUNTER" | |
43 | - | ||
44 | - | let gameTotalBetsLabel = "G_TOTALBETS" | |
45 | - | ||
46 | - | let gameTotalProccedBetsLabel = "G_PROCESSEDBETS" | |
47 | - | ||
48 | - | let gameTotalFieldBetsLabel = "G_TOTALFIELD_ODDS_BETS" | |
49 | - | ||
50 | - | let gameTotalProccedFieldOrOddsBetsLabel = "G_PROCESSEDFIEL_ODDS_BETS" | |
51 | - | ||
52 | - | func gameStartHeightLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_STARTHEIGHT") | |
53 | - | ||
54 | - | ||
55 | - | func gameEndHeightLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_ENDHEIGHT") | |
56 | - | ||
57 | - | ||
58 | - | func getStartHeight (gameCounter) = getInteger(this, gameStartHeightLabel(gameCounter)) | |
59 | - | ||
60 | - | ||
61 | - | func getEndHeight (gameCounter) = getInteger(this, gameEndHeightLabel(gameCounter)) | |
62 | - | ||
63 | - | ||
64 | - | func gameBetLineLabel (betNumber) = (("B_" + toString(betNumber)) + "_BETDETAILS") | |
65 | - | ||
66 | - | ||
67 | - | func gameFieldOrOddsBetLineLabel (betNumber) = (("B_" + toString(betNumber)) + "_BETFIELODDSDDETAILS") | |
68 | - | ||
69 | - | ||
70 | - | func getBetDetailsResult (betNumber) = getString(this, gameBetLineLabel(betNumber)) | |
71 | - | ||
72 | - | ||
73 | - | func getFieldBetDetailsResult (betNumber) = getString(this, gameFieldOrOddsBetLineLabel(betNumber)) | |
74 | - | ||
75 | - | ||
76 | - | func authorizePermission (callerPublicKey) = (callerPublicKey != gameMasterPublicKey) | |
77 | - | ||
78 | - | ||
79 | - | func gameCurrentPointDiceLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_LASTPOINT") | |
80 | - | ||
81 | - | ||
82 | - | func gameFirstPointDiceLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_FIRSTPOINT") | |
83 | - | ||
84 | - | ||
85 | - | func gameWinningNumberBetLabel (gameCounter,betNumber,betType) = ((((((("W_" + "BET_TYPE_") + betType) + "_") + toString(betNumber)) + "_WINNING_BET_") + toString(gameCounter)) + "_GAME_NUMBER") | |
86 | - | ||
87 | - | ||
88 | - | func gameStateLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_STATE") | |
89 | - | ||
90 | - | ||
91 | - | func gameSumShaLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_SUMSHA") | |
92 | - | ||
93 | - | ||
94 | - | func gameRandomHashLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_RANDOMHASH") | |
95 | - | ||
96 | - | ||
97 | - | func getGameTotalBets () = getInteger(this, gameTotalBetsLabel) | |
98 | - | ||
99 | - | ||
100 | - | func getGameProcessedBets () = getInteger(this, gameTotalProccedBetsLabel) | |
101 | - | ||
102 | - | ||
103 | - | func getGameTotalFieldOrOddsBets () = getInteger(this, gameTotalFieldBetsLabel) | |
104 | - | ||
105 | - | ||
106 | - | func getGameProcessedFieldOrOddsBets () = getInteger(this, gameTotalProccedFieldOrOddsBetsLabel) | |
107 | - | ||
108 | - | ||
109 | - | func getGameState (gameCounter) = getInteger(this, gameStateLabel(gameCounter)) | |
110 | - | ||
111 | - | ||
112 | - | func getGameSumSha (gameCounter) = getString(this, gameSumShaLabel(gameCounter)) | |
113 | - | ||
114 | - | ||
115 | - | func getRandomHash (gameCounter) = getString(this, gameRandomHashLabel(gameCounter)) | |
116 | - | ||
117 | - | ||
118 | - | func gameRollsCountBetLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_ROLLSCOUNT") | |
119 | - | ||
120 | - | ||
121 | - | func gameRollDiceWithGameNumberLabel (gameCounter,rollDice) = (((("G_" + toString(gameCounter)) + "_") + toString(rollDice)) + "_GAMENUMBER_ROLLDICE") | |
122 | - | ||
123 | - | ||
124 | - | func gameFieldOrOddsBetForNextThrowLabel (betNumber) = (("B_" + toString(betNumber)) + "_FIELD_ODDS_BET_ROLLDICE") | |
125 | - | ||
126 | - | ||
127 | - | func getGameRollsCount (gameCounter) = getInteger(this, gameRollsCountBetLabel(gameCounter)) | |
128 | - | ||
129 | - | ||
130 | - | func getGameRollDiceWithGameNumber (gameCounter,rollDice) = getInteger(this, gameRollDiceWithGameNumberLabel(gameCounter, rollDice)) | |
131 | - | ||
132 | - | ||
133 | - | func getFieldOddsBetForNextDice (betNumber) = getInteger(this, gameFieldOrOddsBetForNextThrowLabel(betNumber)) | |
134 | - | ||
135 | - | ||
136 | - | func gameBetCounterLabel (gameNumber) = (("B_" + toString(gameNumber)) + "_BET_GAMENUMBER") | |
137 | - | ||
138 | - | ||
139 | - | func gameFieldOrOddsBetGameCounterLabel (gameNumber) = (("B_" + toString(gameNumber)) + "_FIELD_ODDS_BET_GAMENUMBER") | |
140 | - | ||
141 | - | ||
142 | - | func getGameBetCounter (gameNumber) = getInteger(this, gameBetCounterLabel(gameNumber)) | |
143 | - | ||
144 | - | ||
145 | - | func getGameFieldOrOddsBetCounter (gameNumber) = getInteger(this, gameFieldOrOddsBetGameCounterLabel(gameNumber)) | |
146 | - | ||
147 | - | ||
148 | - | func getGameCounter () = getInteger(this, gameCounterLabel) | |
149 | - | ||
150 | - | ||
151 | - | func getFirstPointDice (gameCounter) = getInteger(this, gameFirstPointDiceLabel(gameCounter)) | |
152 | - | ||
153 | - | ||
154 | - | func getCurrentPointDice (gameCounter) = match getInteger(this, gameCurrentPointDiceLabel(gameCounter)) { | |
155 | - | case val: Int => | |
156 | - | val | |
157 | - | case _ => | |
158 | - | 0 | |
159 | - | } | |
160 | - | ||
161 | - | ||
162 | - | func validateBetName (betName) = if ((betName == PASSLINEBET)) | |
163 | - | then true | |
164 | - | else if ((betName == DONTPASSLINEBET)) | |
165 | - | then true | |
166 | - | else false | |
167 | - | ||
168 | - | ||
169 | - | func validateRoundBet (betName) = if ((betName == FIELDBET)) | |
170 | - | then true | |
171 | - | else if ((betName == ODDSBET)) | |
172 | - | then true | |
173 | - | else if ((betName == BIG6OR8BET)) | |
174 | - | then true | |
175 | - | else if ((betName == PLACEBETBUY)) | |
176 | - | then true | |
177 | - | else if ((betName == PLACEBETLAY)) | |
178 | - | then true | |
179 | - | else if ((betName == COMEBET)) | |
180 | - | then true | |
181 | - | else if ((betName == DONTCOMEBET)) | |
182 | - | then true | |
183 | - | else if ((betName == PLACEBETLOSE)) | |
184 | - | then true | |
185 | - | else if ((betName == PLACEBETWIN)) | |
186 | - | then true | |
187 | - | else false | |
188 | - | ||
189 | - | ||
190 | - | func getWinningAmountForOdds (amount,odd,resultOfRound) = if (if ((odd == 4)) | |
191 | - | then true | |
192 | - | else (odd == 10)) | |
193 | - | then { | |
194 | - | let winningAmount = (amount * 7) | |
195 | - | winningAmount | |
196 | - | } | |
197 | - | else if (if ((odd == 5)) | |
198 | - | then true | |
199 | - | else (odd == 8)) | |
200 | - | then { | |
201 | - | let winningAmount = (amount * 9) | |
202 | - | winningAmount | |
203 | - | } | |
204 | - | else if (if ((odd == 3)) | |
205 | - | then true | |
206 | - | else (odd == 11)) | |
207 | - | then { | |
208 | - | let winningAmount = (amount * 15) | |
209 | - | winningAmount | |
210 | - | } | |
211 | - | else if (if ((odd == 2)) | |
212 | - | then true | |
213 | - | else (odd == 12)) | |
214 | - | then { | |
215 | - | let winningAmount = (amount * 30) | |
216 | - | winningAmount | |
217 | - | } | |
218 | - | else if (if ((odd == 10)) | |
219 | - | then true | |
220 | - | else (odd == 4)) | |
221 | - | then { | |
222 | - | let winningAmount = (amount * 30) | |
223 | - | winningAmount | |
224 | - | } | |
225 | - | else if ((odd == 7)) | |
226 | - | then { | |
227 | - | let winningAmount = (amount * 4) | |
228 | - | winningAmount | |
229 | - | } | |
230 | - | else if (if ((odd == 100)) | |
231 | - | then if (if ((resultOfRound == 3)) | |
232 | - | then true | |
233 | - | else (resultOfRound == 12)) | |
234 | - | then true | |
235 | - | else (resultOfRound == 2) | |
236 | - | else false) | |
237 | - | then { | |
238 | - | let winningAmount = (amount * 7) | |
239 | - | winningAmount | |
240 | - | } | |
241 | - | else 0 | |
242 | - | ||
243 | - | ||
244 | - | func getWinningAmountForField (amount,resultOfRound) = if ((resultOfRound == 12)) | |
245 | - | then { | |
246 | - | let winningAmount = (amount * 4) | |
247 | - | winningAmount | |
248 | - | } | |
249 | - | else if ((resultOfRound == 2)) | |
250 | - | then { | |
251 | - | let winningAmount = (amount * 3) | |
252 | - | winningAmount | |
253 | - | } | |
254 | - | else if (if (if (if ((resultOfRound == 5)) | |
255 | - | then true | |
256 | - | else (resultOfRound == 6)) | |
257 | - | then true | |
258 | - | else (resultOfRound == 7)) | |
259 | - | then true | |
260 | - | else (resultOfRound == 8)) | |
261 | - | then 0 | |
262 | - | else { | |
263 | - | let winningAmount = (amount * 2) | |
264 | - | winningAmount | |
265 | - | } | |
266 | - | ||
267 | - | ||
268 | - | func storeOneRoundBetTypes (gameCounter,amount,typeBet,caller,odd) = match getGameTotalFieldOrOddsBets() { | |
269 | - | case betCount: Int => | |
270 | - | match getGameRollsCount(gameCounter) { | |
271 | - | case rollCount: Int => | |
272 | - | let newTotalBetCount = (betCount + 1) | |
273 | - | let newRollCountForGame = (rollCount + 1) | |
274 | - | if (if ((typeBet == COMEBET)) | |
275 | - | then true | |
276 | - | else (typeBet == DONTCOMEBET)) | |
277 | - | then [IntegerEntry(gameFieldOrOddsBetGameCounterLabel(newTotalBetCount), gameCounter), StringEntry(gameFieldOrOddsBetLineLabel(newTotalBetCount), ((((((((caller + "_") + amount) + "_") + typeBet) + "_active_pending_") + toString(gameCounter)) + "_") + toString(newRollCountForGame))), IntegerEntry(gameTotalFieldBetsLabel, newTotalBetCount), IntegerEntry(gameFieldOrOddsBetForNextThrowLabel(newTotalBetCount), newRollCountForGame)] | |
278 | - | else [IntegerEntry(gameFieldOrOddsBetGameCounterLabel(newTotalBetCount), gameCounter), StringEntry(gameFieldOrOddsBetLineLabel(newTotalBetCount), ((((((caller + "_") + amount) + "_") + typeBet) + "_active_pending_") + toString(odd))), IntegerEntry(gameTotalFieldBetsLabel, newTotalBetCount), IntegerEntry(gameFieldOrOddsBetForNextThrowLabel(newTotalBetCount), newRollCountForGame)] | |
279 | - | case _ => | |
280 | - | throw("Game doesn't exist") | |
281 | - | } | |
282 | - | case _ => | |
283 | - | throw("Game has not bee initialized") | |
284 | - | } | |
285 | - | ||
286 | - | ||
287 | - | func rollPlaceBetIntoAnotherRoundBet (totalBets,lastFieldProcessBet,betOnRoll,gameCounter,amount,typeBet,caller,odd) = [IntegerEntry(gameFieldOrOddsBetGameCounterLabel(totalBets), gameCounter), StringEntry(gameFieldOrOddsBetLineLabel(totalBets), ((((((caller + "_") + amount) + "_") + typeBet) + "_active_pending_") + toString(odd))), StringEntry(gameFieldOrOddsBetLineLabel(lastFieldProcessBet), ((((((caller + "_") + amount) + "_") + typeBet) + "_inactive_rolled_") + toString(odd))), IntegerEntry(gameTotalProccedFieldOrOddsBetsLabel, lastFieldProcessBet), IntegerEntry(gameTotalFieldBetsLabel, totalBets), IntegerEntry(gameFieldOrOddsBetForNextThrowLabel(totalBets), betOnRoll)] | |
288 | - | ||
289 | - | ||
290 | - | func storeNextRoll (gameState,amount,totalFieldBets,lastFieldProcessBet,betOnRoll,gameNumber,betType,betPlacer,odd) = if ((gameState == GAMEFINISHED)) | |
291 | - | then rollPlaceBetIntoAnotherRoundBet((totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), toString(amount), betType, betPlacer, odd) | |
292 | - | else rollPlaceBetIntoAnotherRoundBet((totalFieldBets + 1), (lastFieldProcessBet + 1), (betOnRoll + 1), gameNumber, toString(amount), betType, betPlacer, odd) | |
293 | - | ||
294 | - | ||
295 | - | func storeComeDontComeBet (gameState,betDetails,resultOfRound,amount,totalFieldBets,lastFieldProcessBet,betOnRoll,gameNumber,betType,betPlacer,odd) = { | |
296 | - | let comeBetGameNumber = value(parseInt(split(betDetails, "_")[5])) | |
297 | - | let comeBetRollNumber = value(parseInt(split(betDetails, "_")[6])) | |
298 | - | let resultOfGame = value(getGameRollDiceWithGameNumber(comeBetGameNumber, comeBetRollNumber)) | |
299 | - | if ((resultOfRound == 7)) | |
300 | - | then if ((betDetails == COMEBET)) | |
301 | - | then throw("Only Field Type of Bet can be proceed") | |
302 | - | else throw("Only Field Type of Bet can be proceed") | |
303 | - | else if ((resultOfRound == resultOfGame)) | |
304 | - | then throw("Only Field Type of Bet can be proceed") | |
305 | - | else if ((gameState == GAMEFINISHED)) | |
306 | - | then storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), betType, betPlacer, odd) | |
307 | - | else storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), (betOnRoll + 1), gameNumber, betType, betPlacer, odd) | |
40 | + | func randomizer (inv) = { | |
41 | + | let lastPlay = match getBinary(this, lastHashRandomNumber) { | |
42 | + | case s: ByteVector => | |
43 | + | s | |
44 | + | case _: Unit => | |
45 | + | base58'2ee4oFDYriWJ9EMeR' | |
46 | + | case _ => | |
47 | + | throw("Match error") | |
48 | + | } | |
49 | + | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
50 | + | sha256(rand) | |
308 | 51 | } | |
309 | 52 | ||
310 | 53 | ||
311 | - | func storePassOrComeBet (gameCounter,amount,typeBet,caller) = match getGameTotalBets() { | |
312 | - | case number: Int => | |
313 | - | let newTotalBets = (number + 1) | |
314 | - | [IntegerEntry(gameBetCounterLabel(newTotalBets), gameCounter), StringEntry(gameBetLineLabel(newTotalBets), (((((caller + "_") + amount) + "_") + typeBet) + "_active_pending")), IntegerEntry(gameTotalBetsLabel, newTotalBets)] | |
315 | - | case _ => | |
316 | - | throw("Game has not bee initialized") | |
317 | - | } | |
318 | - | ||
319 | - | ||
320 | - | func udpateBetDetailsWithLost (updateBetDetials,gameNumber,lastProceedBet,betIndex,betProceedIndex) = { | |
321 | - | let updateInfoBet = (updateBetDetials + "_lost") | |
322 | - | [StringEntry(betIndex, updateInfoBet), IntegerEntry(betProceedIndex, lastProceedBet)] | |
54 | + | func getPriceArray () = { | |
55 | + | let currentPrices = match getString(this, lotteryPrices) { | |
56 | + | case a: String => | |
57 | + | a | |
58 | + | case _: Unit => | |
59 | + | "" | |
60 | + | case _ => | |
61 | + | throw("Match error") | |
62 | + | } | |
63 | + | let sizePrices = size(currentPrices) | |
64 | + | if ((sizePrices == 0)) | |
65 | + | then nil | |
66 | + | else { | |
67 | + | let trimPrices = take(currentPrices, (size(currentPrices) - 1)) | |
68 | + | let newArray = split(trimPrices, ",") | |
69 | + | newArray | |
70 | + | } | |
323 | 71 | } | |
324 | 72 | ||
325 | 73 | ||
326 | - | func udpateBetDetailsWithLostWithOdd (updateBetDetials,gameNumber,lastProceedBet,betIndex,betProceedIndex,oddNumber) = { | |
327 | - | let updateInfoBet = ((updateBetDetials + "_lost_") + toString(oddNumber)) | |
328 | - | [StringEntry(betIndex, updateInfoBet), IntegerEntry(betProceedIndex, lastProceedBet)] | |
329 | - | } | |
74 | + | func getCurrentBalance () = if (useGarlicCoin) | |
75 | + | then assetBalance(this, fromBase58String(tokenAssetId)) | |
76 | + | else wavesBalance(this) | |
330 | 77 | ||
331 | 78 | ||
332 | - | func updateBetDetailsWithWinning (updateBetDetials,gameNumber,currentProceedBet,betPlacer,winningAmount,betType,betIndex,betProceedIndex) = { | |
333 | - | let updateInfoBet = (updateBetDetials + "_won_") | |
334 | - | [StringEntry(gameWinningNumberBetLabel(gameNumber, currentProceedBet, betType), ((betPlacer + "_amount_") + toString(winningAmount))), StringEntry(betIndex, updateBetDetials), IntegerEntry(betProceedIndex, currentProceedBet), ScriptTransfer(value(addressFromString(betPlacer)), winningAmount, unit)] | |
335 | - | } | |
336 | - | ||
337 | - | ||
338 | - | func storeGameProgressPointState (storeIndex,gameNumber,number,rollCount,currentHeight,randomHash,state) = [IntegerEntry(gameStateLabel(gameNumber), state), IntegerEntry(storeIndex, number), IntegerEntry(gameRollsCountBetLabel(gameNumber), rollCount), IntegerEntry(gameEndHeightLabel(gameNumber), (currentHeight + BLOCKTOPROCESSFORTHROW)), StringEntry(gameRandomHashLabel(gameNumber), toBase64String(randomHash)), IntegerEntry(gameRollDiceWithGameNumberLabel(gameNumber, rollCount), number)] | |
79 | + | func procedLottery (win,token) = if (if (isDefined(token)) | |
80 | + | then true | |
81 | + | else (token != "")) | |
82 | + | then { | |
83 | + | let tokenProbability = getIntegerValue(this, (token + lotteryprobability)) | |
84 | + | let tokenProbabilityDecimal = getIntegerValue(this, (token + lotteryprobabilitydecimal)) | |
85 | + | let sizeOfWin = size(win) | |
86 | + | if ((sizeOfWin == 1)) | |
87 | + | then { | |
88 | + | let randomNumber = win[0] | |
89 | + | let convertedRandomNumber = fromBase64String(randomNumber) | |
90 | + | let convertedDecimalNumber = (tokenProbabilityDecimal * 1000) | |
91 | + | let comparisonNumber = (toInt(convertedRandomNumber) % convertedDecimalNumber) | |
92 | + | if ((tokenProbability > comparisonNumber)) | |
93 | + | then token :: win | |
94 | + | else win | |
95 | + | } | |
96 | + | else win | |
97 | + | } | |
98 | + | else win | |
339 | 99 | ||
340 | 100 | ||
341 | 101 | @Callable(i) | |
342 | - | func processNextBet () = if (authorizePermission(i.callerPublicKey)) | |
343 | - | then throw("processFieldBet_FORBIDDEN") | |
344 | - | else match getGameTotalBets() { | |
345 | - | case totalBets: Int => | |
346 | - | match getGameProcessedBets() { | |
347 | - | case lastProcessBet: Int => | |
348 | - | let nextBet = (lastProcessBet + 1) | |
349 | - | if ((nextBet > totalBets)) | |
350 | - | then throw("Next bet has not been places.") | |
351 | - | else match getGameBetCounter(nextBet) { | |
352 | - | case gameNumber: Int => | |
353 | - | match getGameState(gameNumber) { | |
354 | - | case gameState: Int => | |
355 | - | if (if ((gameState == GAMESTART)) | |
356 | - | then true | |
357 | - | else (gameState == GAMEINPROGRESS)) | |
358 | - | then throw("Game has to finished in order to process NON-FIELD bets") | |
359 | - | else { | |
360 | - | let betDetails = value(getBetDetailsResult(nextBet)) | |
361 | - | let betType = split(betDetails, "_")[2] | |
362 | - | let betPlacer = split(betDetails, "_")[0] | |
363 | - | let amount = value(parseInt(split(betDetails, "_")[1])) | |
364 | - | let address = value(addressFromString(betPlacer)) | |
365 | - | let currentPoint = getCurrentPointDice(nextBet) | |
366 | - | let firstPoint = getFirstPointDice(nextBet) | |
367 | - | let updateBetDetials = (((((betPlacer + "_") + split(betDetails, "_")[1]) + "_") + split(betDetails, "_")[2]) + "_inactive_") | |
368 | - | if ((betType == PASSLINEBET)) | |
369 | - | then if ((currentPoint == 0)) | |
370 | - | then if (if ((firstPoint == 7)) | |
371 | - | then true | |
372 | - | else (firstPoint == 11)) | |
373 | - | then { | |
374 | - | let winningAmount = (amount * 2) | |
375 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
376 | - | } | |
377 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
378 | - | else if ((firstPoint == currentPoint)) | |
379 | - | then { | |
380 | - | let winningAmount = (amount * 2) | |
381 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
382 | - | } | |
383 | - | else if ((currentPoint == 7)) | |
384 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
385 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
386 | - | else if ((betType == DONTPASSLINEBET)) | |
387 | - | then if ((currentPoint == 0)) | |
388 | - | then if (if ((firstPoint == 2)) | |
389 | - | then true | |
390 | - | else (firstPoint == 3)) | |
391 | - | then { | |
392 | - | let winningAmount = (amount * 2) | |
393 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
394 | - | } | |
395 | - | else if (if ((currentPoint == 7)) | |
396 | - | then true | |
397 | - | else (currentPoint == 11)) | |
398 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
399 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
400 | - | else if (if ((currentPoint == 2)) | |
401 | - | then true | |
402 | - | else (currentPoint == 3)) | |
403 | - | then { | |
404 | - | let winningAmount = (amount * 2) | |
405 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
406 | - | } | |
407 | - | else if ((currentPoint == 7)) | |
408 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
409 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
410 | - | else throw((((((("Only " + PASSLINEBET) + ", ") + DONTPASSLINEBET) + " allowed in processNextBet()") + " currentBetType ") + betType)) | |
411 | - | } | |
412 | - | case _ => | |
413 | - | throw("Game does not exist or has already ended.") | |
414 | - | } | |
415 | - | case _ => | |
416 | - | throw("Error") | |
417 | - | } | |
418 | - | case _ => | |
419 | - | throw("Game has not been initialized, next bets not found") | |
102 | + | func setGarlicCoinLottery () = { | |
103 | + | let balance = getCurrentBalance() | |
104 | + | if ((69 > balance)) | |
105 | + | then throw("Not enought Amount") | |
106 | + | else { | |
107 | + | let storedTokensValues = ((tokenAId + ",") + tokenBId) | |
108 | + | if (useGarlicCoin) | |
109 | + | then { | |
110 | + | let updateLotteryPool = WriteSet([DataEntry((tokenAId + lotteryprobability), 69), DataEntry((tokenAId + lotteryPrice), 69), DataEntry((tokenAId + lotteryprobabilitydecimal), 10000), DataEntry((tokenAId + lotteryAssetId), tokenAssetId), DataEntry((tokenBId + lotteryamount), 6900000000), DataEntry((tokenBId + lotteryprobability), 69), DataEntry((tokenBId + lotteryPrice), 6900000000), DataEntry((tokenBId + lotteryprobabilitydecimal), 1000), DataEntry((tokenBId + lotteryAssetId), tokenAssetId), DataEntry(lotteryPrices, storedTokensValues), DataEntry(countOfPrices, 2)]) | |
111 | + | ScriptResult(updateLotteryPool, TransferSet(nil)) | |
112 | + | } | |
113 | + | else { | |
114 | + | let updateLotteryPool = WriteSet([DataEntry((tokenAId + lotteryprobability), 69), DataEntry((tokenAId + lotteryPrice), 69), DataEntry((tokenAId + lotteryprobabilitydecimal), 10000), DataEntry((tokenAId + lotteryAssetId), ""), DataEntry((tokenBId + lotteryamount), 6900000000), DataEntry((tokenBId + lotteryprobability), 69), DataEntry((tokenBId + lotteryPrice), 6900000000), DataEntry((tokenBId + lotteryprobabilitydecimal), 1000), DataEntry((tokenBId + lotteryAssetId), ""), DataEntry(lotteryPrices, storedTokensValues), DataEntry(countOfPrices, 2)]) | |
115 | + | ScriptResult(updateLotteryPool, TransferSet(nil)) | |
116 | + | } | |
420 | 117 | } | |
421 | - | case _ => | |
422 | - | throw("Game has not been initialized, next bets not found") | |
423 | 118 | } | |
424 | 119 | ||
425 | 120 | ||
426 | 121 | ||
427 | 122 | @Callable(i) | |
428 | - | func processOneRoundBet () = if (authorizePermission(i.callerPublicKey)) | |
429 | - | then throw("processFieldBet_FORBIDDEN") | |
430 | - | else match getGameTotalFieldOrOddsBets() { | |
431 | - | case totalFieldBets: Int => | |
432 | - | match getGameProcessedFieldOrOddsBets() { | |
433 | - | case lastFieldProcessBet: Int => | |
434 | - | let nextBet = (lastFieldProcessBet + 1) | |
435 | - | if ((nextBet > totalFieldBets)) | |
436 | - | then throw("Next Field Bet has not been places.") | |
437 | - | else match getGameFieldOrOddsBetCounter(nextBet) { | |
438 | - | case gameNumber: Int => | |
439 | - | match getGameState(gameNumber) { | |
440 | - | case gameState: Int => | |
441 | - | if ((gameState == GAMESTART)) | |
442 | - | then throw("Game has not started yet") | |
123 | + | func startlotto () = { | |
124 | + | let paymentIsDefined = if (!(isDefined(i.payment))) | |
125 | + | then false | |
126 | + | else true | |
127 | + | if ((paymentIsDefined == true)) | |
128 | + | then { | |
129 | + | let pmt = extract(i.payment) | |
130 | + | if (if ((pmt.assetId != ticketAsset)) | |
131 | + | then true | |
132 | + | else (pmt.amount != tokensPerPlay)) | |
133 | + | then throw("Incorrect asset passed or incorrect quantity passed") | |
134 | + | else { | |
135 | + | let currentKey = toBase58String(i.caller.bytes) | |
136 | + | let randhash = randomizer(i) | |
137 | + | let countTokens = match getInteger(this, countOfPrices) { | |
138 | + | case a: Int => | |
139 | + | a | |
140 | + | case _: Unit => | |
141 | + | 0 | |
142 | + | case _ => | |
143 | + | throw("Match error") | |
144 | + | } | |
145 | + | let priceList = getPriceArray() | |
146 | + | let randNumber = toBase64String(randhash) | |
147 | + | let updNumber = fromBase64String(randNumber) | |
148 | + | let listWinningPrices = [randNumber] | |
149 | + | let winningToken = { | |
150 | + | let $list59415993 = priceList | |
151 | + | let $size59415993 = size($list59415993) | |
152 | + | let $acc059415993 = listWinningPrices | |
153 | + | if (($size59415993 == 0)) | |
154 | + | then $acc059415993 | |
155 | + | else { | |
156 | + | let $acc159415993 = procedLottery($acc059415993, $list59415993[0]) | |
157 | + | if (($size59415993 == 1)) | |
158 | + | then $acc159415993 | |
159 | + | else { | |
160 | + | let $acc259415993 = procedLottery($acc159415993, $list59415993[1]) | |
161 | + | if (($size59415993 == 2)) | |
162 | + | then $acc259415993 | |
443 | 163 | else { | |
444 | - | let betDetails = value(getFieldBetDetailsResult(nextBet)) | |
445 | - | let betType = split(betDetails, "_")[2] | |
446 | - | let betPlacer = split(betDetails, "_")[0] | |
447 | - | let amount = value(parseInt(split(betDetails, "_")[1])) | |
448 | - | let odd = value(parseInt(split(betDetails, "_")[5])) | |
449 | - | let address = value(addressFromString(betPlacer)) | |
450 | - | let betOnRoll = value(getFieldOddsBetForNextDice(nextBet)) | |
451 | - | match getGameRollDiceWithGameNumber(gameNumber, betOnRoll) { | |
452 | - | case resultOfRound: Int => | |
453 | - | let updateBetDetials = (((((betPlacer + "_") + split(betDetails, "_")[1]) + "_") + split(betDetails, "_")[2]) + "_inactive_") | |
454 | - | if ((betType == FIELDBET)) | |
455 | - | then { | |
456 | - | let winningAmount = getWinningAmountForField(amount, resultOfRound) | |
457 | - | if ((winningAmount == 0)) | |
458 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(gameNumber), gameTotalProccedFieldOrOddsBetsLabel) | |
459 | - | else updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
164 | + | let $acc359415993 = procedLottery($acc259415993, $list59415993[2]) | |
165 | + | if (($size59415993 == 3)) | |
166 | + | then $acc359415993 | |
167 | + | else { | |
168 | + | let $acc459415993 = procedLottery($acc359415993, $list59415993[3]) | |
169 | + | if (($size59415993 == 4)) | |
170 | + | then $acc459415993 | |
171 | + | else { | |
172 | + | let $acc559415993 = procedLottery($acc459415993, $list59415993[4]) | |
173 | + | throw("List size exceed 4") | |
460 | 174 | } | |
461 | - | else if ((betType == ODDSBET)) | |
462 | - | then { | |
463 | - | let winningAmount = getWinningAmountForOdds(amount, odd, resultOfRound) | |
464 | - | if ((winningAmount == 0)) | |
465 | - | then updateBetDetailsWithWinning((updateBetDetials + "_won_"), gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
466 | - | else udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
467 | - | } | |
468 | - | else if ((betType == BIG6OR8BET)) | |
469 | - | then if (if ((resultOfRound == 6)) | |
470 | - | then true | |
471 | - | else (resultOfRound == 8)) | |
472 | - | then { | |
473 | - | let winningAmount = (2 * amount) | |
474 | - | updateBetDetailsWithWinning((updateBetDetials + "_won_"), gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
475 | - | } | |
476 | - | else udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
477 | - | else if (if ((betType == PLACEBETBUY)) | |
478 | - | then true | |
479 | - | else (betType == PLACEBETWIN)) | |
480 | - | then if ((resultOfRound == 7)) | |
481 | - | then udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
482 | - | else if ((resultOfRound == odd)) | |
483 | - | then { | |
484 | - | let winningAmount = (amount * 2) | |
485 | - | updateBetDetailsWithWinning((updateBetDetials + "_won_"), gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
486 | - | } | |
487 | - | else storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), betType, betPlacer, odd) | |
488 | - | else if (if ((betType == PLACEBETLAY)) | |
489 | - | then true | |
490 | - | else (betType == PLACEBETLOSE)) | |
491 | - | then if ((resultOfRound == 7)) | |
492 | - | then { | |
493 | - | let winningAmount = (amount * 2) | |
494 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
495 | - | } | |
496 | - | else if ((resultOfRound == odd)) | |
497 | - | then udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
498 | - | else storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), betType, betPlacer, odd) | |
499 | - | else if (if ((betType == COMEBET)) | |
500 | - | then true | |
501 | - | else (betType == DONTCOMEBET)) | |
502 | - | then storeComeDontComeBet(gameState, betDetails, resultOfRound, amount, totalFieldBets, lastFieldProcessBet, betOnRoll, gameNumber, betType, betPlacer, odd) | |
503 | - | else throw("Only Field Type of Bet can be proceed") | |
504 | - | case _ => | |
505 | - | throw("There is no result for this round yet") | |
175 | + | } | |
506 | 176 | } | |
177 | + | } | |
178 | + | } | |
179 | + | } | |
180 | + | let sizeOfWinPrices = size(winningToken) | |
181 | + | if ((sizeOfWinPrices == 1)) | |
182 | + | then { | |
183 | + | let writeSets = WriteSet([DataEntry("message", "<h1>Better luck next time!</h1><br><p>Invite more friends to keep playing!<p>"), DataEntry(lastHashRandomNumber, randNumber)]) | |
184 | + | ScriptResult(writeSets, TransferSet(nil)) | |
185 | + | } | |
186 | + | else { | |
187 | + | let token = winningToken[0] | |
188 | + | let callerAddress = toBase58String(i.caller.bytes) | |
189 | + | let addressBalance = getCurrentBalance() | |
190 | + | if ((addressBalance == 0)) | |
191 | + | then throw("Not Enough Garlic Coin") | |
192 | + | else if ((token == tokenAId)) | |
193 | + | then { | |
194 | + | let lotteryPriceTokenA = match getInteger(this, (tokenAId + lotteryPrice)) { | |
195 | + | case t: Int => | |
196 | + | t | |
197 | + | case _: Unit => | |
198 | + | 0 | |
199 | + | case _ => | |
200 | + | throw("Match error") | |
201 | + | } | |
202 | + | let winningAmount = (lotteryPriceTokenA * addressBalance) | |
203 | + | let writeSets = WriteSet([DataEntry((token + lotteryamount), winningAmount), DataEntry((token + lotteryWinningAddress), callerAddress), DataEntry(lastHashRandomNumber, randNumber), DataEntry("message", (((("<h1>Congratulations you won!</h1><br><p>You have won " + toString(winningAmount)) + " ") + token) + "!<p>"))]) | |
204 | + | if (useGarlicCoin) | |
205 | + | then { | |
206 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, winningAmount, fromBase58String(tokenAssetId))]) | |
207 | + | ScriptResult(writeSets, winTransfer) | |
507 | 208 | } | |
508 | - | case _ => | |
509 | - | throw("Game does not exist or has already ended") | |
510 | - | } | |
511 | - | case _ => | |
512 | - | throw("Error") | |
513 | - | } | |
514 | - | case _ => | |
515 | - | throw("Game has not been initialized, next bets not found") | |
209 | + | else { | |
210 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, winningAmount, unit)]) | |
211 | + | ScriptResult(writeSets, winTransfer) | |
212 | + | } | |
213 | + | } | |
214 | + | else if ((token == tokenBId)) | |
215 | + | then { | |
216 | + | let lotteryPriceTokenB = match getInteger(this, (tokenBId + lotteryprobability)) { | |
217 | + | case t: Int => | |
218 | + | t | |
219 | + | case _: Unit => | |
220 | + | 0 | |
221 | + | case _ => | |
222 | + | throw("Match error") | |
223 | + | } | |
224 | + | let writeSets = WriteSet([DataEntry((token + lotteryamount), lotteryPriceTokenB), DataEntry(lastHashRandomNumber, randNumber), DataEntry((token + lotteryWinningAddress), callerAddress), DataEntry("message", (((("<h1>Congratulations you won!</h1><br><p>You have won " + toString(lotteryPriceTokenB)) + " ") + token) + "!<p>"))]) | |
225 | + | if (useGarlicCoin) | |
226 | + | then { | |
227 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, lotteryPriceTokenB, fromBase58String(tokenAssetId))]) | |
228 | + | ScriptResult(writeSets, winTransfer) | |
229 | + | } | |
230 | + | else { | |
231 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, lotteryPriceTokenB, unit)]) | |
232 | + | ScriptResult(writeSets, winTransfer) | |
233 | + | } | |
234 | + | } | |
235 | + | else { | |
236 | + | let writeSets = WriteSet([DataEntry("message", "<h1>Better luck next time!</h1><br><p>Invite more friends to keep playing!<p>"), DataEntry(lastHashRandomNumber, randNumber)]) | |
237 | + | let winTransfer = TransferSet(nil) | |
238 | + | ScriptResult(writeSets, TransferSet(nil)) | |
239 | + | } | |
240 | + | } | |
241 | + | } | |
516 | 242 | } | |
517 | - | case _ => | |
518 | - | throw("Game has not been initialized, next bets not found") | |
519 | - | } | |
520 | - | ||
521 | - | ||
522 | - | ||
523 | - | @Callable(i) | |
524 | - | func initGame () = if (authorizePermission(i.callerPublicKey)) | |
525 | - | then throw("initGame_FORBIDDEN") | |
526 | - | else match getGameCounter() { | |
527 | - | case counter: Int => | |
528 | - | throw("INIT_ALREADY_DONE") | |
529 | - | case _ => | |
530 | - | [IntegerEntry(gameCounterLabel, 0), IntegerEntry(gameTotalBetsLabel, 0), IntegerEntry(gameTotalProccedBetsLabel, 0), IntegerEntry(gameTotalFieldBetsLabel, 0), IntegerEntry(gameTotalProccedFieldOrOddsBetsLabel, 0)] | |
531 | - | } | |
532 | - | ||
533 | - | ||
534 | - | ||
535 | - | @Callable(i) | |
536 | - | func startGame (randomHash) = if (authorizePermission(i.callerPublicKey)) | |
537 | - | then throw("startGame_FORBIDDEN") | |
538 | - | else match getGameCounter() { | |
539 | - | case number: Int => | |
540 | - | if ((number == 0)) | |
541 | - | then { | |
542 | - | let newNumber = (number + 1) | |
543 | - | [IntegerEntry(gameCounterLabel, newNumber), IntegerEntry(gameStateLabel(newNumber), GAMESTART), IntegerEntry(gameStartHeightLabel(newNumber), lastBlock.height), IntegerEntry(gameEndHeightLabel(newNumber), (lastBlock.height + BLOCKTOPROCESSFORTHROW)), IntegerEntry(gameRollsCountBetLabel(newNumber), 0), StringEntry(gameSumShaLabel(newNumber), toBase58String(sha256(fromBase64String(randomHash))))] | |
544 | - | } | |
545 | - | else match getGameState(number) { | |
546 | - | case state: Int => | |
547 | - | if (if ((state == GAMEINPROGRESS)) | |
548 | - | then true | |
549 | - | else (state == GAMESTART)) | |
550 | - | then throw("The previous game is still in progress") | |
551 | - | else { | |
552 | - | let newNumber = (number + 1) | |
553 | - | [IntegerEntry(gameCounterLabel, newNumber), IntegerEntry(gameStateLabel(newNumber), GAMESTART), IntegerEntry(gameStartHeightLabel(newNumber), lastBlock.height), IntegerEntry(gameEndHeightLabel(newNumber), (lastBlock.height + BLOCKTOPROCESSFORTHROW)), IntegerEntry(gameRollsCountBetLabel(newNumber), 0), StringEntry(gameSumShaLabel(newNumber), toBase58String(sha256(fromBase64String(randomHash))))] | |
554 | - | } | |
555 | - | case _ => | |
556 | - | throw("Error") | |
557 | - | } | |
558 | - | case _ => | |
559 | - | throw("INIT_NEED") | |
560 | - | } | |
561 | - | ||
562 | - | ||
563 | - | ||
564 | - | @Callable(i) | |
565 | - | func placeBet (typeBet) = if (validateBetName(typeBet)) | |
566 | - | then if ((size(i.payments) == 0)) | |
567 | - | then throw("Payment not attached") | |
568 | - | else match getGameCounter() { | |
569 | - | case GAMENUMBER: Int => | |
570 | - | let p = i.payments[0] | |
571 | - | match getGameState(GAMENUMBER) { | |
572 | - | case state: Int => | |
573 | - | if ((state == GAMESTART)) | |
574 | - | then if (if ((typeBet == PASSLINEBET)) | |
575 | - | then true | |
576 | - | else (typeBet == DONTPASSLINEBET)) | |
577 | - | then storePassOrComeBet(GAMENUMBER, toString(p.amount), typeBet, toBase58String(i.caller.bytes)) | |
578 | - | else throw((((((("Only " + PASSLINEBET) + ", ") + DONTPASSLINEBET) + " and ") + FIELDBET) + " are allowed in the Beginning of Game")) | |
579 | - | else if ((state == GAMEINPROGRESS)) | |
580 | - | then throw((((((("Only " + COMEBET) + ", ") + DONTCOMEBET) + " and ") + FIELDBET) + " ARE ALLOWED at Start.")) | |
581 | - | else if ((state == GAMEFINISHED)) | |
582 | - | then throw("Game already ended.") | |
583 | - | else throw("Unknown Game State.") | |
584 | - | case _ => | |
585 | - | throw("Game does not exist or has already ended.") | |
586 | - | } | |
587 | - | case _ => | |
588 | - | throw("Game has not been initialized.") | |
589 | - | } | |
590 | - | else throw(((((((((("Unsupported Type of Bet for Crap. Please Select one of " + PASSLINEBET) + ", ") + DONTPASSLINEBET) + ", ") + COMEBET) + ", ") + DONTCOMEBET) + ", ") + FIELDBET)) | |
591 | - | ||
592 | - | ||
593 | - | ||
594 | - | @Callable(i) | |
595 | - | func placeRoundBet (typeBet,oddNumber) = if (validateRoundBet(typeBet)) | |
596 | - | then if ((size(i.payments) == 0)) | |
597 | - | then throw("Payment not attached") | |
598 | - | else match getGameCounter() { | |
599 | - | case GAMENUMBER: Int => | |
600 | - | let p = i.payments[0] | |
601 | - | match getGameState(GAMENUMBER) { | |
602 | - | case state: Int => | |
603 | - | if ((state == GAMEFINISHED)) | |
604 | - | then throw("Game already ended.") | |
605 | - | else if (if ((typeBet == COMEBET)) | |
606 | - | then true | |
607 | - | else (typeBet == DONTCOMEBET)) | |
608 | - | then if ((state == GAMESTART)) | |
609 | - | then throw("Cannot place COME OR DONTCOME BET IF GAME HAS NOT STARTED") | |
610 | - | else storeOneRoundBetTypes(GAMENUMBER, toString(p.amount), typeBet, toBase58String(i.caller.bytes), 0) | |
611 | - | else storeOneRoundBetTypes(GAMENUMBER, toString(p.amount), typeBet, toBase58String(i.caller.bytes), oddNumber) | |
612 | - | case _ => | |
613 | - | throw("Game does not exist or has already ended.") | |
614 | - | } | |
615 | - | case _ => | |
616 | - | throw("Game has not been initialized.") | |
617 | - | } | |
618 | - | else throw(((((((((("Unsupported Type of Bet for Crap. Please Select one of " + ODDSBET) + ", ") + DONTPASSLINEBET) + ", ") + COMEBET) + ", ") + DONTCOMEBET) + ", ") + FIELDBET)) | |
619 | - | ||
620 | - | ||
621 | - | ||
622 | - | @Callable(i) | |
623 | - | func throwDices (rsaSign,gameNumber) = if (authorizePermission(i.callerPublicKey)) | |
624 | - | then throw("throwDices_FORBIDDEN") | |
625 | - | else match getGameState(gameNumber) { | |
626 | - | case state: Int => | |
627 | - | if ((state == GAMEFINISHED)) | |
628 | - | then throw("Game is finished") | |
629 | - | else { | |
630 | - | let currentHeight = lastBlock.height | |
631 | - | let lastHeightAllowed = value(getEndHeight(gameNumber)) | |
632 | - | if ((currentHeight >= lastHeightAllowed)) | |
633 | - | then match getGameSumSha(gameNumber) { | |
634 | - | case sumSha: String => | |
635 | - | let sig = fromBase64String(rsaSign) | |
636 | - | let rsaSigValid = rsaVerify(SHA256, fromBase58String(sumSha), sig, RSAPUBLIC) | |
637 | - | match blockInfoByHeight((lastBlock.height - 1)) { | |
638 | - | case previousBlock: BlockInfo => | |
639 | - | let randomHash = sha256((take(sig, 4) + take(previousBlock.generationSignature, 8))) | |
640 | - | if (!(rsaSigValid)) | |
641 | - | then throw("INVALID_RSA_SIGN") | |
642 | - | else { | |
643 | - | let randNumber = (toInt(randomHash) % 11) | |
644 | - | let number = diceNumber[randNumber] | |
645 | - | match getGameRollsCount(gameNumber) { | |
646 | - | case rollCountNumber: Int => | |
647 | - | let newRollCountNumber = (rollCountNumber + 1) | |
648 | - | if ((state == GAMESTART)) | |
649 | - | then if (if (if (if (if ((number == 7)) | |
650 | - | then true | |
651 | - | else (number == 11)) | |
652 | - | then true | |
653 | - | else (number == 2)) | |
654 | - | then true | |
655 | - | else (number == 3)) | |
656 | - | then true | |
657 | - | else (number == 12)) | |
658 | - | then storeGameProgressPointState(gameFirstPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEFINISHED) | |
659 | - | else storeGameProgressPointState(gameFirstPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEINPROGRESS) | |
660 | - | else { | |
661 | - | let currentPoint = value(getCurrentPointDice(gameNumber)) | |
662 | - | let firstPoint = value(getFirstPointDice(gameNumber)) | |
663 | - | if ((currentPoint == 0)) | |
664 | - | then if (if ((number == 7)) | |
665 | - | then true | |
666 | - | else (firstPoint == number)) | |
667 | - | then storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEFINISHED) | |
668 | - | else storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEINPROGRESS) | |
669 | - | else if (if ((number == 7)) | |
670 | - | then true | |
671 | - | else (firstPoint == number)) | |
672 | - | then storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEFINISHED) | |
673 | - | else storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEINPROGRESS) | |
674 | - | } | |
675 | - | case _ => | |
676 | - | throw("No dices have been thrown") | |
677 | - | } | |
678 | - | } | |
679 | - | case _ => | |
680 | - | throw("Last block doesn't exist.") | |
681 | - | } | |
682 | - | case _ => | |
683 | - | throw("SHA doesn't exist") | |
684 | - | } | |
685 | - | else throw("Throw dice not allow still waiting for block to process") | |
686 | - | } | |
687 | - | case _ => | |
688 | - | throw("Game does not exist or has already ended.") | |
243 | + | else throw((("You need " + toBase58String(ticketAsset)) + " to play this game.")) | |
689 | 244 | } | |
690 | 245 | ||
691 | 246 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let dAppAddres = "F9DCGiYgT8yvBq1AQFcSpGG4p8sdzNz9mZczDvJ45LL" | |
5 | 5 | ||
6 | - | let | |
6 | + | let ticketAsset = base58'5ih9jd4KV9kSey55yvKMgLSHcwsYYkQ4pRDJtRNoxUhy' | |
7 | 7 | ||
8 | - | let | |
8 | + | let tokenAssetId = "5ih9jd4KV9kSey55yvKMgLSHcwsYYkQ4pRDJtRNoxUhy" | |
9 | 9 | ||
10 | - | let | |
10 | + | let useGarlicCoin = false | |
11 | 11 | ||
12 | - | let | |
12 | + | let tokensPerPlay = 100000000 | |
13 | 13 | ||
14 | - | let | |
14 | + | let lotteryamount = "_amount" | |
15 | 15 | ||
16 | - | let | |
16 | + | let lotteryprobability = "_probability" | |
17 | 17 | ||
18 | - | let | |
18 | + | let lotteryprobabilitydecimal = "_probability_decimal" | |
19 | 19 | ||
20 | - | let | |
20 | + | let lotteryWinningAddress = "_winning_address" | |
21 | 21 | ||
22 | - | let | |
22 | + | let lotteryPrice = "_price" | |
23 | 23 | ||
24 | - | let | |
24 | + | let lotteryPrices = "_lottery_prices" | |
25 | 25 | ||
26 | - | let | |
26 | + | let lotteryAssetId = "_lottery_asset_id" | |
27 | 27 | ||
28 | - | let | |
28 | + | let countOfPrices = "_count_prices" | |
29 | 29 | ||
30 | - | let | |
30 | + | let lastHashRandomNumber = "last_spin_random_hash" | |
31 | 31 | ||
32 | - | let | |
32 | + | let allowSizeLottery = 2 | |
33 | 33 | ||
34 | - | let | |
34 | + | let totalPricesInPool = "total_prizes_pool" | |
35 | 35 | ||
36 | - | let | |
36 | + | let tokenAId = "f2MzwrmN5wiMn5DwbBL33247fdsf432FV9kSe" | |
37 | 37 | ||
38 | - | let | |
38 | + | let tokenBId = "f1MzwrmN4wiMn4DwbBL43242fsdf434Ffsdfs" | |
39 | 39 | ||
40 | - | let PLACEBETWIN = "PLACEBETWIN" | |
41 | - | ||
42 | - | let gameCounterLabel = "G_GAMECOUNTER" | |
43 | - | ||
44 | - | let gameTotalBetsLabel = "G_TOTALBETS" | |
45 | - | ||
46 | - | let gameTotalProccedBetsLabel = "G_PROCESSEDBETS" | |
47 | - | ||
48 | - | let gameTotalFieldBetsLabel = "G_TOTALFIELD_ODDS_BETS" | |
49 | - | ||
50 | - | let gameTotalProccedFieldOrOddsBetsLabel = "G_PROCESSEDFIEL_ODDS_BETS" | |
51 | - | ||
52 | - | func gameStartHeightLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_STARTHEIGHT") | |
53 | - | ||
54 | - | ||
55 | - | func gameEndHeightLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_ENDHEIGHT") | |
56 | - | ||
57 | - | ||
58 | - | func getStartHeight (gameCounter) = getInteger(this, gameStartHeightLabel(gameCounter)) | |
59 | - | ||
60 | - | ||
61 | - | func getEndHeight (gameCounter) = getInteger(this, gameEndHeightLabel(gameCounter)) | |
62 | - | ||
63 | - | ||
64 | - | func gameBetLineLabel (betNumber) = (("B_" + toString(betNumber)) + "_BETDETAILS") | |
65 | - | ||
66 | - | ||
67 | - | func gameFieldOrOddsBetLineLabel (betNumber) = (("B_" + toString(betNumber)) + "_BETFIELODDSDDETAILS") | |
68 | - | ||
69 | - | ||
70 | - | func getBetDetailsResult (betNumber) = getString(this, gameBetLineLabel(betNumber)) | |
71 | - | ||
72 | - | ||
73 | - | func getFieldBetDetailsResult (betNumber) = getString(this, gameFieldOrOddsBetLineLabel(betNumber)) | |
74 | - | ||
75 | - | ||
76 | - | func authorizePermission (callerPublicKey) = (callerPublicKey != gameMasterPublicKey) | |
77 | - | ||
78 | - | ||
79 | - | func gameCurrentPointDiceLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_LASTPOINT") | |
80 | - | ||
81 | - | ||
82 | - | func gameFirstPointDiceLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_FIRSTPOINT") | |
83 | - | ||
84 | - | ||
85 | - | func gameWinningNumberBetLabel (gameCounter,betNumber,betType) = ((((((("W_" + "BET_TYPE_") + betType) + "_") + toString(betNumber)) + "_WINNING_BET_") + toString(gameCounter)) + "_GAME_NUMBER") | |
86 | - | ||
87 | - | ||
88 | - | func gameStateLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_STATE") | |
89 | - | ||
90 | - | ||
91 | - | func gameSumShaLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_SUMSHA") | |
92 | - | ||
93 | - | ||
94 | - | func gameRandomHashLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_RANDOMHASH") | |
95 | - | ||
96 | - | ||
97 | - | func getGameTotalBets () = getInteger(this, gameTotalBetsLabel) | |
98 | - | ||
99 | - | ||
100 | - | func getGameProcessedBets () = getInteger(this, gameTotalProccedBetsLabel) | |
101 | - | ||
102 | - | ||
103 | - | func getGameTotalFieldOrOddsBets () = getInteger(this, gameTotalFieldBetsLabel) | |
104 | - | ||
105 | - | ||
106 | - | func getGameProcessedFieldOrOddsBets () = getInteger(this, gameTotalProccedFieldOrOddsBetsLabel) | |
107 | - | ||
108 | - | ||
109 | - | func getGameState (gameCounter) = getInteger(this, gameStateLabel(gameCounter)) | |
110 | - | ||
111 | - | ||
112 | - | func getGameSumSha (gameCounter) = getString(this, gameSumShaLabel(gameCounter)) | |
113 | - | ||
114 | - | ||
115 | - | func getRandomHash (gameCounter) = getString(this, gameRandomHashLabel(gameCounter)) | |
116 | - | ||
117 | - | ||
118 | - | func gameRollsCountBetLabel (gameCounter) = (("G_" + toString(gameCounter)) + "_ROLLSCOUNT") | |
119 | - | ||
120 | - | ||
121 | - | func gameRollDiceWithGameNumberLabel (gameCounter,rollDice) = (((("G_" + toString(gameCounter)) + "_") + toString(rollDice)) + "_GAMENUMBER_ROLLDICE") | |
122 | - | ||
123 | - | ||
124 | - | func gameFieldOrOddsBetForNextThrowLabel (betNumber) = (("B_" + toString(betNumber)) + "_FIELD_ODDS_BET_ROLLDICE") | |
125 | - | ||
126 | - | ||
127 | - | func getGameRollsCount (gameCounter) = getInteger(this, gameRollsCountBetLabel(gameCounter)) | |
128 | - | ||
129 | - | ||
130 | - | func getGameRollDiceWithGameNumber (gameCounter,rollDice) = getInteger(this, gameRollDiceWithGameNumberLabel(gameCounter, rollDice)) | |
131 | - | ||
132 | - | ||
133 | - | func getFieldOddsBetForNextDice (betNumber) = getInteger(this, gameFieldOrOddsBetForNextThrowLabel(betNumber)) | |
134 | - | ||
135 | - | ||
136 | - | func gameBetCounterLabel (gameNumber) = (("B_" + toString(gameNumber)) + "_BET_GAMENUMBER") | |
137 | - | ||
138 | - | ||
139 | - | func gameFieldOrOddsBetGameCounterLabel (gameNumber) = (("B_" + toString(gameNumber)) + "_FIELD_ODDS_BET_GAMENUMBER") | |
140 | - | ||
141 | - | ||
142 | - | func getGameBetCounter (gameNumber) = getInteger(this, gameBetCounterLabel(gameNumber)) | |
143 | - | ||
144 | - | ||
145 | - | func getGameFieldOrOddsBetCounter (gameNumber) = getInteger(this, gameFieldOrOddsBetGameCounterLabel(gameNumber)) | |
146 | - | ||
147 | - | ||
148 | - | func getGameCounter () = getInteger(this, gameCounterLabel) | |
149 | - | ||
150 | - | ||
151 | - | func getFirstPointDice (gameCounter) = getInteger(this, gameFirstPointDiceLabel(gameCounter)) | |
152 | - | ||
153 | - | ||
154 | - | func getCurrentPointDice (gameCounter) = match getInteger(this, gameCurrentPointDiceLabel(gameCounter)) { | |
155 | - | case val: Int => | |
156 | - | val | |
157 | - | case _ => | |
158 | - | 0 | |
159 | - | } | |
160 | - | ||
161 | - | ||
162 | - | func validateBetName (betName) = if ((betName == PASSLINEBET)) | |
163 | - | then true | |
164 | - | else if ((betName == DONTPASSLINEBET)) | |
165 | - | then true | |
166 | - | else false | |
167 | - | ||
168 | - | ||
169 | - | func validateRoundBet (betName) = if ((betName == FIELDBET)) | |
170 | - | then true | |
171 | - | else if ((betName == ODDSBET)) | |
172 | - | then true | |
173 | - | else if ((betName == BIG6OR8BET)) | |
174 | - | then true | |
175 | - | else if ((betName == PLACEBETBUY)) | |
176 | - | then true | |
177 | - | else if ((betName == PLACEBETLAY)) | |
178 | - | then true | |
179 | - | else if ((betName == COMEBET)) | |
180 | - | then true | |
181 | - | else if ((betName == DONTCOMEBET)) | |
182 | - | then true | |
183 | - | else if ((betName == PLACEBETLOSE)) | |
184 | - | then true | |
185 | - | else if ((betName == PLACEBETWIN)) | |
186 | - | then true | |
187 | - | else false | |
188 | - | ||
189 | - | ||
190 | - | func getWinningAmountForOdds (amount,odd,resultOfRound) = if (if ((odd == 4)) | |
191 | - | then true | |
192 | - | else (odd == 10)) | |
193 | - | then { | |
194 | - | let winningAmount = (amount * 7) | |
195 | - | winningAmount | |
196 | - | } | |
197 | - | else if (if ((odd == 5)) | |
198 | - | then true | |
199 | - | else (odd == 8)) | |
200 | - | then { | |
201 | - | let winningAmount = (amount * 9) | |
202 | - | winningAmount | |
203 | - | } | |
204 | - | else if (if ((odd == 3)) | |
205 | - | then true | |
206 | - | else (odd == 11)) | |
207 | - | then { | |
208 | - | let winningAmount = (amount * 15) | |
209 | - | winningAmount | |
210 | - | } | |
211 | - | else if (if ((odd == 2)) | |
212 | - | then true | |
213 | - | else (odd == 12)) | |
214 | - | then { | |
215 | - | let winningAmount = (amount * 30) | |
216 | - | winningAmount | |
217 | - | } | |
218 | - | else if (if ((odd == 10)) | |
219 | - | then true | |
220 | - | else (odd == 4)) | |
221 | - | then { | |
222 | - | let winningAmount = (amount * 30) | |
223 | - | winningAmount | |
224 | - | } | |
225 | - | else if ((odd == 7)) | |
226 | - | then { | |
227 | - | let winningAmount = (amount * 4) | |
228 | - | winningAmount | |
229 | - | } | |
230 | - | else if (if ((odd == 100)) | |
231 | - | then if (if ((resultOfRound == 3)) | |
232 | - | then true | |
233 | - | else (resultOfRound == 12)) | |
234 | - | then true | |
235 | - | else (resultOfRound == 2) | |
236 | - | else false) | |
237 | - | then { | |
238 | - | let winningAmount = (amount * 7) | |
239 | - | winningAmount | |
240 | - | } | |
241 | - | else 0 | |
242 | - | ||
243 | - | ||
244 | - | func getWinningAmountForField (amount,resultOfRound) = if ((resultOfRound == 12)) | |
245 | - | then { | |
246 | - | let winningAmount = (amount * 4) | |
247 | - | winningAmount | |
248 | - | } | |
249 | - | else if ((resultOfRound == 2)) | |
250 | - | then { | |
251 | - | let winningAmount = (amount * 3) | |
252 | - | winningAmount | |
253 | - | } | |
254 | - | else if (if (if (if ((resultOfRound == 5)) | |
255 | - | then true | |
256 | - | else (resultOfRound == 6)) | |
257 | - | then true | |
258 | - | else (resultOfRound == 7)) | |
259 | - | then true | |
260 | - | else (resultOfRound == 8)) | |
261 | - | then 0 | |
262 | - | else { | |
263 | - | let winningAmount = (amount * 2) | |
264 | - | winningAmount | |
265 | - | } | |
266 | - | ||
267 | - | ||
268 | - | func storeOneRoundBetTypes (gameCounter,amount,typeBet,caller,odd) = match getGameTotalFieldOrOddsBets() { | |
269 | - | case betCount: Int => | |
270 | - | match getGameRollsCount(gameCounter) { | |
271 | - | case rollCount: Int => | |
272 | - | let newTotalBetCount = (betCount + 1) | |
273 | - | let newRollCountForGame = (rollCount + 1) | |
274 | - | if (if ((typeBet == COMEBET)) | |
275 | - | then true | |
276 | - | else (typeBet == DONTCOMEBET)) | |
277 | - | then [IntegerEntry(gameFieldOrOddsBetGameCounterLabel(newTotalBetCount), gameCounter), StringEntry(gameFieldOrOddsBetLineLabel(newTotalBetCount), ((((((((caller + "_") + amount) + "_") + typeBet) + "_active_pending_") + toString(gameCounter)) + "_") + toString(newRollCountForGame))), IntegerEntry(gameTotalFieldBetsLabel, newTotalBetCount), IntegerEntry(gameFieldOrOddsBetForNextThrowLabel(newTotalBetCount), newRollCountForGame)] | |
278 | - | else [IntegerEntry(gameFieldOrOddsBetGameCounterLabel(newTotalBetCount), gameCounter), StringEntry(gameFieldOrOddsBetLineLabel(newTotalBetCount), ((((((caller + "_") + amount) + "_") + typeBet) + "_active_pending_") + toString(odd))), IntegerEntry(gameTotalFieldBetsLabel, newTotalBetCount), IntegerEntry(gameFieldOrOddsBetForNextThrowLabel(newTotalBetCount), newRollCountForGame)] | |
279 | - | case _ => | |
280 | - | throw("Game doesn't exist") | |
281 | - | } | |
282 | - | case _ => | |
283 | - | throw("Game has not bee initialized") | |
284 | - | } | |
285 | - | ||
286 | - | ||
287 | - | func rollPlaceBetIntoAnotherRoundBet (totalBets,lastFieldProcessBet,betOnRoll,gameCounter,amount,typeBet,caller,odd) = [IntegerEntry(gameFieldOrOddsBetGameCounterLabel(totalBets), gameCounter), StringEntry(gameFieldOrOddsBetLineLabel(totalBets), ((((((caller + "_") + amount) + "_") + typeBet) + "_active_pending_") + toString(odd))), StringEntry(gameFieldOrOddsBetLineLabel(lastFieldProcessBet), ((((((caller + "_") + amount) + "_") + typeBet) + "_inactive_rolled_") + toString(odd))), IntegerEntry(gameTotalProccedFieldOrOddsBetsLabel, lastFieldProcessBet), IntegerEntry(gameTotalFieldBetsLabel, totalBets), IntegerEntry(gameFieldOrOddsBetForNextThrowLabel(totalBets), betOnRoll)] | |
288 | - | ||
289 | - | ||
290 | - | func storeNextRoll (gameState,amount,totalFieldBets,lastFieldProcessBet,betOnRoll,gameNumber,betType,betPlacer,odd) = if ((gameState == GAMEFINISHED)) | |
291 | - | then rollPlaceBetIntoAnotherRoundBet((totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), toString(amount), betType, betPlacer, odd) | |
292 | - | else rollPlaceBetIntoAnotherRoundBet((totalFieldBets + 1), (lastFieldProcessBet + 1), (betOnRoll + 1), gameNumber, toString(amount), betType, betPlacer, odd) | |
293 | - | ||
294 | - | ||
295 | - | func storeComeDontComeBet (gameState,betDetails,resultOfRound,amount,totalFieldBets,lastFieldProcessBet,betOnRoll,gameNumber,betType,betPlacer,odd) = { | |
296 | - | let comeBetGameNumber = value(parseInt(split(betDetails, "_")[5])) | |
297 | - | let comeBetRollNumber = value(parseInt(split(betDetails, "_")[6])) | |
298 | - | let resultOfGame = value(getGameRollDiceWithGameNumber(comeBetGameNumber, comeBetRollNumber)) | |
299 | - | if ((resultOfRound == 7)) | |
300 | - | then if ((betDetails == COMEBET)) | |
301 | - | then throw("Only Field Type of Bet can be proceed") | |
302 | - | else throw("Only Field Type of Bet can be proceed") | |
303 | - | else if ((resultOfRound == resultOfGame)) | |
304 | - | then throw("Only Field Type of Bet can be proceed") | |
305 | - | else if ((gameState == GAMEFINISHED)) | |
306 | - | then storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), betType, betPlacer, odd) | |
307 | - | else storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), (betOnRoll + 1), gameNumber, betType, betPlacer, odd) | |
40 | + | func randomizer (inv) = { | |
41 | + | let lastPlay = match getBinary(this, lastHashRandomNumber) { | |
42 | + | case s: ByteVector => | |
43 | + | s | |
44 | + | case _: Unit => | |
45 | + | base58'2ee4oFDYriWJ9EMeR' | |
46 | + | case _ => | |
47 | + | throw("Match error") | |
48 | + | } | |
49 | + | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
50 | + | sha256(rand) | |
308 | 51 | } | |
309 | 52 | ||
310 | 53 | ||
311 | - | func storePassOrComeBet (gameCounter,amount,typeBet,caller) = match getGameTotalBets() { | |
312 | - | case number: Int => | |
313 | - | let newTotalBets = (number + 1) | |
314 | - | [IntegerEntry(gameBetCounterLabel(newTotalBets), gameCounter), StringEntry(gameBetLineLabel(newTotalBets), (((((caller + "_") + amount) + "_") + typeBet) + "_active_pending")), IntegerEntry(gameTotalBetsLabel, newTotalBets)] | |
315 | - | case _ => | |
316 | - | throw("Game has not bee initialized") | |
317 | - | } | |
318 | - | ||
319 | - | ||
320 | - | func udpateBetDetailsWithLost (updateBetDetials,gameNumber,lastProceedBet,betIndex,betProceedIndex) = { | |
321 | - | let updateInfoBet = (updateBetDetials + "_lost") | |
322 | - | [StringEntry(betIndex, updateInfoBet), IntegerEntry(betProceedIndex, lastProceedBet)] | |
54 | + | func getPriceArray () = { | |
55 | + | let currentPrices = match getString(this, lotteryPrices) { | |
56 | + | case a: String => | |
57 | + | a | |
58 | + | case _: Unit => | |
59 | + | "" | |
60 | + | case _ => | |
61 | + | throw("Match error") | |
62 | + | } | |
63 | + | let sizePrices = size(currentPrices) | |
64 | + | if ((sizePrices == 0)) | |
65 | + | then nil | |
66 | + | else { | |
67 | + | let trimPrices = take(currentPrices, (size(currentPrices) - 1)) | |
68 | + | let newArray = split(trimPrices, ",") | |
69 | + | newArray | |
70 | + | } | |
323 | 71 | } | |
324 | 72 | ||
325 | 73 | ||
326 | - | func udpateBetDetailsWithLostWithOdd (updateBetDetials,gameNumber,lastProceedBet,betIndex,betProceedIndex,oddNumber) = { | |
327 | - | let updateInfoBet = ((updateBetDetials + "_lost_") + toString(oddNumber)) | |
328 | - | [StringEntry(betIndex, updateInfoBet), IntegerEntry(betProceedIndex, lastProceedBet)] | |
329 | - | } | |
74 | + | func getCurrentBalance () = if (useGarlicCoin) | |
75 | + | then assetBalance(this, fromBase58String(tokenAssetId)) | |
76 | + | else wavesBalance(this) | |
330 | 77 | ||
331 | 78 | ||
332 | - | func updateBetDetailsWithWinning (updateBetDetials,gameNumber,currentProceedBet,betPlacer,winningAmount,betType,betIndex,betProceedIndex) = { | |
333 | - | let updateInfoBet = (updateBetDetials + "_won_") | |
334 | - | [StringEntry(gameWinningNumberBetLabel(gameNumber, currentProceedBet, betType), ((betPlacer + "_amount_") + toString(winningAmount))), StringEntry(betIndex, updateBetDetials), IntegerEntry(betProceedIndex, currentProceedBet), ScriptTransfer(value(addressFromString(betPlacer)), winningAmount, unit)] | |
335 | - | } | |
336 | - | ||
337 | - | ||
338 | - | func storeGameProgressPointState (storeIndex,gameNumber,number,rollCount,currentHeight,randomHash,state) = [IntegerEntry(gameStateLabel(gameNumber), state), IntegerEntry(storeIndex, number), IntegerEntry(gameRollsCountBetLabel(gameNumber), rollCount), IntegerEntry(gameEndHeightLabel(gameNumber), (currentHeight + BLOCKTOPROCESSFORTHROW)), StringEntry(gameRandomHashLabel(gameNumber), toBase64String(randomHash)), IntegerEntry(gameRollDiceWithGameNumberLabel(gameNumber, rollCount), number)] | |
79 | + | func procedLottery (win,token) = if (if (isDefined(token)) | |
80 | + | then true | |
81 | + | else (token != "")) | |
82 | + | then { | |
83 | + | let tokenProbability = getIntegerValue(this, (token + lotteryprobability)) | |
84 | + | let tokenProbabilityDecimal = getIntegerValue(this, (token + lotteryprobabilitydecimal)) | |
85 | + | let sizeOfWin = size(win) | |
86 | + | if ((sizeOfWin == 1)) | |
87 | + | then { | |
88 | + | let randomNumber = win[0] | |
89 | + | let convertedRandomNumber = fromBase64String(randomNumber) | |
90 | + | let convertedDecimalNumber = (tokenProbabilityDecimal * 1000) | |
91 | + | let comparisonNumber = (toInt(convertedRandomNumber) % convertedDecimalNumber) | |
92 | + | if ((tokenProbability > comparisonNumber)) | |
93 | + | then token :: win | |
94 | + | else win | |
95 | + | } | |
96 | + | else win | |
97 | + | } | |
98 | + | else win | |
339 | 99 | ||
340 | 100 | ||
341 | 101 | @Callable(i) | |
342 | - | func processNextBet () = if (authorizePermission(i.callerPublicKey)) | |
343 | - | then throw("processFieldBet_FORBIDDEN") | |
344 | - | else match getGameTotalBets() { | |
345 | - | case totalBets: Int => | |
346 | - | match getGameProcessedBets() { | |
347 | - | case lastProcessBet: Int => | |
348 | - | let nextBet = (lastProcessBet + 1) | |
349 | - | if ((nextBet > totalBets)) | |
350 | - | then throw("Next bet has not been places.") | |
351 | - | else match getGameBetCounter(nextBet) { | |
352 | - | case gameNumber: Int => | |
353 | - | match getGameState(gameNumber) { | |
354 | - | case gameState: Int => | |
355 | - | if (if ((gameState == GAMESTART)) | |
356 | - | then true | |
357 | - | else (gameState == GAMEINPROGRESS)) | |
358 | - | then throw("Game has to finished in order to process NON-FIELD bets") | |
359 | - | else { | |
360 | - | let betDetails = value(getBetDetailsResult(nextBet)) | |
361 | - | let betType = split(betDetails, "_")[2] | |
362 | - | let betPlacer = split(betDetails, "_")[0] | |
363 | - | let amount = value(parseInt(split(betDetails, "_")[1])) | |
364 | - | let address = value(addressFromString(betPlacer)) | |
365 | - | let currentPoint = getCurrentPointDice(nextBet) | |
366 | - | let firstPoint = getFirstPointDice(nextBet) | |
367 | - | let updateBetDetials = (((((betPlacer + "_") + split(betDetails, "_")[1]) + "_") + split(betDetails, "_")[2]) + "_inactive_") | |
368 | - | if ((betType == PASSLINEBET)) | |
369 | - | then if ((currentPoint == 0)) | |
370 | - | then if (if ((firstPoint == 7)) | |
371 | - | then true | |
372 | - | else (firstPoint == 11)) | |
373 | - | then { | |
374 | - | let winningAmount = (amount * 2) | |
375 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
376 | - | } | |
377 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
378 | - | else if ((firstPoint == currentPoint)) | |
379 | - | then { | |
380 | - | let winningAmount = (amount * 2) | |
381 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
382 | - | } | |
383 | - | else if ((currentPoint == 7)) | |
384 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
385 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
386 | - | else if ((betType == DONTPASSLINEBET)) | |
387 | - | then if ((currentPoint == 0)) | |
388 | - | then if (if ((firstPoint == 2)) | |
389 | - | then true | |
390 | - | else (firstPoint == 3)) | |
391 | - | then { | |
392 | - | let winningAmount = (amount * 2) | |
393 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
394 | - | } | |
395 | - | else if (if ((currentPoint == 7)) | |
396 | - | then true | |
397 | - | else (currentPoint == 11)) | |
398 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
399 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
400 | - | else if (if ((currentPoint == 2)) | |
401 | - | then true | |
402 | - | else (currentPoint == 3)) | |
403 | - | then { | |
404 | - | let winningAmount = (amount * 2) | |
405 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
406 | - | } | |
407 | - | else if ((currentPoint == 7)) | |
408 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
409 | - | else udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameBetLineLabel(nextBet), gameTotalProccedBetsLabel) | |
410 | - | else throw((((((("Only " + PASSLINEBET) + ", ") + DONTPASSLINEBET) + " allowed in processNextBet()") + " currentBetType ") + betType)) | |
411 | - | } | |
412 | - | case _ => | |
413 | - | throw("Game does not exist or has already ended.") | |
414 | - | } | |
415 | - | case _ => | |
416 | - | throw("Error") | |
417 | - | } | |
418 | - | case _ => | |
419 | - | throw("Game has not been initialized, next bets not found") | |
102 | + | func setGarlicCoinLottery () = { | |
103 | + | let balance = getCurrentBalance() | |
104 | + | if ((69 > balance)) | |
105 | + | then throw("Not enought Amount") | |
106 | + | else { | |
107 | + | let storedTokensValues = ((tokenAId + ",") + tokenBId) | |
108 | + | if (useGarlicCoin) | |
109 | + | then { | |
110 | + | let updateLotteryPool = WriteSet([DataEntry((tokenAId + lotteryprobability), 69), DataEntry((tokenAId + lotteryPrice), 69), DataEntry((tokenAId + lotteryprobabilitydecimal), 10000), DataEntry((tokenAId + lotteryAssetId), tokenAssetId), DataEntry((tokenBId + lotteryamount), 6900000000), DataEntry((tokenBId + lotteryprobability), 69), DataEntry((tokenBId + lotteryPrice), 6900000000), DataEntry((tokenBId + lotteryprobabilitydecimal), 1000), DataEntry((tokenBId + lotteryAssetId), tokenAssetId), DataEntry(lotteryPrices, storedTokensValues), DataEntry(countOfPrices, 2)]) | |
111 | + | ScriptResult(updateLotteryPool, TransferSet(nil)) | |
112 | + | } | |
113 | + | else { | |
114 | + | let updateLotteryPool = WriteSet([DataEntry((tokenAId + lotteryprobability), 69), DataEntry((tokenAId + lotteryPrice), 69), DataEntry((tokenAId + lotteryprobabilitydecimal), 10000), DataEntry((tokenAId + lotteryAssetId), ""), DataEntry((tokenBId + lotteryamount), 6900000000), DataEntry((tokenBId + lotteryprobability), 69), DataEntry((tokenBId + lotteryPrice), 6900000000), DataEntry((tokenBId + lotteryprobabilitydecimal), 1000), DataEntry((tokenBId + lotteryAssetId), ""), DataEntry(lotteryPrices, storedTokensValues), DataEntry(countOfPrices, 2)]) | |
115 | + | ScriptResult(updateLotteryPool, TransferSet(nil)) | |
116 | + | } | |
420 | 117 | } | |
421 | - | case _ => | |
422 | - | throw("Game has not been initialized, next bets not found") | |
423 | 118 | } | |
424 | 119 | ||
425 | 120 | ||
426 | 121 | ||
427 | 122 | @Callable(i) | |
428 | - | func processOneRoundBet () = if (authorizePermission(i.callerPublicKey)) | |
429 | - | then throw("processFieldBet_FORBIDDEN") | |
430 | - | else match getGameTotalFieldOrOddsBets() { | |
431 | - | case totalFieldBets: Int => | |
432 | - | match getGameProcessedFieldOrOddsBets() { | |
433 | - | case lastFieldProcessBet: Int => | |
434 | - | let nextBet = (lastFieldProcessBet + 1) | |
435 | - | if ((nextBet > totalFieldBets)) | |
436 | - | then throw("Next Field Bet has not been places.") | |
437 | - | else match getGameFieldOrOddsBetCounter(nextBet) { | |
438 | - | case gameNumber: Int => | |
439 | - | match getGameState(gameNumber) { | |
440 | - | case gameState: Int => | |
441 | - | if ((gameState == GAMESTART)) | |
442 | - | then throw("Game has not started yet") | |
123 | + | func startlotto () = { | |
124 | + | let paymentIsDefined = if (!(isDefined(i.payment))) | |
125 | + | then false | |
126 | + | else true | |
127 | + | if ((paymentIsDefined == true)) | |
128 | + | then { | |
129 | + | let pmt = extract(i.payment) | |
130 | + | if (if ((pmt.assetId != ticketAsset)) | |
131 | + | then true | |
132 | + | else (pmt.amount != tokensPerPlay)) | |
133 | + | then throw("Incorrect asset passed or incorrect quantity passed") | |
134 | + | else { | |
135 | + | let currentKey = toBase58String(i.caller.bytes) | |
136 | + | let randhash = randomizer(i) | |
137 | + | let countTokens = match getInteger(this, countOfPrices) { | |
138 | + | case a: Int => | |
139 | + | a | |
140 | + | case _: Unit => | |
141 | + | 0 | |
142 | + | case _ => | |
143 | + | throw("Match error") | |
144 | + | } | |
145 | + | let priceList = getPriceArray() | |
146 | + | let randNumber = toBase64String(randhash) | |
147 | + | let updNumber = fromBase64String(randNumber) | |
148 | + | let listWinningPrices = [randNumber] | |
149 | + | let winningToken = { | |
150 | + | let $list59415993 = priceList | |
151 | + | let $size59415993 = size($list59415993) | |
152 | + | let $acc059415993 = listWinningPrices | |
153 | + | if (($size59415993 == 0)) | |
154 | + | then $acc059415993 | |
155 | + | else { | |
156 | + | let $acc159415993 = procedLottery($acc059415993, $list59415993[0]) | |
157 | + | if (($size59415993 == 1)) | |
158 | + | then $acc159415993 | |
159 | + | else { | |
160 | + | let $acc259415993 = procedLottery($acc159415993, $list59415993[1]) | |
161 | + | if (($size59415993 == 2)) | |
162 | + | then $acc259415993 | |
443 | 163 | else { | |
444 | - | let betDetails = value(getFieldBetDetailsResult(nextBet)) | |
445 | - | let betType = split(betDetails, "_")[2] | |
446 | - | let betPlacer = split(betDetails, "_")[0] | |
447 | - | let amount = value(parseInt(split(betDetails, "_")[1])) | |
448 | - | let odd = value(parseInt(split(betDetails, "_")[5])) | |
449 | - | let address = value(addressFromString(betPlacer)) | |
450 | - | let betOnRoll = value(getFieldOddsBetForNextDice(nextBet)) | |
451 | - | match getGameRollDiceWithGameNumber(gameNumber, betOnRoll) { | |
452 | - | case resultOfRound: Int => | |
453 | - | let updateBetDetials = (((((betPlacer + "_") + split(betDetails, "_")[1]) + "_") + split(betDetails, "_")[2]) + "_inactive_") | |
454 | - | if ((betType == FIELDBET)) | |
455 | - | then { | |
456 | - | let winningAmount = getWinningAmountForField(amount, resultOfRound) | |
457 | - | if ((winningAmount == 0)) | |
458 | - | then udpateBetDetailsWithLost(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(gameNumber), gameTotalProccedFieldOrOddsBetsLabel) | |
459 | - | else updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
164 | + | let $acc359415993 = procedLottery($acc259415993, $list59415993[2]) | |
165 | + | if (($size59415993 == 3)) | |
166 | + | then $acc359415993 | |
167 | + | else { | |
168 | + | let $acc459415993 = procedLottery($acc359415993, $list59415993[3]) | |
169 | + | if (($size59415993 == 4)) | |
170 | + | then $acc459415993 | |
171 | + | else { | |
172 | + | let $acc559415993 = procedLottery($acc459415993, $list59415993[4]) | |
173 | + | throw("List size exceed 4") | |
460 | 174 | } | |
461 | - | else if ((betType == ODDSBET)) | |
462 | - | then { | |
463 | - | let winningAmount = getWinningAmountForOdds(amount, odd, resultOfRound) | |
464 | - | if ((winningAmount == 0)) | |
465 | - | then updateBetDetailsWithWinning((updateBetDetials + "_won_"), gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
466 | - | else udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
467 | - | } | |
468 | - | else if ((betType == BIG6OR8BET)) | |
469 | - | then if (if ((resultOfRound == 6)) | |
470 | - | then true | |
471 | - | else (resultOfRound == 8)) | |
472 | - | then { | |
473 | - | let winningAmount = (2 * amount) | |
474 | - | updateBetDetailsWithWinning((updateBetDetials + "_won_"), gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
475 | - | } | |
476 | - | else udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
477 | - | else if (if ((betType == PLACEBETBUY)) | |
478 | - | then true | |
479 | - | else (betType == PLACEBETWIN)) | |
480 | - | then if ((resultOfRound == 7)) | |
481 | - | then udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
482 | - | else if ((resultOfRound == odd)) | |
483 | - | then { | |
484 | - | let winningAmount = (amount * 2) | |
485 | - | updateBetDetailsWithWinning((updateBetDetials + "_won_"), gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
486 | - | } | |
487 | - | else storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), betType, betPlacer, odd) | |
488 | - | else if (if ((betType == PLACEBETLAY)) | |
489 | - | then true | |
490 | - | else (betType == PLACEBETLOSE)) | |
491 | - | then if ((resultOfRound == 7)) | |
492 | - | then { | |
493 | - | let winningAmount = (amount * 2) | |
494 | - | updateBetDetailsWithWinning(updateBetDetials, gameNumber, nextBet, betPlacer, winningAmount, betType, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel) | |
495 | - | } | |
496 | - | else if ((resultOfRound == odd)) | |
497 | - | then udpateBetDetailsWithLostWithOdd(updateBetDetials, gameNumber, nextBet, gameFieldOrOddsBetLineLabel(nextBet), gameTotalProccedFieldOrOddsBetsLabel, odd) | |
498 | - | else storeNextRoll(gameState, amount, (totalFieldBets + 1), (lastFieldProcessBet + 1), 1, (gameNumber + 1), betType, betPlacer, odd) | |
499 | - | else if (if ((betType == COMEBET)) | |
500 | - | then true | |
501 | - | else (betType == DONTCOMEBET)) | |
502 | - | then storeComeDontComeBet(gameState, betDetails, resultOfRound, amount, totalFieldBets, lastFieldProcessBet, betOnRoll, gameNumber, betType, betPlacer, odd) | |
503 | - | else throw("Only Field Type of Bet can be proceed") | |
504 | - | case _ => | |
505 | - | throw("There is no result for this round yet") | |
175 | + | } | |
506 | 176 | } | |
177 | + | } | |
178 | + | } | |
179 | + | } | |
180 | + | let sizeOfWinPrices = size(winningToken) | |
181 | + | if ((sizeOfWinPrices == 1)) | |
182 | + | then { | |
183 | + | let writeSets = WriteSet([DataEntry("message", "<h1>Better luck next time!</h1><br><p>Invite more friends to keep playing!<p>"), DataEntry(lastHashRandomNumber, randNumber)]) | |
184 | + | ScriptResult(writeSets, TransferSet(nil)) | |
185 | + | } | |
186 | + | else { | |
187 | + | let token = winningToken[0] | |
188 | + | let callerAddress = toBase58String(i.caller.bytes) | |
189 | + | let addressBalance = getCurrentBalance() | |
190 | + | if ((addressBalance == 0)) | |
191 | + | then throw("Not Enough Garlic Coin") | |
192 | + | else if ((token == tokenAId)) | |
193 | + | then { | |
194 | + | let lotteryPriceTokenA = match getInteger(this, (tokenAId + lotteryPrice)) { | |
195 | + | case t: Int => | |
196 | + | t | |
197 | + | case _: Unit => | |
198 | + | 0 | |
199 | + | case _ => | |
200 | + | throw("Match error") | |
201 | + | } | |
202 | + | let winningAmount = (lotteryPriceTokenA * addressBalance) | |
203 | + | let writeSets = WriteSet([DataEntry((token + lotteryamount), winningAmount), DataEntry((token + lotteryWinningAddress), callerAddress), DataEntry(lastHashRandomNumber, randNumber), DataEntry("message", (((("<h1>Congratulations you won!</h1><br><p>You have won " + toString(winningAmount)) + " ") + token) + "!<p>"))]) | |
204 | + | if (useGarlicCoin) | |
205 | + | then { | |
206 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, winningAmount, fromBase58String(tokenAssetId))]) | |
207 | + | ScriptResult(writeSets, winTransfer) | |
507 | 208 | } | |
508 | - | case _ => | |
509 | - | throw("Game does not exist or has already ended") | |
510 | - | } | |
511 | - | case _ => | |
512 | - | throw("Error") | |
513 | - | } | |
514 | - | case _ => | |
515 | - | throw("Game has not been initialized, next bets not found") | |
209 | + | else { | |
210 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, winningAmount, unit)]) | |
211 | + | ScriptResult(writeSets, winTransfer) | |
212 | + | } | |
213 | + | } | |
214 | + | else if ((token == tokenBId)) | |
215 | + | then { | |
216 | + | let lotteryPriceTokenB = match getInteger(this, (tokenBId + lotteryprobability)) { | |
217 | + | case t: Int => | |
218 | + | t | |
219 | + | case _: Unit => | |
220 | + | 0 | |
221 | + | case _ => | |
222 | + | throw("Match error") | |
223 | + | } | |
224 | + | let writeSets = WriteSet([DataEntry((token + lotteryamount), lotteryPriceTokenB), DataEntry(lastHashRandomNumber, randNumber), DataEntry((token + lotteryWinningAddress), callerAddress), DataEntry("message", (((("<h1>Congratulations you won!</h1><br><p>You have won " + toString(lotteryPriceTokenB)) + " ") + token) + "!<p>"))]) | |
225 | + | if (useGarlicCoin) | |
226 | + | then { | |
227 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, lotteryPriceTokenB, fromBase58String(tokenAssetId))]) | |
228 | + | ScriptResult(writeSets, winTransfer) | |
229 | + | } | |
230 | + | else { | |
231 | + | let winTransfer = TransferSet([ScriptTransfer(i.caller, lotteryPriceTokenB, unit)]) | |
232 | + | ScriptResult(writeSets, winTransfer) | |
233 | + | } | |
234 | + | } | |
235 | + | else { | |
236 | + | let writeSets = WriteSet([DataEntry("message", "<h1>Better luck next time!</h1><br><p>Invite more friends to keep playing!<p>"), DataEntry(lastHashRandomNumber, randNumber)]) | |
237 | + | let winTransfer = TransferSet(nil) | |
238 | + | ScriptResult(writeSets, TransferSet(nil)) | |
239 | + | } | |
240 | + | } | |
241 | + | } | |
516 | 242 | } | |
517 | - | case _ => | |
518 | - | throw("Game has not been initialized, next bets not found") | |
519 | - | } | |
520 | - | ||
521 | - | ||
522 | - | ||
523 | - | @Callable(i) | |
524 | - | func initGame () = if (authorizePermission(i.callerPublicKey)) | |
525 | - | then throw("initGame_FORBIDDEN") | |
526 | - | else match getGameCounter() { | |
527 | - | case counter: Int => | |
528 | - | throw("INIT_ALREADY_DONE") | |
529 | - | case _ => | |
530 | - | [IntegerEntry(gameCounterLabel, 0), IntegerEntry(gameTotalBetsLabel, 0), IntegerEntry(gameTotalProccedBetsLabel, 0), IntegerEntry(gameTotalFieldBetsLabel, 0), IntegerEntry(gameTotalProccedFieldOrOddsBetsLabel, 0)] | |
531 | - | } | |
532 | - | ||
533 | - | ||
534 | - | ||
535 | - | @Callable(i) | |
536 | - | func startGame (randomHash) = if (authorizePermission(i.callerPublicKey)) | |
537 | - | then throw("startGame_FORBIDDEN") | |
538 | - | else match getGameCounter() { | |
539 | - | case number: Int => | |
540 | - | if ((number == 0)) | |
541 | - | then { | |
542 | - | let newNumber = (number + 1) | |
543 | - | [IntegerEntry(gameCounterLabel, newNumber), IntegerEntry(gameStateLabel(newNumber), GAMESTART), IntegerEntry(gameStartHeightLabel(newNumber), lastBlock.height), IntegerEntry(gameEndHeightLabel(newNumber), (lastBlock.height + BLOCKTOPROCESSFORTHROW)), IntegerEntry(gameRollsCountBetLabel(newNumber), 0), StringEntry(gameSumShaLabel(newNumber), toBase58String(sha256(fromBase64String(randomHash))))] | |
544 | - | } | |
545 | - | else match getGameState(number) { | |
546 | - | case state: Int => | |
547 | - | if (if ((state == GAMEINPROGRESS)) | |
548 | - | then true | |
549 | - | else (state == GAMESTART)) | |
550 | - | then throw("The previous game is still in progress") | |
551 | - | else { | |
552 | - | let newNumber = (number + 1) | |
553 | - | [IntegerEntry(gameCounterLabel, newNumber), IntegerEntry(gameStateLabel(newNumber), GAMESTART), IntegerEntry(gameStartHeightLabel(newNumber), lastBlock.height), IntegerEntry(gameEndHeightLabel(newNumber), (lastBlock.height + BLOCKTOPROCESSFORTHROW)), IntegerEntry(gameRollsCountBetLabel(newNumber), 0), StringEntry(gameSumShaLabel(newNumber), toBase58String(sha256(fromBase64String(randomHash))))] | |
554 | - | } | |
555 | - | case _ => | |
556 | - | throw("Error") | |
557 | - | } | |
558 | - | case _ => | |
559 | - | throw("INIT_NEED") | |
560 | - | } | |
561 | - | ||
562 | - | ||
563 | - | ||
564 | - | @Callable(i) | |
565 | - | func placeBet (typeBet) = if (validateBetName(typeBet)) | |
566 | - | then if ((size(i.payments) == 0)) | |
567 | - | then throw("Payment not attached") | |
568 | - | else match getGameCounter() { | |
569 | - | case GAMENUMBER: Int => | |
570 | - | let p = i.payments[0] | |
571 | - | match getGameState(GAMENUMBER) { | |
572 | - | case state: Int => | |
573 | - | if ((state == GAMESTART)) | |
574 | - | then if (if ((typeBet == PASSLINEBET)) | |
575 | - | then true | |
576 | - | else (typeBet == DONTPASSLINEBET)) | |
577 | - | then storePassOrComeBet(GAMENUMBER, toString(p.amount), typeBet, toBase58String(i.caller.bytes)) | |
578 | - | else throw((((((("Only " + PASSLINEBET) + ", ") + DONTPASSLINEBET) + " and ") + FIELDBET) + " are allowed in the Beginning of Game")) | |
579 | - | else if ((state == GAMEINPROGRESS)) | |
580 | - | then throw((((((("Only " + COMEBET) + ", ") + DONTCOMEBET) + " and ") + FIELDBET) + " ARE ALLOWED at Start.")) | |
581 | - | else if ((state == GAMEFINISHED)) | |
582 | - | then throw("Game already ended.") | |
583 | - | else throw("Unknown Game State.") | |
584 | - | case _ => | |
585 | - | throw("Game does not exist or has already ended.") | |
586 | - | } | |
587 | - | case _ => | |
588 | - | throw("Game has not been initialized.") | |
589 | - | } | |
590 | - | else throw(((((((((("Unsupported Type of Bet for Crap. Please Select one of " + PASSLINEBET) + ", ") + DONTPASSLINEBET) + ", ") + COMEBET) + ", ") + DONTCOMEBET) + ", ") + FIELDBET)) | |
591 | - | ||
592 | - | ||
593 | - | ||
594 | - | @Callable(i) | |
595 | - | func placeRoundBet (typeBet,oddNumber) = if (validateRoundBet(typeBet)) | |
596 | - | then if ((size(i.payments) == 0)) | |
597 | - | then throw("Payment not attached") | |
598 | - | else match getGameCounter() { | |
599 | - | case GAMENUMBER: Int => | |
600 | - | let p = i.payments[0] | |
601 | - | match getGameState(GAMENUMBER) { | |
602 | - | case state: Int => | |
603 | - | if ((state == GAMEFINISHED)) | |
604 | - | then throw("Game already ended.") | |
605 | - | else if (if ((typeBet == COMEBET)) | |
606 | - | then true | |
607 | - | else (typeBet == DONTCOMEBET)) | |
608 | - | then if ((state == GAMESTART)) | |
609 | - | then throw("Cannot place COME OR DONTCOME BET IF GAME HAS NOT STARTED") | |
610 | - | else storeOneRoundBetTypes(GAMENUMBER, toString(p.amount), typeBet, toBase58String(i.caller.bytes), 0) | |
611 | - | else storeOneRoundBetTypes(GAMENUMBER, toString(p.amount), typeBet, toBase58String(i.caller.bytes), oddNumber) | |
612 | - | case _ => | |
613 | - | throw("Game does not exist or has already ended.") | |
614 | - | } | |
615 | - | case _ => | |
616 | - | throw("Game has not been initialized.") | |
617 | - | } | |
618 | - | else throw(((((((((("Unsupported Type of Bet for Crap. Please Select one of " + ODDSBET) + ", ") + DONTPASSLINEBET) + ", ") + COMEBET) + ", ") + DONTCOMEBET) + ", ") + FIELDBET)) | |
619 | - | ||
620 | - | ||
621 | - | ||
622 | - | @Callable(i) | |
623 | - | func throwDices (rsaSign,gameNumber) = if (authorizePermission(i.callerPublicKey)) | |
624 | - | then throw("throwDices_FORBIDDEN") | |
625 | - | else match getGameState(gameNumber) { | |
626 | - | case state: Int => | |
627 | - | if ((state == GAMEFINISHED)) | |
628 | - | then throw("Game is finished") | |
629 | - | else { | |
630 | - | let currentHeight = lastBlock.height | |
631 | - | let lastHeightAllowed = value(getEndHeight(gameNumber)) | |
632 | - | if ((currentHeight >= lastHeightAllowed)) | |
633 | - | then match getGameSumSha(gameNumber) { | |
634 | - | case sumSha: String => | |
635 | - | let sig = fromBase64String(rsaSign) | |
636 | - | let rsaSigValid = rsaVerify(SHA256, fromBase58String(sumSha), sig, RSAPUBLIC) | |
637 | - | match blockInfoByHeight((lastBlock.height - 1)) { | |
638 | - | case previousBlock: BlockInfo => | |
639 | - | let randomHash = sha256((take(sig, 4) + take(previousBlock.generationSignature, 8))) | |
640 | - | if (!(rsaSigValid)) | |
641 | - | then throw("INVALID_RSA_SIGN") | |
642 | - | else { | |
643 | - | let randNumber = (toInt(randomHash) % 11) | |
644 | - | let number = diceNumber[randNumber] | |
645 | - | match getGameRollsCount(gameNumber) { | |
646 | - | case rollCountNumber: Int => | |
647 | - | let newRollCountNumber = (rollCountNumber + 1) | |
648 | - | if ((state == GAMESTART)) | |
649 | - | then if (if (if (if (if ((number == 7)) | |
650 | - | then true | |
651 | - | else (number == 11)) | |
652 | - | then true | |
653 | - | else (number == 2)) | |
654 | - | then true | |
655 | - | else (number == 3)) | |
656 | - | then true | |
657 | - | else (number == 12)) | |
658 | - | then storeGameProgressPointState(gameFirstPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEFINISHED) | |
659 | - | else storeGameProgressPointState(gameFirstPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEINPROGRESS) | |
660 | - | else { | |
661 | - | let currentPoint = value(getCurrentPointDice(gameNumber)) | |
662 | - | let firstPoint = value(getFirstPointDice(gameNumber)) | |
663 | - | if ((currentPoint == 0)) | |
664 | - | then if (if ((number == 7)) | |
665 | - | then true | |
666 | - | else (firstPoint == number)) | |
667 | - | then storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEFINISHED) | |
668 | - | else storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEINPROGRESS) | |
669 | - | else if (if ((number == 7)) | |
670 | - | then true | |
671 | - | else (firstPoint == number)) | |
672 | - | then storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEFINISHED) | |
673 | - | else storeGameProgressPointState(gameCurrentPointDiceLabel(gameNumber), gameNumber, number, newRollCountNumber, currentHeight, randomHash, GAMEINPROGRESS) | |
674 | - | } | |
675 | - | case _ => | |
676 | - | throw("No dices have been thrown") | |
677 | - | } | |
678 | - | } | |
679 | - | case _ => | |
680 | - | throw("Last block doesn't exist.") | |
681 | - | } | |
682 | - | case _ => | |
683 | - | throw("SHA doesn't exist") | |
684 | - | } | |
685 | - | else throw("Throw dice not allow still waiting for block to process") | |
686 | - | } | |
687 | - | case _ => | |
688 | - | throw("Game does not exist or has already ended.") | |
243 | + | else throw((("You need " + toBase58String(ticketAsset)) + " to play this game.")) | |
689 | 244 | } | |
690 | 245 | ||
691 | 246 | ||
692 | 247 | @Verifier(tx) | |
693 | 248 | func verify () = match tx { | |
694 | 249 | case _ => | |
695 | 250 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
696 | 251 | } | |
697 | 252 |
github/deemru/w8io/169f3d6 83.04 ms ◑![]()