Contract con_myluckynumber_v4


Contract Code

1 import currency
2 import con_gold_contract
3 import con_doug_lst001
4
5 game = Hash(default_value=0)
6 operator = Variable()
7
8 random.seed()
9
10 @construct
11 def seed(vk: str, jackpot:int):
12 operator.set(vk)
13 game['jackpot'] = jackpot
14 game['cost'] = 70
15 game['cost_2'] = 100
16 game['cost_3'] = 50
17 game['cost_4'] = 120
18 game['cost_game1_gold'] = 30000
19 game['cost_game1_gold_m'] = 150
20 game['cost_game1_douglas'] = 600
21 game['cost_game1_douglas_m'] = 7
22 game['m_1'] = 7
23 game['m_2'] = 5
24 game['m_3'] = 2
25 game['m_4'] = 25
26 game['m_5'] = 500
27 game['m_6'] = 7
28 game['m_7'] = 25
29 game['range1'] = 1
30 game['range2'] = 2
31 game['range3'] = 9
32 game['trasure_box'] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 30, 30, 30, 30, 50, 50, 50, 100, 100, 200, 500]
33 game['treasure_multiplier'] = [2,2,2,2,2,3,3,3,4,4,5]
34 game['treasure_gold_multiplier'] = [2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,5]
35 game['treasure_douglas_multiplier'] = [2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,5]
36
37 @export
38 def lucky_number(my_number: int):
39 caller = ctx.caller
40 amount = 0
41 assert currency.balance_of(caller
42 ) >= game['cost'], 'Not enough Balance to play!'
43
44 currency.transfer_from(game['cost'], operator.get(), caller)
45
46 game_number = random.randint(1, 100)
47 mystery_number = random.randint(1, 100)
48 second_chance = random.randint(1, 100)
49
50 game_multiplier = 0
51
52 if my_number == game_number:
53 if second_chance < 51:
54 game_number = random.randint(1, 100)
55
56 if abs(my_number-game_number) == game['range1']:
57 amount = game['cost'] * game['m_1']
58 game_multiplier = game['m_1']
59 currency.transfer_from(amount, caller, operator.get())
60 game[caller, 'last_lucky_number'] = my_number
61
62 if abs(my_number-game_number) == game['range2']:
63 amount = game['cost'] * game['m_2']
64 game_multiplier = game['m_2']
65 currency.transfer_from(amount, caller, operator.get())
66 game[caller, 'last_lucky_number'] = my_number
67
68 if abs(my_number-game_number) > game['range2'] and abs(my_number-game_number) < game['range3']:
69 amount = game['cost'] * game['m_3']
70 game_multiplier = game['m_3']
71 currency.transfer_from(amount, caller, operator.get())
72 game[caller, 'last_lucky_number'] = my_number
73
74 if my_number == game_number:
75 amount = game['cost'] * game['m_4']
76 game_multiplier = game['m_4']
77 currency.transfer_from(amount, caller, operator.get())
78 game[caller, 'last_lucky_number'] = my_number
79
80 if mystery_number == game_number:
81 if my_number == game_number:
82 amount = game['jackpot'] - amount
83 game_multiplier = game['m_5']
84 currency.transfer_from(amount, caller, operator.get())
85
86 return {'bet': game['cost'], 'win': amount, 'my_number': my_number, 'game_number': game_number, 'multiplier': game_multiplier, 'mystery': mystery_number, 'diff': abs(my_number-game_number)}
87
88 @export
89 def treasure_hunt(box: list):
90 caller = ctx.caller
91 amount = 0
92
93 assert len(box) <= 80, 'Bad game selection!'
94 assert box.count(1) == 5, 'To may selection!'
95
96 assert currency.balance_of(caller
97 ) >= game['cost_4'], 'Not enough Balance to play!'
98
99 currency.transfer_from(game['cost_4'], operator.get(), caller)
100
101 games_number = game['trasure_box']
102 multiplier = game['treasure_multiplier']
103 multiplier_position = random.randint(0, 79)
104 counter = 0
105 counter_prize = 0
106
107 random.shuffle(games_number)
108 random.shuffle(multiplier)
109 game_multiplier = random.choice(multiplier)
110
111 for x in box:
112 if counter < 80:
113 if x == 1 and counter_prize < 5:
114 amount = amount + games_number[counter]
115 counter_prize += 1
116
117 if multiplier_position == counter and x == 1 and counter_prize < 5:
118 amount = amount + (games_number[counter] * (game_multiplier - 1))
119
120 counter +=1
121
122 currency.transfer_from(amount, caller, operator.get())
123
124 return {'bet': game['cost_4'], 'win': amount, 'box': box, 'game': games_number, 'multiplier_position': multiplier_position, 'multiplier': game_multiplier}
125
126 @export
127 def treasure_hunt_douglas(box: list):
128 caller = ctx.caller
129 amount = 0
130
131 assert len(box) <= 80, 'Bad game selection!'
132 assert box.count(1) == 5, 'To may selection!'
133
134 con_doug_lst001.transfer_from(game['cost_game1_douglas'], operator.get(), caller)
135
136 games_number = game['trasure_box']
137 multiplier = game['treasure_douglas_multiplier']
138 multiplier_position = random.randint(0, 79)
139 counter = 0
140 counter_prize = 0
141
142 random.shuffle(games_number)
143 random.shuffle(multiplier)
144 game_multiplier = random.choice(multiplier)
145
146 for x in box:
147 if counter < 80:
148 if x == 1 and counter_prize < 5:
149 amount = amount + (games_number[counter] * game['cost_game1_douglas_m'])
150 counter_prize += 1
151
152 if multiplier_position == counter and x == 1 and counter_prize < 5:
153 amount = amount + ((games_number[counter] * game['cost_game1_douglas_m']) * (game_multiplier - 1))
154
155 counter +=1
156
157 con_doug_lst001.transfer_from(amount, caller, operator.get())
158
159 return {'bet': game['cost_game1_douglas'], 'gold': game['cost_game1_douglas_m'], 'win': amount, 'box': box, 'game': games_number, 'multiplier_position': multiplier_position, 'multiplier': game_multiplier}
160
161
162
163 @export
164 def treasure_hunt_gold(box: list):
165 caller = ctx.caller
166 amount = 0
167
168 assert len(box) <= 80, 'Bad game selection!'
169 assert box.count(1) == 5, 'To may selection!'
170
171 con_gold_contract.transfer_from(game['cost_game1_gold'], operator.get(), caller)
172
173 games_number = game['trasure_box']
174 multiplier = game['treasure_gold_multiplier']
175 multiplier_position = random.randint(0, 79)
176 counter = 0
177 counter_prize = 0
178
179 random.shuffle(games_number)
180 random.shuffle(multiplier)
181 game_multiplier = random.choice(multiplier)
182
183 for x in box:
184 if counter < 80:
185 if x == 1 and counter_prize < 5:
186 amount = amount + (games_number[counter] * game['cost_game1_gold_m'])
187 counter_prize += 1
188
189 if multiplier_position == counter and x == 1 and counter_prize < 5:
190 amount = amount + ((games_number[counter] * game['cost_game1_gold_m']) * (game_multiplier - 1))
191
192 counter +=1
193
194 con_gold_contract.transfer_from(amount, caller, operator.get())
195
196 return {'bet': game['cost_game1_gold'], 'gold': game['cost_game1_gold_m'], 'win': amount, 'box': box, 'game': games_number, 'multiplier_position': multiplier_position, 'multiplier': game_multiplier}
197
198
199 @export
200 def best_card(option: int, bets: list):
201 caller = ctx.caller
202 amount = 0
203 game_multiplier = 0
204
205 assert bets[0] == 1, 'No bet!'
206
207 if bets[1] == 0:
208 assert currency.balance_of(caller
209 ) >= game['cost_2'], 'Not enough Balance to play!'
210 currency.transfer_from(game['cost_2'], operator.get(), caller)
211
212 if bets[1] == 1:
213 assert currency.balance_of(caller
214 ) >= game['cost_2'] + game['cost_3'], 'Not enough Balance to play!'
215 currency.transfer_from(game['cost_2'] + game['cost_3'], operator.get(), caller)
216
217 deck = [2,3,4,5,6,7,8,9,10,11,12,13,14]
218 card = [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4]
219
220 random.choice(deck)
221 random.choice(card)
222
223 player = [random.choice(deck),random.choice(card)]
224 dealer = [random.choice(deck),random.choice(card)]
225
226 if option == 1:
227 if player[0] > dealer[0]:
228 amount = game['cost_2'] * 2
229 game_multiplier = 2
230 currency.transfer_from(amount, caller, operator.get())
231
232 if option == 2:
233 if player[0] < dealer[0]:
234 amount = game['cost_2'] * 2
235 game_multiplier = 2
236 currency.transfer_from(amount, caller, operator.get())
237
238 if player[0] == dealer[0]:
239 amount = game['cost_2'] * 1
240 game_multiplier = 1
241 currency.transfer_from(amount, caller, operator.get())
242
243 if bets[1] == 1:
244 if player[0] == dealer[0]:
245 amount = (game['cost_3'] * game['m_6']) + game['cost_2']
246 game_multiplier = game['m_6']
247 currency.transfer_from(amount, caller, operator.get())
248
249 if bets[1] == 1:
250 if player[0] == dealer[0]:
251 if player[1] == dealer[1]:
252 amount = (game['cost_3'] * game['m_7']) + game['cost_2']
253 game_multiplier = game['m_7']
254 currency.transfer_from(amount, caller, operator.get())
255
256 return {'option': option, 'player': player, 'dealer': dealer, 'win': amount, 'bets': bets, 'multiplier': game_multiplier}
257
258
259 @export
260 def set_values(field: str, value: int):
261 assert_owner()
262 game[field] = value
263
264 @export
265 def change_operator(vk: str):
266 assert_owner()
267 operator.set(vk)
268
269 def assert_owner():
270 assert ctx.caller == operator.get(), 'Only operator can call!'
271
272
273
274
275

