tx · 46ogj69H7LC1d1DmUAz8sX9KrnVWkToDb2rfraTNYPPW

3N9fzexZxi7HrPcfizpvpFcaAnvpyuuMKPg:  -0.01400000 Waves

2019.09.05 21:16 [663080] smart account 3N9fzexZxi7HrPcfizpvpFcaAnvpyuuMKPg > SELF 0.00000000 Waves

{ "type": 13, "id": "46ogj69H7LC1d1DmUAz8sX9KrnVWkToDb2rfraTNYPPW", "fee": 1400000, "feeAssetId": null, "timestamp": 1567707397075, "version": 1, "sender": "3N9fzexZxi7HrPcfizpvpFcaAnvpyuuMKPg", "senderPublicKey": "BJB5QS4iQna1z8idKb5QQ5cACUmNgxzHc81Y7AW6ZZY7", "proofs": [ "R7JQR2VrYkhF2DjhvHmmwX2e4t3uhqA8qqQAEUDkX96oKEgstXPFXJMDdWwySmjMQLiCV87Uwy6MDv7v7i8sp1A" ], "script": "base64:AAIDAAAAAAAAAAAAAAAIAAAAABBzdGFydFJvdW5kSGVpZ2h0AAAAAAAAAAAFAQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAACGxhc3RQbGF5BAAAAAckbWF0Y2gwCQAEHAAAAAIFAAAABHRoaXMCAAAACGxhc3RQbGF5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0BAAAAAFhBQAAAAckbWF0Y2gwAQAAAAxXYXZlc0xvdHRvVjIJAQAAAAV0aHJvdwAAAAAEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACBQAAAAhsYXN0UGxheQgFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABm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FtZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAHQm9vbGVhbgQAAAABZwUAAAAHJG1hdGNoMAUAAAABZwcEAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50BAAAAAxhZGRyZXNzR2FtZXIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAMY3VycmVudFJvdW5kCQEAAAAVZ2V0Q3VycmVudE51bWJlclJvdW5kAAAAAAQAAAAIY291bnRCZXQJAQAAAAZnZXRCZXQAAAADCAUAAAADcG10AAAABmFtb3VudAUAAAAMY3VycmVudFJvdW5kBQAAAAxhZGRyZXNzR2FtZXIDAwMJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAkAAGcAAAACCAUAAAADcG10AAAABmFtb3VudAUAAAAIY291bnRCZXQHBQAAAA1pc0dhbWVTdGFydGVkBwkBAAAAC3NldEdhbWVyQmV0AAAABAUAAAAMYWRkcmVzc0dhbWVyAgAAAAZfbW9yZV8CAAAADl9jb3VudEdhbWVyc1VwCAUAAAADcG10AAAABmFtb3VudAMJAABmAAAAAgUAAAAIY291bnRCZXQIBQAAAANwbXQAAAAGYW1vdW50CQAAAgAAAAECAAAAI1BheW1lbnQgbXVzdCBiZSBtb3JlIGZvciB0aGUgcm91bmQhCQAAAgAAAAECAAAAFXdvcmtzIHdpdGggd2F2ZXMgb25seQAAAACJRukz", "chainId": 84, "height": 663080, "spentComplexity": 0 } View: original | compacted Prev: 4vBWRhoh2qb5iSri55czCtQBfNSx8RLca2T18g7CV3s9 Next: none Diff:
OldNewDifferences
3333 }
3434
3535
36-func getBet (bet,round,addressGamer) = if ((round >= 1))
37- then {
38- let winnerOfPrevRound = match getString(this, "lastRoundWinner") {
39- case w: String =>
40- w
41- case _ =>
42- ""
43- }
44- let winnerFromPrevRound = match getString(this, (winnerOfPrevRound + addressGamer)) {
45- case w: String =>
46- w
47- case _ =>
48- ""
49- }
50- if (if ((round > 1))
51- then (winnerFromPrevRound == "")
52- else false)
53- then (round * 2)
54- else 1
55- }
56- else 1
36+func setGamerBet (addressGamer,directionRate,directionGamer,currentBet) = {
37+ let currentRound = getCurrentNumberRound()
38+ let newNumberOfRound = match getInteger(this, "numberRound") {
39+ case a: Int =>
40+ a
41+ case _ =>
42+ 1
43+ }
44+ let numOfGamersCurrDirection = match getInteger(this, (toString(newNumberOfRound) + directionGamer)) {
45+ case g: Int =>
46+ g
47+ case _ =>
48+ 0
49+ }
50+ let numberOfGame = match getInteger(this, "numberGame") {
51+ case g: Int =>
52+ g
53+ case _ =>
54+ 0
55+ }
56+ let sumOfBank = match getInteger(this, (toString(numberOfGame) + "_bankOfGame")) {
57+ case g: Int =>
58+ g
59+ case _ =>
60+ 0
61+ }
62+ let sumGamerBets = match getInteger(this, ((toString(numberOfGame) + "_") + addressGamer)) {
63+ case s: Int =>
64+ s
65+ case _ =>
66+ 0
67+ }
68+ WriteSet([DataEntry(((toString(currentRound) + directionRate) + addressGamer), currentBet), DataEntry((toString(currentRound) + directionGamer), (numOfGamersCurrDirection + 1)), DataEntry((toString(numberOfGame) + "_bankOfGame"), (sumOfBank + currentBet)), DataEntry(((toString(numberOfGame) + "_") + addressGamer), (sumGamerBets + currentBet))])
69+ }
5770
5871
59-func getNumberGame () = match getInteger(this, "numberGame") {
72+func getBet (bet,round,addressGamer) = {
73+ let minBet = 1
74+ if ((round >= 1))
75+ then {
76+ let winnerOfPrevRound = match getString(this, "lastRoundWinner") {
77+ case w: String =>
78+ w
79+ case _ =>
80+ ""
81+ }
82+ let winnerFromPrevRound = match getString(this, (winnerOfPrevRound + addressGamer)) {
83+ case w: String =>
84+ w
85+ case _ =>
86+ ""
87+ }
88+ if (if ((round > 1))
89+ then (winnerFromPrevRound == "")
90+ else false)
91+ then ((minBet * round) * 2)
92+ else minBet
93+ }
94+ else minBet
95+ }
96+
97+
98+func isOppositeRate () = {
99+ let newNumberOfRound = match getInteger(this, "numberRound") {
100+ case a: Int =>
101+ a
102+ case _ =>
103+ 1
104+ }
105+ let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) {
106+ case g: Int =>
107+ g
108+ case _ =>
109+ 0
110+ }
111+ let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) {
112+ case g: Int =>
113+ g
114+ case _ =>
115+ 0
116+ }
117+ if ((numberOfGamersUp > 0))
118+ then (numberOfGamersDown > 0)
119+ else false
120+ }
121+
122+
123+func getNextNumberGame () = match getInteger(this, "numberGame") {
60124 case a: Int =>
61125 (a + 1)
62126 case _ =>
85149 then !(isGameStarted)
86150 else false)
87151 then {
88- let newNumberGame = getNumberGame()
89- WriteSet([DataEntry("numberGame", newNumberGame), DataEntry("startGame", !(isGameStarted)), DataEntry("numberRound", newNumberOfRound)])
152+ let newNumberGame = getNextNumberGame()
153+ WriteSet([DataEntry("numberGame", newNumberGame), DataEntry("startGame", !(isGameStarted)), DataEntry("numberRound", newNumberOfRound), DataEntry((toString(newNumberGame) + "_bankOfGame"), 0)])
90154 }
91- else if (if ((newNumberOfRound > 1))
155+ else if (if (if ((newNumberOfRound > 1))
92156 then (i.caller == this)
157+ else false)
158+ then !(isGameStarted)
93159 else false)
94160 then setWinnersPrevRound(newNumberOfRound, (toInt(randhash) % 1000))
95161 else throw("Only owner can start the game.")
98164
99165
100166 @Callable(i)
101-func forwardRound () = {
167+func stopGame () = {
102168 let isGameStarted = match getBoolean(this, "startGame") {
103169 case g: Boolean =>
104170 g
105171 case _ =>
106172 false
107173 }
108- let newNumberOfRound = match getInteger(this, "numberRound") {
109- case a: Int =>
110- a
111- case _ =>
112- 1
113- }
114- let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) {
115- case g: Int =>
116- g
117- case _ =>
118- 0
119- }
120- let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) {
121- case g: Int =>
122- g
123- case _ =>
124- 0
125- }
126- if (if (if (if ((numberOfGamersUp > 0))
174+ if (if (if (isOppositeRate())
127175 then (i.caller == this)
128176 else false)
129177 then isGameStarted
130- else false)
131- then (numberOfGamersDown > 0)
132178 else false)
133179 then WriteSet([DataEntry("startGame", !(isGameStarted))])
134180 else throw("Only owner can start the game.")
138184
139185 @Callable(i)
140186 func makeBetLess () = {
187+ let isGameStarted = match getBoolean(this, "startGame") {
188+ case g: Boolean =>
189+ g
190+ case _ =>
191+ false
192+ }
141193 let pmt = extract(i.payment)
142194 let addressGamer = toBase58String(i.caller.bytes)
143195 let currentRound = getCurrentNumberRound()
144196 let countBet = getBet(pmt.amount, currentRound, addressGamer)
145- if (if (!(isDefined(pmt.assetId)))
197+ if (if (if (!(isDefined(pmt.assetId)))
146198 then (pmt.amount >= countBet)
147199 else false)
148- then {
149- let newNumberOfRound = match getInteger(this, "numberRound") {
150- case a: Int =>
151- a
152- case _ =>
153- 1
154- }
155- let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) {
156- case g: Int =>
157- g
158- case _ =>
159- 0
160- }
161- WriteSet([DataEntry(((toString(currentRound) + "_less_") + addressGamer), pmt.amount), DataEntry((toString(currentRound) + "_countGamersDown"), (numberOfGamersDown + 1))])
162- }
200+ then isGameStarted
201+ else false)
202+ then setGamerBet(addressGamer, "_less_", "_countGamersDown", pmt.amount)
163203 else if ((countBet > pmt.amount))
164204 then throw("Payment must be more for the round!")
165205 else throw("works with waves only")
169209
170210 @Callable(i)
171211 func makeBetMore () = {
212+ let isGameStarted = match getBoolean(this, "startGame") {
213+ case g: Boolean =>
214+ g
215+ case _ =>
216+ false
217+ }
172218 let pmt = extract(i.payment)
173219 let addressGamer = toBase58String(i.caller.bytes)
174220 let currentRound = getCurrentNumberRound()
175221 let countBet = getBet(pmt.amount, currentRound, addressGamer)
176- if (if (!(isDefined(pmt.assetId)))
222+ if (if (if (!(isDefined(pmt.assetId)))
177223 then (pmt.amount >= countBet)
178224 else false)
179- then {
180- let newNumberOfRound = match getInteger(this, "numberRound") {
181- case a: Int =>
182- a
183- case _ =>
184- 1
185- }
186- let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) {
187- case g: Int =>
188- g
189- case _ =>
190- 0
191- }
192- WriteSet([DataEntry(((toString(currentRound) + "_more_") + addressGamer), pmt.amount), DataEntry((toString(currentRound) + "_countGamersUp"), (numberOfGamersUp + 1))])
193- }
225+ then isGameStarted
226+ else false)
227+ then setGamerBet(addressGamer, "_more_", "_countGamersUp", pmt.amount)
194228 else if ((countBet > pmt.amount))
195229 then throw("Payment must be more for the round!")
196230 else throw("works with waves only")
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let startRoundHeight = 5
55
66 func randomizer (inv) = {
77 let lastPlay = match getBinary(this, "lastPlay") {
88 case s: ByteVector =>
99 s
1010 case a: Unit =>
1111 base58'2ee4oFDYriWJ9EMeR'
1212 case _ =>
1313 throw()
1414 }
1515 let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))
1616 sha256(rand)
1717 }
1818
1919
2020 func setWinnersPrevRound (currRound,randhash) = {
2121 let prevNumberRound = (currRound - 1)
2222 if ((randhash > 500))
2323 then WriteSet([DataEntry("lastRoundWinner", (toString(prevNumberRound) + "_more_")), DataEntry("numberRound", currRound), DataEntry("startGame", true), DataEntry("randhash", randhash)])
2424 else WriteSet([DataEntry("lastRoundWinner", (toString(prevNumberRound) + "_less_")), DataEntry("numberRound", currRound), DataEntry("startGame", true), DataEntry("randhash", randhash)])
2525 }
2626
2727
2828 func getCurrentNumberRound () = match getInteger(this, "numberRound") {
2929 case a: Int =>
3030 a
3131 case _ =>
3232 1
3333 }
3434
3535
36-func getBet (bet,round,addressGamer) = if ((round >= 1))
37- then {
38- let winnerOfPrevRound = match getString(this, "lastRoundWinner") {
39- case w: String =>
40- w
41- case _ =>
42- ""
43- }
44- let winnerFromPrevRound = match getString(this, (winnerOfPrevRound + addressGamer)) {
45- case w: String =>
46- w
47- case _ =>
48- ""
49- }
50- if (if ((round > 1))
51- then (winnerFromPrevRound == "")
52- else false)
53- then (round * 2)
54- else 1
55- }
56- else 1
36+func setGamerBet (addressGamer,directionRate,directionGamer,currentBet) = {
37+ let currentRound = getCurrentNumberRound()
38+ let newNumberOfRound = match getInteger(this, "numberRound") {
39+ case a: Int =>
40+ a
41+ case _ =>
42+ 1
43+ }
44+ let numOfGamersCurrDirection = match getInteger(this, (toString(newNumberOfRound) + directionGamer)) {
45+ case g: Int =>
46+ g
47+ case _ =>
48+ 0
49+ }
50+ let numberOfGame = match getInteger(this, "numberGame") {
51+ case g: Int =>
52+ g
53+ case _ =>
54+ 0
55+ }
56+ let sumOfBank = match getInteger(this, (toString(numberOfGame) + "_bankOfGame")) {
57+ case g: Int =>
58+ g
59+ case _ =>
60+ 0
61+ }
62+ let sumGamerBets = match getInteger(this, ((toString(numberOfGame) + "_") + addressGamer)) {
63+ case s: Int =>
64+ s
65+ case _ =>
66+ 0
67+ }
68+ WriteSet([DataEntry(((toString(currentRound) + directionRate) + addressGamer), currentBet), DataEntry((toString(currentRound) + directionGamer), (numOfGamersCurrDirection + 1)), DataEntry((toString(numberOfGame) + "_bankOfGame"), (sumOfBank + currentBet)), DataEntry(((toString(numberOfGame) + "_") + addressGamer), (sumGamerBets + currentBet))])
69+ }
5770
5871
59-func getNumberGame () = match getInteger(this, "numberGame") {
72+func getBet (bet,round,addressGamer) = {
73+ let minBet = 1
74+ if ((round >= 1))
75+ then {
76+ let winnerOfPrevRound = match getString(this, "lastRoundWinner") {
77+ case w: String =>
78+ w
79+ case _ =>
80+ ""
81+ }
82+ let winnerFromPrevRound = match getString(this, (winnerOfPrevRound + addressGamer)) {
83+ case w: String =>
84+ w
85+ case _ =>
86+ ""
87+ }
88+ if (if ((round > 1))
89+ then (winnerFromPrevRound == "")
90+ else false)
91+ then ((minBet * round) * 2)
92+ else minBet
93+ }
94+ else minBet
95+ }
96+
97+
98+func isOppositeRate () = {
99+ let newNumberOfRound = match getInteger(this, "numberRound") {
100+ case a: Int =>
101+ a
102+ case _ =>
103+ 1
104+ }
105+ let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) {
106+ case g: Int =>
107+ g
108+ case _ =>
109+ 0
110+ }
111+ let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) {
112+ case g: Int =>
113+ g
114+ case _ =>
115+ 0
116+ }
117+ if ((numberOfGamersUp > 0))
118+ then (numberOfGamersDown > 0)
119+ else false
120+ }
121+
122+
123+func getNextNumberGame () = match getInteger(this, "numberGame") {
60124 case a: Int =>
61125 (a + 1)
62126 case _ =>
63127 1
64128 }
65129
66130
67131 @Callable(i)
68132 func startRound () = {
69133 let newNumberOfRound = match getInteger(this, "numberRound") {
70134 case a: Int =>
71135 (a + 1)
72136 case _ =>
73137 1
74138 }
75139 let randhash = randomizer(i)
76140 let isGameStarted = match getBoolean(this, "startGame") {
77141 case g: Boolean =>
78142 g
79143 case _ =>
80144 false
81145 }
82146 if (if (if ((newNumberOfRound == 1))
83147 then (i.caller == this)
84148 else false)
85149 then !(isGameStarted)
86150 else false)
87151 then {
88- let newNumberGame = getNumberGame()
89- WriteSet([DataEntry("numberGame", newNumberGame), DataEntry("startGame", !(isGameStarted)), DataEntry("numberRound", newNumberOfRound)])
152+ let newNumberGame = getNextNumberGame()
153+ WriteSet([DataEntry("numberGame", newNumberGame), DataEntry("startGame", !(isGameStarted)), DataEntry("numberRound", newNumberOfRound), DataEntry((toString(newNumberGame) + "_bankOfGame"), 0)])
90154 }
91- else if (if ((newNumberOfRound > 1))
155+ else if (if (if ((newNumberOfRound > 1))
92156 then (i.caller == this)
157+ else false)
158+ then !(isGameStarted)
93159 else false)
94160 then setWinnersPrevRound(newNumberOfRound, (toInt(randhash) % 1000))
95161 else throw("Only owner can start the game.")
96162 }
97163
98164
99165
100166 @Callable(i)
101-func forwardRound () = {
167+func stopGame () = {
102168 let isGameStarted = match getBoolean(this, "startGame") {
103169 case g: Boolean =>
104170 g
105171 case _ =>
106172 false
107173 }
108- let newNumberOfRound = match getInteger(this, "numberRound") {
109- case a: Int =>
110- a
111- case _ =>
112- 1
113- }
114- let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) {
115- case g: Int =>
116- g
117- case _ =>
118- 0
119- }
120- let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) {
121- case g: Int =>
122- g
123- case _ =>
124- 0
125- }
126- if (if (if (if ((numberOfGamersUp > 0))
174+ if (if (if (isOppositeRate())
127175 then (i.caller == this)
128176 else false)
129177 then isGameStarted
130- else false)
131- then (numberOfGamersDown > 0)
132178 else false)
133179 then WriteSet([DataEntry("startGame", !(isGameStarted))])
134180 else throw("Only owner can start the game.")
135181 }
136182
137183
138184
139185 @Callable(i)
140186 func makeBetLess () = {
187+ let isGameStarted = match getBoolean(this, "startGame") {
188+ case g: Boolean =>
189+ g
190+ case _ =>
191+ false
192+ }
141193 let pmt = extract(i.payment)
142194 let addressGamer = toBase58String(i.caller.bytes)
143195 let currentRound = getCurrentNumberRound()
144196 let countBet = getBet(pmt.amount, currentRound, addressGamer)
145- if (if (!(isDefined(pmt.assetId)))
197+ if (if (if (!(isDefined(pmt.assetId)))
146198 then (pmt.amount >= countBet)
147199 else false)
148- then {
149- let newNumberOfRound = match getInteger(this, "numberRound") {
150- case a: Int =>
151- a
152- case _ =>
153- 1
154- }
155- let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) {
156- case g: Int =>
157- g
158- case _ =>
159- 0
160- }
161- WriteSet([DataEntry(((toString(currentRound) + "_less_") + addressGamer), pmt.amount), DataEntry((toString(currentRound) + "_countGamersDown"), (numberOfGamersDown + 1))])
162- }
200+ then isGameStarted
201+ else false)
202+ then setGamerBet(addressGamer, "_less_", "_countGamersDown", pmt.amount)
163203 else if ((countBet > pmt.amount))
164204 then throw("Payment must be more for the round!")
165205 else throw("works with waves only")
166206 }
167207
168208
169209
170210 @Callable(i)
171211 func makeBetMore () = {
212+ let isGameStarted = match getBoolean(this, "startGame") {
213+ case g: Boolean =>
214+ g
215+ case _ =>
216+ false
217+ }
172218 let pmt = extract(i.payment)
173219 let addressGamer = toBase58String(i.caller.bytes)
174220 let currentRound = getCurrentNumberRound()
175221 let countBet = getBet(pmt.amount, currentRound, addressGamer)
176- if (if (!(isDefined(pmt.assetId)))
222+ if (if (if (!(isDefined(pmt.assetId)))
177223 then (pmt.amount >= countBet)
178224 else false)
179- then {
180- let newNumberOfRound = match getInteger(this, "numberRound") {
181- case a: Int =>
182- a
183- case _ =>
184- 1
185- }
186- let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) {
187- case g: Int =>
188- g
189- case _ =>
190- 0
191- }
192- WriteSet([DataEntry(((toString(currentRound) + "_more_") + addressGamer), pmt.amount), DataEntry((toString(currentRound) + "_countGamersUp"), (numberOfGamersUp + 1))])
193- }
225+ then isGameStarted
226+ else false)
227+ then setGamerBet(addressGamer, "_more_", "_countGamersUp", pmt.amount)
194228 else if ((countBet > pmt.amount))
195229 then throw("Payment must be more for the round!")
196230 else throw("works with waves only")
197231 }
198232
199233

github/deemru/w8io/026f985 
48.05 ms