tx · 8SQjJKyJzYLw16Caj1HzR9DjTgmvy8sjJQ17Hwrtv4YV 3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun: -0.01400000 Waves 2019.09.08 14:34 [667049] smart account 3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun > SELF 0.00000000 Waves
{ "type": 13, "id": "8SQjJKyJzYLw16Caj1HzR9DjTgmvy8sjJQ17Hwrtv4YV", "fee": 1400000, "feeAssetId": null, "timestamp": 1567942459964, "version": 1, "sender": "3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun", "senderPublicKey": "7uRSDXQUkUS7719CDA4wXghhzsWrF22gb18FGDPZyA6P", "proofs": [ "3wcCwpynyNCTYt5Crprzx8tj7s3fM7hDHz2gG3HvCgYrihxJ2cLBsCrPp8jQod5qWBXAmYPD7m4gKGec8XAeikd4" ], "script": "base64:AAIDAAAAAAAAAAAAAAASAAAAAAlXaW5TZXJ2ZXIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM045WG55UHBXeFlvaEtIN3o1ZEV1cThycG5vYnB5elByekUAAAAAB1dBVkVMRVQJAABoAAAAAgkAAGgAAAACAAAAAAAAAABkAAAAAAAAAAPoAAAAAAAAAAPoAAAAAApDT01NSVNTSU9OCQAAaQAAAAIJAABoAAAAAgAAAAAAAAAABQUAAAAHV0FWRUxFVAAAAAAAAAAD6AAAAAAOVGlja2V0c1BlcldhdmUAAAAAAAAAAGQAAAAAC0NVUlJFTlRHQU1FAgAAAA0kQ1VSUkVOVF9HQU1FAAAAAA9HQU1FU0NPVU5URVJLRVkCAAAACSRHQU1FX05VTQAAAAAKTEFTVFRJQ0tFVAIAAAAMJExBU1RfVElDS0VUAAAAAARCQU5LAgAAAAokR0FNRV9CQU5LAQAAAA5nZXRQbGF5ZXJzTGlzdAAAAAIAAAAGZ2FtZUlkAAAADWN1cnJlbnRQbGF5ZXIEAAAAEHBsYXllcnNQcmVzZW50ZWQJ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QW10BQAAABVuZXdUb3RhbFBsYXllckJldHNBbXQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAhfcGxheWVycwkBAAAADmdldFBsYXllcnNMaXN0AAAAAgUAAAAGZ2FtZUlkBQAAABBwbGF5ZXJBZGRyZXNzU3RyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApMQVNUVElDS0VUCQEAAAANZ2V0TGFzdFRpY2tldAAAAAEFAAAACnBheW1lbnRBbXQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZnYW1lSWQCAAAAAV8FAAAABEJBTksFAAAADm5ld0JhbmtCYWxhbmNlBQAAAANuaWwEAAAAC3RvV2luU2VydmVyCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAACVdpblNlcnZlcgUAAAAKcGF5bWVudEFtdAUAAAAEdW5pdAUAAAADbmlsCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQUAAAAHYmV0RGF0YQkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAALdG9XaW5TZXJ2ZXIAAAAAuEFOFA==", "chainId": 84, "height": 667049, "spentComplexity": 0 } View: original | compacted Prev: BnCWwfp8RGwVhDjYBjKgkznwpjFezeuYnCbqB4hb4vqg Next: 9tuH1rfxj1xbC8fZg6b8Q5qF2UakJNGjjYkLnZH9HsnA Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | - | ||
6 | - | let BetServer = addressFromStringValue("3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun") | |
4 | + | let WinServer = addressFromStringValue("3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE") | |
7 | 5 | ||
8 | 6 | let WAVELET = ((100 * 1000) * 1000) | |
9 | 7 | ||
13 | 11 | ||
14 | 12 | let CURRENTGAME = "$CURRENT_GAME" | |
15 | 13 | ||
14 | + | let GAMESCOUNTERKEY = "$GAME_NUM" | |
15 | + | ||
16 | 16 | let LASTTICKET = "$LAST_TICKET" | |
17 | 17 | ||
18 | 18 | let BANK = "$GAME_BANK" | |
19 | 19 | ||
20 | - | func GenerateRandInt (gameId,rsaSign) = { | |
21 | - | let lastTicket = getIntegerValue(BetServer, LASTTICKET) | |
22 | - | let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey) | |
23 | - | if (rsaSigValid) | |
24 | - | then { | |
25 | - | let rand = (toInt(sha256(rsaSign)) % lastTicket) | |
26 | - | if ((0 > rand)) | |
27 | - | then ((-1 * rand) + 1) | |
28 | - | else (rand + 1) | |
29 | - | } | |
30 | - | else throw("Invalid RSA signature") | |
20 | + | func getPlayersList (gameId,currentPlayer) = { | |
21 | + | let playersPresented = isDefined(getString(this, (gameId + "_players"))) | |
22 | + | if (!(playersPresented)) | |
23 | + | then currentPlayer | |
24 | + | else if (isDefined(getString(this, (((gameId + "_") + currentPlayer) + "_tickets")))) | |
25 | + | then getStringValue(this, (gameId + "_players")) | |
26 | + | else ((getStringValue(this, (gameId + "_players")) + "_") + currentPlayer) | |
31 | 27 | } | |
32 | 28 | ||
33 | 29 | ||
34 | - | func isWinner (ticketsStr,winTicket) = { | |
35 | - | let tickets = split(ticketsStr, "_") | |
36 | - | if (if ((winTicket >= parseIntValue(tickets[0]))) | |
37 | - | then (parseIntValue(tickets[1]) >= winTicket) | |
38 | - | else false) | |
39 | - | then true | |
40 | - | else if (if ((winTicket >= parseIntValue(tickets[2]))) | |
41 | - | then (parseIntValue(tickets[3]) >= winTicket) | |
42 | - | else false) | |
43 | - | then true | |
44 | - | else if (if ((winTicket >= parseIntValue(tickets[4]))) | |
45 | - | then (parseIntValue(tickets[5]) >= winTicket) | |
46 | - | else false) | |
47 | - | then true | |
48 | - | else if (if ((winTicket >= parseIntValue(tickets[6]))) | |
49 | - | then (parseIntValue(tickets[7]) >= winTicket) | |
50 | - | else false) | |
51 | - | then true | |
52 | - | else false | |
30 | + | func getOrCreateLastTicket () = { | |
31 | + | let isLastTicketPresented = isDefined(getInteger(this, LASTTICKET)) | |
32 | + | if (!(isLastTicketPresented)) | |
33 | + | then 0 | |
34 | + | else getIntegerValue(this, LASTTICKET) | |
53 | 35 | } | |
54 | 36 | ||
55 | 37 | ||
56 | - | func win (gameId,winTicket,winnerAddressStr,bankBalance,totalWinnerBetsAmt) = { | |
57 | - | let winAmt = (((bankBalance - totalWinnerBetsAmt) * 90) / 100) | |
58 | - | let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)] | |
59 | - | let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)] | |
60 | - | ScriptResult(WriteSet(gameResult), TransferSet(winTX)) | |
38 | + | func getPlayerBetsCount (gameId,playerAddressStr) = { | |
39 | + | let betsCount = match getInteger(this, (((gameId + "_") + playerAddressStr) + "_betsCount")) { | |
40 | + | case num: Int => | |
41 | + | num | |
42 | + | case _ => | |
43 | + | 0 | |
44 | + | } | |
45 | + | betsCount | |
46 | + | } | |
47 | + | ||
48 | + | ||
49 | + | func getTickets (gameId,playerAddressStr,paymentAmt) = { | |
50 | + | let lastTicket = getOrCreateLastTicket() | |
51 | + | let wavesPayment = (paymentAmt / WAVELET) | |
52 | + | let firstNewTicket = (lastTicket + 1) | |
53 | + | let lastNewTicket = ((firstNewTicket + (wavesPayment * TicketsPerWave)) - 1) | |
54 | + | let firstNewTicketStr = toString(firstNewTicket) | |
55 | + | let lastNewTicketStr = toString(lastNewTicket) | |
56 | + | let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets"))) | |
57 | + | if (ticketsStr) | |
58 | + | then { | |
59 | + | let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets")) | |
60 | + | let currentPlayerBetNum = getPlayerBetsCount(gameId, playerAddressStr) | |
61 | + | let CTL = split(currentTickets, "_") | |
62 | + | if ((currentPlayerBetNum == 1)) | |
63 | + | then (((((((CTL[0] + "_") + CTL[1]) + "_") + firstNewTicketStr) + "_") + lastNewTicketStr) + "_0_0_0_0") | |
64 | + | else if ((currentPlayerBetNum == 2)) | |
65 | + | then ((((((((((CTL[0] + "_") + CTL[1]) + "_") + CTL[2]) + "_") + CTL[3]) + firstNewTicketStr) + "_") + lastNewTicketStr) + "_0_0") | |
66 | + | else if ((currentPlayerBetNum == 3)) | |
67 | + | then ((((((((((((CTL[0] + "_") + CTL[1]) + "_") + CTL[2]) + "_") + CTL[3]) + CTL[4]) + "_") + CTL[5]) + firstNewTicketStr) + "_") + lastNewTicketStr) | |
68 | + | else throw("Error, bid limit exceeded") | |
69 | + | } | |
70 | + | else (((firstNewTicketStr + "_") + lastNewTicketStr) + "_0_0_0_0_0_0") | |
71 | + | } | |
72 | + | ||
73 | + | ||
74 | + | func getLastTicket (paymentAmt) = { | |
75 | + | let lastTicket = getOrCreateLastTicket() | |
76 | + | let wavesPayment = (paymentAmt / WAVELET) | |
77 | + | (lastTicket + (wavesPayment * TicketsPerWave)) | |
78 | + | } | |
79 | + | ||
80 | + | ||
81 | + | func IncrementGameNum (gameId,txId) = { | |
82 | + | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
83 | + | case num: Int => | |
84 | + | num | |
85 | + | case _ => | |
86 | + | 0 | |
87 | + | } | |
88 | + | if ((gameId == txId)) | |
89 | + | then (gameNum + 1) | |
90 | + | else gameNum | |
91 | + | } | |
92 | + | ||
93 | + | ||
94 | + | func getOrCreateCurrentGame (txId) = { | |
95 | + | let isCurrentGamePresented = isDefined(getString(this, CURRENTGAME)) | |
96 | + | if (!(isCurrentGamePresented)) | |
97 | + | then txId | |
98 | + | else if ((getStringValue(this, CURRENTGAME) == "")) | |
99 | + | then txId | |
100 | + | else getStringValue(this, CURRENTGAME) | |
101 | + | } | |
102 | + | ||
103 | + | ||
104 | + | func getCurrentGame (txId) = { | |
105 | + | let gameId = getOrCreateCurrentGame(txId) | |
106 | + | let gameAlreadyPlayed = isDefined(getString(this, (gameId + "_result"))) | |
107 | + | if (gameAlreadyPlayed) | |
108 | + | then txId | |
109 | + | else gameId | |
110 | + | } | |
111 | + | ||
112 | + | ||
113 | + | func getBankBalance (gameId,paymentAmt) = { | |
114 | + | let bankBalance = match getInteger(this, ((gameId + "_") + BANK)) { | |
115 | + | case num: Int => | |
116 | + | num | |
117 | + | case _ => | |
118 | + | 0 | |
119 | + | } | |
120 | + | (bankBalance + paymentAmt) | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func getTotalPlayerBetsAmt (gameId,playerAddressStr,paymentAmt) = { | |
125 | + | let totalPlayerBets = match getInteger(this, (((gameId + "_") + playerAddressStr) + "_totalBetsAmt")) { | |
126 | + | case num: Int => | |
127 | + | num | |
128 | + | case _ => | |
129 | + | 0 | |
130 | + | } | |
131 | + | (totalPlayerBets + paymentAmt) | |
61 | 132 | } | |
62 | 133 | ||
63 | 134 | ||
64 | 135 | @Callable(i) | |
65 | - | func generateResult (gameId,rsaSignCrypted) = { | |
66 | - | let currentGame = getStringValue(BetServer, CURRENTGAME) | |
67 | - | if ((currentGame == gameId)) | |
68 | - | then { | |
69 | - | let rsaSign = fromBase58String(rsaSignCrypted) | |
70 | - | let winTicket = GenerateRandInt(gameId, rsaSign) | |
71 | - | let players = getStringValue(BetServer, (gameId + "_players")) | |
72 | - | let playersList = split(players, "_") | |
73 | - | let bankBalance = getIntegerValue(BetServer, BANK) | |
74 | - | if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[0]) + "_tickets")), winTicket)) | |
75 | - | then win(gameId, winTicket, playersList[0], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[0]) + "_totalBetsAmt"))) | |
76 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[1]) + "_tickets")), winTicket)) | |
77 | - | then win(gameId, winTicket, playersList[1], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[1]) + "_totalBetsAmt"))) | |
78 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[2]) + "_tickets")), winTicket)) | |
79 | - | then win(gameId, winTicket, playersList[2], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[2]) + "_totalBetsAmt"))) | |
80 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[3]) + "_tickets")), winTicket)) | |
81 | - | then win(gameId, winTicket, playersList[3], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[3]) + "_totalBetsAmt"))) | |
82 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[4]) + "_tickets")), winTicket)) | |
83 | - | then win(gameId, winTicket, playersList[4], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[4]) + "_totalBetsAmt"))) | |
84 | - | else throw("Error") | |
85 | - | } | |
86 | - | else throw(((("Current Game is " + currentGame) + ", but not ") + gameId)) | |
136 | + | func resetGameData (gameId) = { | |
137 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
138 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
139 | + | let playerAddressStr = toString(playerAddress) | |
140 | + | let zeroData = [DataEntry(CURRENTGAME, ""), DataEntry(GAMESCOUNTERKEY, 0), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), ""), DataEntry((((gameId + "_") + playerAddressStr) + "_betsCount"), 0), DataEntry((((gameId + "_") + playerAddressStr) + "_totalBetsAmt"), 0), DataEntry(((gameId + "_") + BANK), 0), DataEntry((gameId + "_players"), ""), DataEntry(LASTTICKET, 0)] | |
141 | + | WriteSet(zeroData) | |
142 | + | } | |
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | @Callable(i) | |
147 | + | func bet () = { | |
148 | + | let txId = toBase58String(i.transactionId) | |
149 | + | let gameId = getCurrentGame(txId) | |
150 | + | let gameNum = IncrementGameNum(gameId, txId) | |
151 | + | let pmt = extract(i.payment) | |
152 | + | let paymentAmt = pmt.amount | |
153 | + | let betNotInWaves = isDefined(pmt.assetId) | |
154 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
155 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
156 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
157 | + | if (betNotInWaves) | |
158 | + | then throw("Bet amount must be in Waves") | |
159 | + | else if (feeNotInWaves) | |
160 | + | then throw("Transaction's fee must be in Waves") | |
161 | + | else { | |
162 | + | let playerAddressStr = toString(playerAddress) | |
163 | + | let newBankBalance = getBankBalance(gameId, paymentAmt) | |
164 | + | let newTotalPlayerBetsAmt = getTotalPlayerBetsAmt(gameId, playerAddressStr, paymentAmt) | |
165 | + | let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(gameId, playerAddressStr, paymentAmt)), DataEntry((((gameId + "_") + playerAddressStr) + "_betsCount"), (getPlayerBetsCount(gameId, playerAddressStr) + 1)), DataEntry((((gameId + "_") + playerAddressStr) + "_totalBetsAmt"), newTotalPlayerBetsAmt), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr)), DataEntry(LASTTICKET, getLastTicket(paymentAmt)), DataEntry(((gameId + "_") + BANK), newBankBalance)] | |
166 | + | let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)] | |
167 | + | ScriptResult(WriteSet(betData), TransferSet(toWinServer)) | |
168 | + | } | |
87 | 169 | } | |
88 | 170 | ||
89 | 171 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | - | ||
6 | - | let BetServer = addressFromStringValue("3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun") | |
4 | + | let WinServer = addressFromStringValue("3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE") | |
7 | 5 | ||
8 | 6 | let WAVELET = ((100 * 1000) * 1000) | |
9 | 7 | ||
10 | 8 | let COMMISSION = ((5 * WAVELET) / 1000) | |
11 | 9 | ||
12 | 10 | let TicketsPerWave = 100 | |
13 | 11 | ||
14 | 12 | let CURRENTGAME = "$CURRENT_GAME" | |
15 | 13 | ||
14 | + | let GAMESCOUNTERKEY = "$GAME_NUM" | |
15 | + | ||
16 | 16 | let LASTTICKET = "$LAST_TICKET" | |
17 | 17 | ||
18 | 18 | let BANK = "$GAME_BANK" | |
19 | 19 | ||
20 | - | func GenerateRandInt (gameId,rsaSign) = { | |
21 | - | let lastTicket = getIntegerValue(BetServer, LASTTICKET) | |
22 | - | let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey) | |
23 | - | if (rsaSigValid) | |
24 | - | then { | |
25 | - | let rand = (toInt(sha256(rsaSign)) % lastTicket) | |
26 | - | if ((0 > rand)) | |
27 | - | then ((-1 * rand) + 1) | |
28 | - | else (rand + 1) | |
29 | - | } | |
30 | - | else throw("Invalid RSA signature") | |
20 | + | func getPlayersList (gameId,currentPlayer) = { | |
21 | + | let playersPresented = isDefined(getString(this, (gameId + "_players"))) | |
22 | + | if (!(playersPresented)) | |
23 | + | then currentPlayer | |
24 | + | else if (isDefined(getString(this, (((gameId + "_") + currentPlayer) + "_tickets")))) | |
25 | + | then getStringValue(this, (gameId + "_players")) | |
26 | + | else ((getStringValue(this, (gameId + "_players")) + "_") + currentPlayer) | |
31 | 27 | } | |
32 | 28 | ||
33 | 29 | ||
34 | - | func isWinner (ticketsStr,winTicket) = { | |
35 | - | let tickets = split(ticketsStr, "_") | |
36 | - | if (if ((winTicket >= parseIntValue(tickets[0]))) | |
37 | - | then (parseIntValue(tickets[1]) >= winTicket) | |
38 | - | else false) | |
39 | - | then true | |
40 | - | else if (if ((winTicket >= parseIntValue(tickets[2]))) | |
41 | - | then (parseIntValue(tickets[3]) >= winTicket) | |
42 | - | else false) | |
43 | - | then true | |
44 | - | else if (if ((winTicket >= parseIntValue(tickets[4]))) | |
45 | - | then (parseIntValue(tickets[5]) >= winTicket) | |
46 | - | else false) | |
47 | - | then true | |
48 | - | else if (if ((winTicket >= parseIntValue(tickets[6]))) | |
49 | - | then (parseIntValue(tickets[7]) >= winTicket) | |
50 | - | else false) | |
51 | - | then true | |
52 | - | else false | |
30 | + | func getOrCreateLastTicket () = { | |
31 | + | let isLastTicketPresented = isDefined(getInteger(this, LASTTICKET)) | |
32 | + | if (!(isLastTicketPresented)) | |
33 | + | then 0 | |
34 | + | else getIntegerValue(this, LASTTICKET) | |
53 | 35 | } | |
54 | 36 | ||
55 | 37 | ||
56 | - | func win (gameId,winTicket,winnerAddressStr,bankBalance,totalWinnerBetsAmt) = { | |
57 | - | let winAmt = (((bankBalance - totalWinnerBetsAmt) * 90) / 100) | |
58 | - | let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)] | |
59 | - | let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)] | |
60 | - | ScriptResult(WriteSet(gameResult), TransferSet(winTX)) | |
38 | + | func getPlayerBetsCount (gameId,playerAddressStr) = { | |
39 | + | let betsCount = match getInteger(this, (((gameId + "_") + playerAddressStr) + "_betsCount")) { | |
40 | + | case num: Int => | |
41 | + | num | |
42 | + | case _ => | |
43 | + | 0 | |
44 | + | } | |
45 | + | betsCount | |
46 | + | } | |
47 | + | ||
48 | + | ||
49 | + | func getTickets (gameId,playerAddressStr,paymentAmt) = { | |
50 | + | let lastTicket = getOrCreateLastTicket() | |
51 | + | let wavesPayment = (paymentAmt / WAVELET) | |
52 | + | let firstNewTicket = (lastTicket + 1) | |
53 | + | let lastNewTicket = ((firstNewTicket + (wavesPayment * TicketsPerWave)) - 1) | |
54 | + | let firstNewTicketStr = toString(firstNewTicket) | |
55 | + | let lastNewTicketStr = toString(lastNewTicket) | |
56 | + | let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets"))) | |
57 | + | if (ticketsStr) | |
58 | + | then { | |
59 | + | let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets")) | |
60 | + | let currentPlayerBetNum = getPlayerBetsCount(gameId, playerAddressStr) | |
61 | + | let CTL = split(currentTickets, "_") | |
62 | + | if ((currentPlayerBetNum == 1)) | |
63 | + | then (((((((CTL[0] + "_") + CTL[1]) + "_") + firstNewTicketStr) + "_") + lastNewTicketStr) + "_0_0_0_0") | |
64 | + | else if ((currentPlayerBetNum == 2)) | |
65 | + | then ((((((((((CTL[0] + "_") + CTL[1]) + "_") + CTL[2]) + "_") + CTL[3]) + firstNewTicketStr) + "_") + lastNewTicketStr) + "_0_0") | |
66 | + | else if ((currentPlayerBetNum == 3)) | |
67 | + | then ((((((((((((CTL[0] + "_") + CTL[1]) + "_") + CTL[2]) + "_") + CTL[3]) + CTL[4]) + "_") + CTL[5]) + firstNewTicketStr) + "_") + lastNewTicketStr) | |
68 | + | else throw("Error, bid limit exceeded") | |
69 | + | } | |
70 | + | else (((firstNewTicketStr + "_") + lastNewTicketStr) + "_0_0_0_0_0_0") | |
71 | + | } | |
72 | + | ||
73 | + | ||
74 | + | func getLastTicket (paymentAmt) = { | |
75 | + | let lastTicket = getOrCreateLastTicket() | |
76 | + | let wavesPayment = (paymentAmt / WAVELET) | |
77 | + | (lastTicket + (wavesPayment * TicketsPerWave)) | |
78 | + | } | |
79 | + | ||
80 | + | ||
81 | + | func IncrementGameNum (gameId,txId) = { | |
82 | + | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
83 | + | case num: Int => | |
84 | + | num | |
85 | + | case _ => | |
86 | + | 0 | |
87 | + | } | |
88 | + | if ((gameId == txId)) | |
89 | + | then (gameNum + 1) | |
90 | + | else gameNum | |
91 | + | } | |
92 | + | ||
93 | + | ||
94 | + | func getOrCreateCurrentGame (txId) = { | |
95 | + | let isCurrentGamePresented = isDefined(getString(this, CURRENTGAME)) | |
96 | + | if (!(isCurrentGamePresented)) | |
97 | + | then txId | |
98 | + | else if ((getStringValue(this, CURRENTGAME) == "")) | |
99 | + | then txId | |
100 | + | else getStringValue(this, CURRENTGAME) | |
101 | + | } | |
102 | + | ||
103 | + | ||
104 | + | func getCurrentGame (txId) = { | |
105 | + | let gameId = getOrCreateCurrentGame(txId) | |
106 | + | let gameAlreadyPlayed = isDefined(getString(this, (gameId + "_result"))) | |
107 | + | if (gameAlreadyPlayed) | |
108 | + | then txId | |
109 | + | else gameId | |
110 | + | } | |
111 | + | ||
112 | + | ||
113 | + | func getBankBalance (gameId,paymentAmt) = { | |
114 | + | let bankBalance = match getInteger(this, ((gameId + "_") + BANK)) { | |
115 | + | case num: Int => | |
116 | + | num | |
117 | + | case _ => | |
118 | + | 0 | |
119 | + | } | |
120 | + | (bankBalance + paymentAmt) | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func getTotalPlayerBetsAmt (gameId,playerAddressStr,paymentAmt) = { | |
125 | + | let totalPlayerBets = match getInteger(this, (((gameId + "_") + playerAddressStr) + "_totalBetsAmt")) { | |
126 | + | case num: Int => | |
127 | + | num | |
128 | + | case _ => | |
129 | + | 0 | |
130 | + | } | |
131 | + | (totalPlayerBets + paymentAmt) | |
61 | 132 | } | |
62 | 133 | ||
63 | 134 | ||
64 | 135 | @Callable(i) | |
65 | - | func generateResult (gameId,rsaSignCrypted) = { | |
66 | - | let currentGame = getStringValue(BetServer, CURRENTGAME) | |
67 | - | if ((currentGame == gameId)) | |
68 | - | then { | |
69 | - | let rsaSign = fromBase58String(rsaSignCrypted) | |
70 | - | let winTicket = GenerateRandInt(gameId, rsaSign) | |
71 | - | let players = getStringValue(BetServer, (gameId + "_players")) | |
72 | - | let playersList = split(players, "_") | |
73 | - | let bankBalance = getIntegerValue(BetServer, BANK) | |
74 | - | if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[0]) + "_tickets")), winTicket)) | |
75 | - | then win(gameId, winTicket, playersList[0], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[0]) + "_totalBetsAmt"))) | |
76 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[1]) + "_tickets")), winTicket)) | |
77 | - | then win(gameId, winTicket, playersList[1], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[1]) + "_totalBetsAmt"))) | |
78 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[2]) + "_tickets")), winTicket)) | |
79 | - | then win(gameId, winTicket, playersList[2], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[2]) + "_totalBetsAmt"))) | |
80 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[3]) + "_tickets")), winTicket)) | |
81 | - | then win(gameId, winTicket, playersList[3], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[3]) + "_totalBetsAmt"))) | |
82 | - | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[4]) + "_tickets")), winTicket)) | |
83 | - | then win(gameId, winTicket, playersList[4], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[4]) + "_totalBetsAmt"))) | |
84 | - | else throw("Error") | |
85 | - | } | |
86 | - | else throw(((("Current Game is " + currentGame) + ", but not ") + gameId)) | |
136 | + | func resetGameData (gameId) = { | |
137 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
138 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
139 | + | let playerAddressStr = toString(playerAddress) | |
140 | + | let zeroData = [DataEntry(CURRENTGAME, ""), DataEntry(GAMESCOUNTERKEY, 0), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), ""), DataEntry((((gameId + "_") + playerAddressStr) + "_betsCount"), 0), DataEntry((((gameId + "_") + playerAddressStr) + "_totalBetsAmt"), 0), DataEntry(((gameId + "_") + BANK), 0), DataEntry((gameId + "_players"), ""), DataEntry(LASTTICKET, 0)] | |
141 | + | WriteSet(zeroData) | |
142 | + | } | |
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | @Callable(i) | |
147 | + | func bet () = { | |
148 | + | let txId = toBase58String(i.transactionId) | |
149 | + | let gameId = getCurrentGame(txId) | |
150 | + | let gameNum = IncrementGameNum(gameId, txId) | |
151 | + | let pmt = extract(i.payment) | |
152 | + | let paymentAmt = pmt.amount | |
153 | + | let betNotInWaves = isDefined(pmt.assetId) | |
154 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
155 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
156 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
157 | + | if (betNotInWaves) | |
158 | + | then throw("Bet amount must be in Waves") | |
159 | + | else if (feeNotInWaves) | |
160 | + | then throw("Transaction's fee must be in Waves") | |
161 | + | else { | |
162 | + | let playerAddressStr = toString(playerAddress) | |
163 | + | let newBankBalance = getBankBalance(gameId, paymentAmt) | |
164 | + | let newTotalPlayerBetsAmt = getTotalPlayerBetsAmt(gameId, playerAddressStr, paymentAmt) | |
165 | + | let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(gameId, playerAddressStr, paymentAmt)), DataEntry((((gameId + "_") + playerAddressStr) + "_betsCount"), (getPlayerBetsCount(gameId, playerAddressStr) + 1)), DataEntry((((gameId + "_") + playerAddressStr) + "_totalBetsAmt"), newTotalPlayerBetsAmt), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr)), DataEntry(LASTTICKET, getLastTicket(paymentAmt)), DataEntry(((gameId + "_") + BANK), newBankBalance)] | |
166 | + | let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)] | |
167 | + | ScriptResult(WriteSet(betData), TransferSet(toWinServer)) | |
168 | + | } | |
87 | 169 | } | |
88 | 170 | ||
89 | 171 |
github/deemru/w8io/026f985 30.02 ms ◑