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:AAIDAAAAAAAAAAAAAAAIAAAAABBzdGFydFJvdW5kSGVpZ2h0AAAAAAAAAAAFAQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAACGxhc3RQbGF5BAAAAAckbWF0Y2gwCQAEHAAAAAIFAAAABHRoaXMCAAAACGxhc3RQbGF5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0BAAAAAFhBQAAAAckbWF0Y2gwAQAAAAxXYXZlc0xvdHRvVjIJAQAAAAV0aHJvdwAAAAAEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACBQAAAAhsYXN0UGxheQgFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABmg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tZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAHQm9vbGVhbgQAAAABZwUAAAAHJG1hdGNoMAUAAAABZwcEAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50BAAAAAxhZGRyZXNzR2FtZXIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAMY3VycmVudFJvdW5kCQEAAAAVZ2V0Q3VycmVudE51bWJlclJvdW5kAAAAAAQAAAAIY291bnRCZXQJAQAAAAZnZXRCZXQAAAADCAUAAAADcG10AAAABmFtb3VudAUAAAAMY3VycmVudFJvdW5kBQAAAAxhZGRyZXNzR2FtZXIDAwMJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAkAAGcAAAACCAUAAAADcG10AAAABmFtb3VudAUAAAAIY291bnRCZXQHBQAAAA1pc0dhbWVTdGFydGVkBwkBAAAAC3NldEdhbWVyQmV0AAAABAUAAAAMYWRkcmVzc0dhbWVyAgAAAAZfbW9yZV8CAAAADl9jb3VudEdhbWVyc1VwCAUAAAADcG10AAAABmFtb3VudAMJAABmAAAAAgUAAAAIY291bnRCZXQIBQAAAANwbXQAAAAGYW1vdW50CQAAAgAAAAECAAAAI1BheW1lbnQgbXVzdCBiZSBtb3JlIGZvciB0aGUgcm91bmQhCQAAAgAAAAECAAAAFXdvcmtzIHdpdGggd2F2ZXMgb25seQAAAACJRukz", "chainId": 84, "height": 663080, "spentComplexity": 0 } View: original | compacted Prev: 4vBWRhoh2qb5iSri55czCtQBfNSx8RLca2T18g7CV3s9 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
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 | + | } | |
57 | 70 | ||
58 | 71 | ||
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") { | |
60 | 124 | case a: Int => | |
61 | 125 | (a + 1) | |
62 | 126 | case _ => | |
85 | 149 | then !(isGameStarted) | |
86 | 150 | else false) | |
87 | 151 | then { | |
88 | - | let newNumberGame = | |
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)]) | |
90 | 154 | } | |
91 | - | else if (if ((newNumberOfRound > 1)) | |
155 | + | else if (if (if ((newNumberOfRound > 1)) | |
92 | 156 | then (i.caller == this) | |
157 | + | else false) | |
158 | + | then !(isGameStarted) | |
93 | 159 | else false) | |
94 | 160 | then setWinnersPrevRound(newNumberOfRound, (toInt(randhash) % 1000)) | |
95 | 161 | else throw("Only owner can start the game.") | |
98 | 164 | ||
99 | 165 | ||
100 | 166 | @Callable(i) | |
101 | - | func | |
167 | + | func stopGame () = { | |
102 | 168 | let isGameStarted = match getBoolean(this, "startGame") { | |
103 | 169 | case g: Boolean => | |
104 | 170 | g | |
105 | 171 | case _ => | |
106 | 172 | false | |
107 | 173 | } | |
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()) | |
127 | 175 | then (i.caller == this) | |
128 | 176 | else false) | |
129 | 177 | then isGameStarted | |
130 | - | else false) | |
131 | - | then (numberOfGamersDown > 0) | |
132 | 178 | else false) | |
133 | 179 | then WriteSet([DataEntry("startGame", !(isGameStarted))]) | |
134 | 180 | else throw("Only owner can start the game.") | |
138 | 184 | ||
139 | 185 | @Callable(i) | |
140 | 186 | func makeBetLess () = { | |
187 | + | let isGameStarted = match getBoolean(this, "startGame") { | |
188 | + | case g: Boolean => | |
189 | + | g | |
190 | + | case _ => | |
191 | + | false | |
192 | + | } | |
141 | 193 | let pmt = extract(i.payment) | |
142 | 194 | let addressGamer = toBase58String(i.caller.bytes) | |
143 | 195 | let currentRound = getCurrentNumberRound() | |
144 | 196 | let countBet = getBet(pmt.amount, currentRound, addressGamer) | |
145 | - | if (if (!(isDefined(pmt.assetId))) | |
197 | + | if (if (if (!(isDefined(pmt.assetId))) | |
146 | 198 | then (pmt.amount >= countBet) | |
147 | 199 | 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) | |
163 | 203 | else if ((countBet > pmt.amount)) | |
164 | 204 | then throw("Payment must be more for the round!") | |
165 | 205 | else throw("works with waves only") | |
169 | 209 | ||
170 | 210 | @Callable(i) | |
171 | 211 | func makeBetMore () = { | |
212 | + | let isGameStarted = match getBoolean(this, "startGame") { | |
213 | + | case g: Boolean => | |
214 | + | g | |
215 | + | case _ => | |
216 | + | false | |
217 | + | } | |
172 | 218 | let pmt = extract(i.payment) | |
173 | 219 | let addressGamer = toBase58String(i.caller.bytes) | |
174 | 220 | let currentRound = getCurrentNumberRound() | |
175 | 221 | let countBet = getBet(pmt.amount, currentRound, addressGamer) | |
176 | - | if (if (!(isDefined(pmt.assetId))) | |
222 | + | if (if (if (!(isDefined(pmt.assetId))) | |
177 | 223 | then (pmt.amount >= countBet) | |
178 | 224 | 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) | |
194 | 228 | else if ((countBet > pmt.amount)) | |
195 | 229 | then throw("Payment must be more for the round!") | |
196 | 230 | else throw("works with waves only") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let startRoundHeight = 5 | |
5 | 5 | ||
6 | 6 | func randomizer (inv) = { | |
7 | 7 | let lastPlay = match getBinary(this, "lastPlay") { | |
8 | 8 | case s: ByteVector => | |
9 | 9 | s | |
10 | 10 | case a: Unit => | |
11 | 11 | base58'2ee4oFDYriWJ9EMeR' | |
12 | 12 | case _ => | |
13 | 13 | throw() | |
14 | 14 | } | |
15 | 15 | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
16 | 16 | sha256(rand) | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func setWinnersPrevRound (currRound,randhash) = { | |
21 | 21 | let prevNumberRound = (currRound - 1) | |
22 | 22 | if ((randhash > 500)) | |
23 | 23 | then WriteSet([DataEntry("lastRoundWinner", (toString(prevNumberRound) + "_more_")), DataEntry("numberRound", currRound), DataEntry("startGame", true), DataEntry("randhash", randhash)]) | |
24 | 24 | else WriteSet([DataEntry("lastRoundWinner", (toString(prevNumberRound) + "_less_")), DataEntry("numberRound", currRound), DataEntry("startGame", true), DataEntry("randhash", randhash)]) | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getCurrentNumberRound () = match getInteger(this, "numberRound") { | |
29 | 29 | case a: Int => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | 1 | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
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 | + | } | |
57 | 70 | ||
58 | 71 | ||
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") { | |
60 | 124 | case a: Int => | |
61 | 125 | (a + 1) | |
62 | 126 | case _ => | |
63 | 127 | 1 | |
64 | 128 | } | |
65 | 129 | ||
66 | 130 | ||
67 | 131 | @Callable(i) | |
68 | 132 | func startRound () = { | |
69 | 133 | let newNumberOfRound = match getInteger(this, "numberRound") { | |
70 | 134 | case a: Int => | |
71 | 135 | (a + 1) | |
72 | 136 | case _ => | |
73 | 137 | 1 | |
74 | 138 | } | |
75 | 139 | let randhash = randomizer(i) | |
76 | 140 | let isGameStarted = match getBoolean(this, "startGame") { | |
77 | 141 | case g: Boolean => | |
78 | 142 | g | |
79 | 143 | case _ => | |
80 | 144 | false | |
81 | 145 | } | |
82 | 146 | if (if (if ((newNumberOfRound == 1)) | |
83 | 147 | then (i.caller == this) | |
84 | 148 | else false) | |
85 | 149 | then !(isGameStarted) | |
86 | 150 | else false) | |
87 | 151 | then { | |
88 | - | let newNumberGame = | |
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)]) | |
90 | 154 | } | |
91 | - | else if (if ((newNumberOfRound > 1)) | |
155 | + | else if (if (if ((newNumberOfRound > 1)) | |
92 | 156 | then (i.caller == this) | |
157 | + | else false) | |
158 | + | then !(isGameStarted) | |
93 | 159 | else false) | |
94 | 160 | then setWinnersPrevRound(newNumberOfRound, (toInt(randhash) % 1000)) | |
95 | 161 | else throw("Only owner can start the game.") | |
96 | 162 | } | |
97 | 163 | ||
98 | 164 | ||
99 | 165 | ||
100 | 166 | @Callable(i) | |
101 | - | func | |
167 | + | func stopGame () = { | |
102 | 168 | let isGameStarted = match getBoolean(this, "startGame") { | |
103 | 169 | case g: Boolean => | |
104 | 170 | g | |
105 | 171 | case _ => | |
106 | 172 | false | |
107 | 173 | } | |
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()) | |
127 | 175 | then (i.caller == this) | |
128 | 176 | else false) | |
129 | 177 | then isGameStarted | |
130 | - | else false) | |
131 | - | then (numberOfGamersDown > 0) | |
132 | 178 | else false) | |
133 | 179 | then WriteSet([DataEntry("startGame", !(isGameStarted))]) | |
134 | 180 | else throw("Only owner can start the game.") | |
135 | 181 | } | |
136 | 182 | ||
137 | 183 | ||
138 | 184 | ||
139 | 185 | @Callable(i) | |
140 | 186 | func makeBetLess () = { | |
187 | + | let isGameStarted = match getBoolean(this, "startGame") { | |
188 | + | case g: Boolean => | |
189 | + | g | |
190 | + | case _ => | |
191 | + | false | |
192 | + | } | |
141 | 193 | let pmt = extract(i.payment) | |
142 | 194 | let addressGamer = toBase58String(i.caller.bytes) | |
143 | 195 | let currentRound = getCurrentNumberRound() | |
144 | 196 | let countBet = getBet(pmt.amount, currentRound, addressGamer) | |
145 | - | if (if (!(isDefined(pmt.assetId))) | |
197 | + | if (if (if (!(isDefined(pmt.assetId))) | |
146 | 198 | then (pmt.amount >= countBet) | |
147 | 199 | 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) | |
163 | 203 | else if ((countBet > pmt.amount)) | |
164 | 204 | then throw("Payment must be more for the round!") | |
165 | 205 | else throw("works with waves only") | |
166 | 206 | } | |
167 | 207 | ||
168 | 208 | ||
169 | 209 | ||
170 | 210 | @Callable(i) | |
171 | 211 | func makeBetMore () = { | |
212 | + | let isGameStarted = match getBoolean(this, "startGame") { | |
213 | + | case g: Boolean => | |
214 | + | g | |
215 | + | case _ => | |
216 | + | false | |
217 | + | } | |
172 | 218 | let pmt = extract(i.payment) | |
173 | 219 | let addressGamer = toBase58String(i.caller.bytes) | |
174 | 220 | let currentRound = getCurrentNumberRound() | |
175 | 221 | let countBet = getBet(pmt.amount, currentRound, addressGamer) | |
176 | - | if (if (!(isDefined(pmt.assetId))) | |
222 | + | if (if (if (!(isDefined(pmt.assetId))) | |
177 | 223 | then (pmt.amount >= countBet) | |
178 | 224 | 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) | |
194 | 228 | else if ((countBet > pmt.amount)) | |
195 | 229 | then throw("Payment must be more for the round!") | |
196 | 230 | else throw("works with waves only") | |
197 | 231 | } | |
198 | 232 | ||
199 | 233 |
github/deemru/w8io/026f985 48.05 ms ◑