Byte Code

e3000000000000000000000000050000004000000073f4000000640064016c005a00640064016c015a01640064016c025a02650364006402640364048d035a0465056402640564068d025a0665076a08830001006509650a64079c026408640984045a0b650c64028301650a640a9c01640b640c840483015a0d650c64028301650e640d9c01640e640f840483015a0f650c64028301650e640d9c0164106411840483015a10650c64028301650e640d9c0164126413840483015a11650c64028301650a650e64149c0264156416840483015a12650c640283016509650a64179c0264186419840483015a13650c640283016509641a9c01641b641c840483015a14641d641e84005a1564015300291fe9000000004eda14636f6e5f6d796c75636b796e756d6265725f7634da0467616d652903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086f70657261746f722902720500000072060000002902da02766bda076a61636b706f7463020000000000000002000000500000004300000073bc01000074006a017c00830101007c01740264013c006402740264033c006404740264053c006406740264073c006408740264093c00640a7402640b3c00640c7402640d3c00640e7402640f3c006410740264113c006410740264123c006413740264143c006415740264163c006417740264183c0064197402641a3c0064107402641b3c0064177402641c3c00641d7402641e3c0064157402641f3c006420740264213c00641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d641d64136413641364136413641364136413641364136413641364136413641364136413641364136413641364136413641364136422642264226422642264226422642264226422642364236423642364066406640664046404642464196750740264253c0064156415641564156415642664266426642764276413670b740264283c0064156415641564156415641564156415642664266426642664266427642764136710740264293c00641564156415641564156415641564156426642664266426642664276427641367107402642a3c0064005300292b4e7209000000e946000000da04636f7374e964000000da06636f73745f32e932000000da06636f73745f33e978000000da06636f73745f346930750000da0f636f73745f67616d65315f676f6c64e996000000da11636f73745f67616d65315f676f6c645f6d6958020000da12636f73745f67616d65315f646f75676c6173e907000000da14636f73745f67616d65315f646f75676c61735f6dda036d5f31e905000000da036d5f32e902000000da036d5f33e919000000da036d5f3469f4010000da036d5f35da036d5f36da036d5f37e901000000da0672616e676531da0672616e676532e909000000da0672616e676533e90a000000e91e000000e9c8000000da0b747261737572655f626f78e903000000e904000000da1374726561737572655f6d756c7469706c696572da1874726561737572655f676f6c645f6d756c7469706c696572da1b74726561737572655f646f75676c61735f6d756c7469706c6965722903da0a5f5f6f70657261746f72da03736574da065f5f67616d65290272080000007209000000a9007233000000da00da045f5f5f5f09000000733c00000000010a01080108010801080108010801080108010801080108010801080108010801080108010801080120012e012c0120010e011e0116011201140172350000002901da096d795f6e756d626572630100000000000000070000000900000043000000731002000074006a017d0164017d0274026a037c0183017404640219006b057324740564038301820174026a0674046402190074076a0883007c018303010074096a0a6404640583027d0374096a0a6404640583027d0474096a0a6404640583027d0564017d067c007c036b02727e7c0564066b00727e74096a0a6404640583027d03740b7c007c03180083017404640719006b0272c874046402190074046408190014007d027404640819007d0674026a067c027c0174076a088300830301007c0074047c01640966023c00740b7c007c03180083017404640a19006b02900172147404640219007404640b190014007d027404640b19007d0674026a067c027c0174076a088300830301007c0074047c01640966023c00740b7c007c03180083017404640a19006b0490017276740b7c007c03180083017404640c19006b00900172767404640219007404640d190014007d027404640d19007d0674026a067c027c0174076a088300830301007c0074047c01640966023c007c007c036b02900172b67404640219007404640e190014007d027404640e19007d0674026a067c027c0174076a088300830301007c0074047c01640966023c007c047c036b02900172f07c007c036b02900172f07404640f19007c0218007d027404641019007d0674026a067c027c0174076a088300830301007404640219007c027c007c037c067c04740b7c007c031800830164119c07530029124e7201000000720b0000007a1b4e6f7420656e6f7567682042616c616e636520746f20706c6179217222000000720c000000e93300000072230000007218000000da116c6173745f6c75636b795f6e756d6265727224000000721a0000007226000000721c000000721e0000007209000000721f0000002907da03626574da0377696e7236000000da0b67616d655f6e756d626572da0a6d756c7469706c696572da076d797374657279da0464696666290cda03637478da0663616c6c6572da0863757272656e6379da0a62616c616e63655f6f667232000000da0e417373657274696f6e4572726f72da0d7472616e736665725f66726f6d7230000000da03676574da0672616e646f6dda0772616e64696e74da03616273290772360000007240000000da06616d6f756e74723b000000da0e6d7973746572795f6e756d626572da0d7365636f6e645f6368616e6365da0f67616d655f6d756c7469706c696572723300000072330000007234000000da0c6c75636b795f6e756d6265722a00000073520000000002060104011401060116010c010c010c010401080108010c0114011001080112010c0116011001080112010c011a0112011001080112010c010a011001080112010c010a010a010c01080112010a010401724d0000002901da03626f786301000000000000000a0000000700000043000000733e01000074006a017d0164017d0274027c00830164026b01731e74036403830182017c006a046404830164056b027334740364068301820174056a067c0183017407640719006b05734e740364088301820174056a0874076407190074096a0a83007c01830301007407640919007d037407640a19007d04740b6a0c6401640b83027d0564017d0664017d07740b6a0d7c0383010100740b6a0d7c0483010100740b6a0e7c0483017d08786e7c0044005d667d097c0664026b0072ac7c0964046b0272dc7c0764056b0072dc7c027c037c06190017007d027c07640437007d077c057c066b026ff27c0964046b026ff27c0764056b009001720a7c027c037c0619007c0864041800140017007d027c06640437007d0671ac570074056a087c027c0174096a0a8300830301007407640719007c027c007c037c057c08640c9c065300290d4e7201000000e9500000007a134261642067616d652073656c656374696f6e21722200000072190000007a11546f206d61792073656c656374696f6e2172110000007a1b4e6f7420656e6f7567682042616c616e636520746f20706c617921722a000000722d000000e94f00000029067239000000723a000000724e0000007203000000da136d756c7469706c6965725f706f736974696f6e723c000000290f723f0000007240000000da036c656e7243000000da05636f756e7472410000007242000000723200000072440000007230000000724500000072460000007247000000da0773687566666c65da0663686f696365290a724e00000072400000007249000000da0c67616d65735f6e756d626572723c0000007251000000da07636f756e746572da0d636f756e7465725f7072697a65724c000000da0178723300000072330000007234000000da0d74726561737572655f68756e7457000000733600000000020601040114011601140106011601080108010c01040104010a010a010a010a01080110010c0108011a0114010c0112010a010401725a0000006301000000000000000a0000000800000043000000733a01000074006a017d0164017d0274027c00830164026b01731e74036403830182017c006a046404830164056b027334740364068301820174056a0674076407190074086a0983007c01830301007407640819007d037407640919007d04740a6a0b6401640a83027d0564017d0664017d07740a6a0c7c0383010100740a6a0c7c0483010100740a6a0d7c0483017d08787e7c0044005d767d097c0664026b0072927c0964046b0272ca7c0764056b0072ca7c027c037c0619007407640b1900140017007d027c07640437007d077c057c066b026fe07c0964046b026fe07c0764056b00900172007c027c037c0619007407640b190014007c0864041800140017007d027c06640437007d067192570074056a067c027c0174086a098300830301007407640719007407640b19007c027c007c037c057c08640c9c075300290d4e7201000000724f0000007a134261642067616d652073656c656374696f6e21722200000072190000007a11546f206d61792073656c656374696f6e217215000000722a000000722f0000007250000000721700000029077239000000da04676f6c64723a000000724e00000072030000007251000000723c000000290e723f0000007240000000725200000072430000007253000000da0f636f6e5f646f75675f6c737430303172440000007232000000723000000072450000007246000000724700000072540000007255000000290a724e000000724000000072490000007256000000723c000000725100000072570000007258000000724c0000007259000000723300000072330000007234000000da1574726561737572655f68756e745f646f75676c617376000000733a0000000002060104011401160110010601080108010c01040104010a010a010a010a01080110010a010a0108011a0102011a010c011201080108010401725d0000006301000000000000000a0000000800000043000000733a01000074006a017d0164017d0274027c00830164026b01731e74036403830182017c006a046404830164056b027334740364068301820174056a0674076407190074086a0983007c01830301007407640819007d037407640919007d04740a6a0b6401640a83027d0564017d0664017d07740a6a0c7c0383010100740a6a0c7c0483010100740a6a0d7c0483017d08787e7c0044005d767d097c0664026b0072927c0964046b0272ca7c0764056b0072ca7c027c037c0619007407640b1900140017007d027c07640437007d077c057c066b026fe07c0964046b026fe07c0764056b00900172007c027c037c0619007407640b190014007c0864041800140017007d027c06640437007d067192570074056a067c027c0174086a098300830301007407640719007407640b19007c027c007c037c057c08640c9c075300290d4e7201000000724f0000007a134261642067616d652073656c656374696f6e21722200000072190000007a11546f206d61792073656c656374696f6e217212000000722a000000722e0000007250000000721400000029077239000000725b000000723a000000724e00000072030000007251000000723c000000290e723f0000007240000000725200000072430000007253000000da11636f6e5f676f6c645f636f6e747261637472440000007232000000723000000072450000007246000000724700000072540000007255000000290a724e000000724000000072490000007256000000723c000000725100000072570000007258000000724c0000007259000000723300000072330000007234000000da1274726561737572655f68756e745f676f6c6497000000733a0000000002060104011401160110010601080108010c01040104010a010a010a010a01080110010a010a0108011a0102011a010c011201080108010401725f0000002902da066f7074696f6eda046265747363020000000000000009000000100000004300000073a002000074006a017d0264017d0364017d047c016401190064026b02732274026403830182017c016402190064016b02725e74036a047c0283017405640419006b057348740264058301820174036a0674056404190074076a0883007c02830301007c016402190064026b0272aa74036a047c02830174056404190074056406190017006b05738c740264058301820174036a06740564041900740564061900170074076a0883007c0283030100640764086409640a640b640c640d640e640f6410641164126413670d7d05640264026402640264076407640764076408640864086408640964096409640967107d0674096a0a7c058301010074096a0a7c068301010074096a0a7c05830174096a0a7c06830167027d0774096a0a7c05830174096a0a7c06830167027d087c0064026b02900172667c07640119007c08640119006b0490017266740564041900640714007d0364077d0474036a067c037c0274076a088300830301007c0064076b02900172a47c07640119007c08640119006b00900172a4740564041900640714007d0364077d0474036a067c037c0274076a088300830301007c07640119007c08640119006b02900172d8740564041900640214007d0364027d0474036a067c037c0274076a088300830301007c016402190064026b029002722a7c07640119007c08640119006b029002722a740564061900740564141900140074056404190017007d037405641419007d0474036a067c037c0274076a088300830301007c016402190064026b029002728e7c07640119007c08640119006b029002728e7c07640219007c08640219006b029002728e740564061900740564151900140074056404190017007d037405641519007d0474036a067c037c0274076a088300830301007c007c077c087c037c017c0464169c06530029174e720100000072220000007a074e6f2062657421720d0000007a1b4e6f7420656e6f7567682042616c616e636520746f20706c617921720f000000721b000000722b000000722c0000007219000000e9060000007216000000e90800000072250000007227000000e90b000000e90c000000e90d000000e90e0000007220000000722100000029067260000000da06706c61796572da066465616c6572723a0000007261000000723c000000290b723f000000724000000072430000007241000000724200000072320000007244000000723000000072450000007246000000725500000029097260000000726100000072400000007249000000724c000000da046465636bda046361726472680000007269000000723300000072330000007234000000da09626573745f63617264b8000000735c000000000206010401040114010c011401060116010c011001120112010c011e0124010a010a01140114010a0112010c01040112010a0112010c010401120112010c01040112010e0112011801080112010e01120112011801080112010601726c0000002902da056669656c64da0576616c756563020000000000000002000000030000004300000073120000007400830001007c0174017c003c006400530029014e2902da0e5f5f6173736572745f6f776e657272320000002902726d000000726e000000723300000072330000007234000000da0a7365745f76616c756573ea000000730400000000020601727000000029017208000000630100000000000000010000000200000043000000731400000074008300010074016a027c00830101006400530029014e2903726f0000007230000000723100000029017208000000723300000072330000007234000000da0f6368616e67655f6f70657261746f72f00000007304000000000206017271000000630000000000000000000000000200000043000000731a00000074006a0174026a0383006b02731674046401830182016400530029024e7a174f6e6c79206f70657261746f722063616e2063616c6c212905723f00000072400000007230000000724500000072430000007233000000723300000072330000007234000000726f000000f600000073020000000001726f00000029167241000000725e000000725c000000da04486173687232000000da085661726961626c6572300000007246000000da0473656564da03737472da03696e747235000000da085f5f6578706f7274724d000000da046c697374725a000000725d000000725f000000726c00000072700000007271000000726f0000007233000000723300000072330000007234000000da083c6d6f64756c653e01000000732a0000000801080108010e010c01080310210601102c0601101e0601102006011020060112310601120506011005