Contract con_poker_card_games_v3
Creator | ae9cfa894495930b8d2f1707ab936325b5c848ace677bb8ba41dfe7dcdb3e3e6 |
Creation Hash | f6438d7d159d4571264b786582c2f125f7ced3ccceb3d0df2402b8d25af60447 |
Created On | 880 days ago - 12/17/2021, 8:36:41 PM UTC+0 |
Contract Code
1
# con_poker_card_games_v3
2
import con_phi_lst001 as phi
3
I = importlib
4
5
phi_balances = ForeignHash(foreign_contract='con_phi_lst001', foreign_name='balances')
6
7
games = Hash(default_value=None)
8
hands = Hash(default_value=None)
9
game_names = Hash(default_value=None)
10
players_games = Hash(default_value=[])
11
players_invites = Hash(default_value=[])
12
13
player_metadata_contract = Variable()
14
game_controller_contract = Variable()
15
hand_controller_contract = Variable()
16
17
owner = Variable()
18
19
20
@construct
21
def seed():
22
owner.set(ctx.caller)
23
player_metadata_contract.set('con_gamma_phi_profile_v4')
24
hand_controller_contract.set('con_poker_hand_controller_v1')
25
game_controller_contract.set('con_poker_game_controller_v1')
26
27
@export
28
def update_player_metadata_contract(contract: str):
29
assert ctx.caller == owner.get(), 'Only the owner can call update_player_metadata_contract()'
30
player_metadata_contract.set(contract)
31
32
33
@export
34
def update_hand_controller_contract(contract: str):
35
assert ctx.caller == owner.get(), 'Only the owner can call update_player_metadata_contract()'
36
hand_controller_contract.set(contract)
37
38
39
@export
40
def update_game_controller_contract(contract: str):
41
assert ctx.caller == owner.get(), 'Only the owner can call update_player_metadata_contract()'
42
game_controller_contract.set(contract)
43
44
45
@export
46
def add_chips_to_game(game_id: str, amount: float):
47
player = ctx.caller
48
module = I.import_module(game_controller_contract.get())
49
module.add_chips_to_game(
50
game_id=game_id,
51
amount=amount,
52
player=player,
53
games=games,
54
)
55
assert phi_balances[player, ctx.this] >= amount, 'You have not approved enough for this amount of chips'
56
phi.transfer_from(amount, ctx.this, player)
57
58
@export
59
def withdraw_chips_from_game(game_id: str, amount: float):
60
player = ctx.caller
61
module = I.import_module(game_controller_contract.get())
62
module.withdraw_chips_from_game(
63
game_id=game_id,
64
amount=amount,
65
player=player,
66
games=games,
67
)
68
phi.transfer(
69
amount=amount,
70
to=player
71
)
72
73
74
@export
75
def respond_to_invite(game_id: str, accept: bool):
76
player = ctx.caller
77
module = I.import_module(game_controller_contract.get())
78
module.respond_to_invite(
79
game_id=game_id,
80
accept=accept,
81
player=player,
82
games=games,
83
players_invites=players_invites,
84
players_games=players_games
85
)
86
87
88
@export
89
def decline_all_invites():
90
# Nuclear option
91
player = ctx.caller
92
module = I.import_module(game_controller_contract.get())
93
module.decline_all_invites(
94
player=player,
95
players_invites=players_invites
96
)
97
98
99
@export
100
def start_game(name: str,
101
other_players: list,
102
game_config: dict,
103
public: bool = False) -> str:
104
105
creator = ctx.caller
106
module = I.import_module(game_controller_contract.get())
107
return module.start_game(
108
name=name,
109
other_players=other_players,
110
game_config=game_config,
111
creator=creator,
112
games=games,
113
players_games=players_games,
114
players_invites=players_invites,
115
game_names=game_names,
116
public=public
117
)
118
119
120
@export
121
def add_player_to_game(game_id: str, player_to_add: str):
122
player = ctx.caller
123
module = I.import_module(game_controller_contract.get())
124
module.add_player_to_game(
125
game_id=game_id,
126
player_to_add=player_to_add,
127
player=player,
128
games=games,
129
players_invites=players_invites,
130
)
131
132
133
@export
134
def leave_game(game_id: str):
135
player = ctx.caller
136
module = I.import_module(game_controller_contract.get())
137
module.leave_game(
138
game_id=game_id,
139
player=player,
140
games=games,
141
players_games=players_games,
142
hands=hands,
143
hand_controller_contract=hand_controller_contract.get()
144
)
145
146
147
@export
148
def start_hand(game_id: str) -> str:
149
dealer = ctx.caller
150
module = I.import_module(hand_controller_contract.get())
151
return module.start_hand(
152
game_id=game_id,
153
dealer=dealer,
154
games=games,
155
hands=hands,
156
)
157
158
159
@export
160
def ante_up(hand_id: str):
161
player = ctx.caller
162
module = I.import_module(hand_controller_contract.get())
163
module.ante_up(
164
hand_id=hand_id,
165
player=player,
166
games=games,
167
hands=hands,
168
)
169
170
171
@export
172
def deal_cards(hand_id: str):
173
dealer = ctx.caller
174
module = I.import_module(hand_controller_contract.get())
175
player_metadata = ForeignHash(foreign_contract=player_metadata_contract.get(), foreign_name='metadata')
176
module.deal_cards(
177
hand_id=hand_id,
178
dealer=dealer,
179
games=games,
180
hands=hands,
181
player_metadata=player_metadata
182
)
183
184
185
@export
186
def reveal_otp(hand_id: str, pad: int, salt: int, index: int):
187
player = ctx.caller
188
module = I.import_module(hand_controller_contract.get())
189
module.reveal_otp(
190
hand_id=hand_id,
191
pad=pad,
192
salt=salt,
193
index=index,
194
player=player,
195
hands=hands,
196
)
197
198
199
@export
200
def reveal(hand_id: str, index: int) -> str:
201
module = I.import_module(hand_controller_contract.get())
202
return module.reveal(
203
hand_id=hand_id,
204
index=index,
205
hands=hands,
206
)
207
208
209
@export
210
def bet_check_or_fold(hand_id: str, bet: float):
211
player = ctx.caller
212
module = I.import_module(hand_controller_contract.get())
213
module.bet_check_or_fold(
214
hand_id=hand_id,
215
bet=bet,
216
player=player,
217
games=games,
218
hands=hands,
219
)
220
221
222
@export
223
def verify_hand(hand_id: str, player_hand_str: str) -> str:
224
player = ctx.caller
225
module = I.import_module(hand_controller_contract.get())
226
return module.verify_hand(
227
hand_id=hand_id,
228
player_hand_str=player_hand_str,
229
player=player,
230
games=games,
231
hands=hands,
232
)
233
234
235
@export
236
def payout_hand(hand_id: str):
237
module = I.import_module(hand_controller_contract.get())
238
module.payout_hand(
239
hand_id=hand_id,
240
games=games,
241
hands=hands,
242
)
243
244
245
@export
246
def emergency_withdraw(amount: float):
247
assert ctx.caller == owner.get(), 'Only the owner can call emergency_withdraw()'
248
phi.transfer(
249
amount=amount,
250
to=ctx.caller
251
)
252
253
254
@export
255
def change_ownership(new_owner: str):
256
assert ctx.caller == owner.get(), 'Only the owner can change ownership!'
257
owner.set(new_owner)
Byte Code
e300000000000000000000000008000000400000007374020000640064016c005a0165025a036504640264036404640564068d045a05650664016404640764088d035a07650664016404640964088d035a08650664016404640a64088d035a09650667006404640b64088d035a0a650667006404640c64088d035a0b650c6404640d640e8d025a0d650c6404640f640e8d025a0e650c64046410640e8d025a0f650c64046411640e8d025a106412641384005a11651264048301651364149c0164156416840483015a14651264048301651364149c0164176418840483015a15651264048301651364149c016419641a840483015a1665126404830165136517641b9c02641c641d840483015a1865126404830165136517641b9c02641e641f840483015a196512640483016513651a64209c0264216422840483015a1b65126404830164236424840083015a1c651264048301644b6513651d651e651a651364269c0564276428840583015a1f6512640483016513651364299c02642a642b840483015a206512640483016513642c9c01642d642e840483015a2165126404830165136513642f9c0264306431840483015a22651264048301651364329c0164336434840483015a23651264048301651364329c0164356436840483015a24651264048301651365256525652564379c0464386439840483015a26651264048301651365256513643a9c03643b643c840483015a2765126404830165136517643d9c02643e643f840483015a2865126404830165136513651364409c0364416442840483015a29651264048301651364329c0164436444840483015a2a651264048301651764459c0164466447840483015a2b651264048301651364489c016449644a840483015a2c64015300294ce9000000004eda0e636f6e5f7068695f6c7374303031da0862616c616e636573da17636f6e5f706f6b65725f636172645f67616d65735f7633da0c7068695f62616c616e6365732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65da08636f6e7472616374da046e616d65da0567616d65732903da0d64656661756c745f76616c756572080000007209000000da0568616e6473da0a67616d655f6e616d6573da0d706c61796572735f67616d6573da0f706c61796572735f696e7669746573da18706c617965725f6d657461646174615f636f6e7472616374290272080000007209000000da1867616d655f636f6e74726f6c6c65725f636f6e7472616374da1868616e645f636f6e74726f6c6c65725f636f6e7472616374da056f776e6572630000000000000000000000000200000043000000732e00000074006a0174026a038301010074046a0164018301010074056a0164028301010074066a016403830101006400530029044eda18636f6e5f67616d6d615f7068695f70726f66696c655f7634da1c636f6e5f706f6b65725f68616e645f636f6e74726f6c6c65725f7631da1c636f6e5f706f6b65725f67616d655f636f6e74726f6c6c65725f76312907da075f5f6f776e6572da03736574da03637478da0663616c6c6572da1a5f5f706c617965725f6d657461646174615f636f6e7472616374da1a5f5f68616e645f636f6e74726f6c6c65725f636f6e7472616374da1a5f5f67616d655f636f6e74726f6c6c65725f636f6e7472616374a900721e000000721e000000da00da045f5f5f5f19000000730800000000010c010a010a01722000000029017208000000630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174056a067c00830101006400530029024e7a394f6e6c7920746865206f776e65722063616e2063616c6c207570646174655f706c617965725f6d657461646174615f636f6e7472616374282929077219000000721a0000007217000000da03676574da0e417373657274696f6e4572726f72721b000000721800000029017208000000721e000000721e000000721f000000da1f7570646174655f706c617965725f6d657461646174615f636f6e74726163742000000073060000000002100106017223000000630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174056a067c00830101006400530029024e7a394f6e6c7920746865206f776e65722063616e2063616c6c207570646174655f706c617965725f6d657461646174615f636f6e7472616374282929077219000000721a000000721700000072210000007222000000721c000000721800000029017208000000721e000000721e000000721f000000da1f7570646174655f68616e645f636f6e74726f6c6c65725f636f6e74726163742700000073060000000002100106017224000000630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174056a067c00830101006400530029024e7a394f6e6c7920746865206f776e65722063616e2063616c6c207570646174655f706c617965725f6d657461646174615f636f6e7472616374282929077219000000721a000000721700000072210000007222000000721d000000721800000029017208000000721e000000721e000000721f000000da1f7570646174655f67616d655f636f6e74726f6c6c65725f636f6e74726163742e000000730600000000021001060172250000002902da0767616d655f6964da06616d6f756e74630200000000000000040000000600000043000000735400000074006a017d0274026a0374046a05830083017d037c036a067c007c017c02740764018d04010074087c0274006a09660219007c016b057340740a640283018201740b6a0c7c0174006a097c02830301006400530029034e290472260000007227000000da06706c61796572720a0000007a35596f752068617665206e6f7420617070726f76656420656e6f75676820666f72207468697320616d6f756e74206f66206368697073290d7219000000721a000000da0149da0d696d706f72745f6d6f64756c65721d0000007221000000da116164645f63686970735f746f5f67616d65da075f5f67616d6573da0e5f5f7068695f62616c616e636573da04746869737222000000da03706869da0d7472616e736665725f66726f6d2904722600000072270000007228000000da066d6f64756c65721e000000721e000000721f000000722b00000035000000730e000000000206010e010a0108010c010e01722b000000630200000000000000040000000600000043000000733800000074006a017d0274026a0374046a05830083017d037c036a067c007c017c02740764018d04010074086a097c017c0264028d0201006400530029034e2904722600000072270000007228000000720a00000029027227000000da02746f290a7219000000721a0000007229000000722a000000721d0000007221000000da1877697468647261775f63686970735f66726f6d5f67616d65722c000000722f000000da087472616e7366657229047226000000722700000072280000007231000000721e000000721e000000721f000000723300000040000000730a000000000206010e0108010a01723300000029027226000000da06616363657074630200000000000000040000000800000043000000732e00000074006a017d0274026a0374046a05830083017d037c036a067c007c017c0274077408740964018d0601006400530029024e2906722600000072350000007228000000720a000000720f000000720e000000290a7219000000721a0000007229000000722a000000721d0000007221000000da11726573706f6e645f746f5f696e76697465722c000000da115f5f706c61796572735f696e7669746573da0f5f5f706c61796572735f67616d657329047226000000723500000072280000007231000000721e000000721e000000721f000000723600000049000000730a000000000206010e010a0104017236000000630000000000000000020000000400000043000000732600000074006a017d0074026a0374046a05830083017d017c016a067c00740764018d0201006400530029024e29027228000000720f00000029087219000000721a0000007229000000722a000000721d0000007221000000da136465636c696e655f616c6c5f696e76697465737237000000290272280000007231000000721e000000721e000000721f0000007239000000520000007306000000000206010e0172390000004629057209000000da0d6f746865725f706c6179657273da0b67616d655f636f6e666967da067075626c6963da0672657475726e630400000000000000060000000b00000043000000733000000074006a017d0474026a0374046a05830083017d057c056a067c007c017c027c04740774087409740a7c0364018d09530029024e29097209000000723a000000723b000000da0763726561746f72720a000000720e000000720f000000720d000000723c000000290b7219000000721a0000007229000000722a000000721d0000007221000000da0a73746172745f67616d65722c00000072380000007237000000da0c5f5f67616d655f6e616d657329067209000000723a000000723b000000723c000000723e0000007231000000721e000000721e000000721f000000723f0000005a000000730c000000000306010e01080106010401723f00000029027226000000da0d706c617965725f746f5f616464630200000000000000040000000700000043000000732c00000074006a017d0274026a0374046a05830083017d037c036a067c007c017c027407740864018d0501006400530029024e2905722600000072410000007228000000720a000000720f00000029097219000000721a0000007229000000722a000000721d0000007221000000da126164645f706c617965725f746f5f67616d65722c000000723700000029047226000000724100000072280000007231000000721e000000721e000000721f0000007242000000650000007308000000000206010e010801724200000029017226000000630100000000000000030000000800000043000000733200000074006a017d0174026a0374046a05830083017d027c026a067c007c01740774087409740a6a05830064018d0601006400530029024e290672260000007228000000720a000000720e000000720c0000007212000000290b7219000000721a0000007229000000722a000000721d0000007221000000da0a6c656176655f67616d65722c0000007238000000da075f5f68616e6473721c0000002903722600000072280000007231000000721e000000721e000000721f00000072430000006d000000730a000000000206010e010a010401724300000029027226000000723d000000630100000000000000030000000600000043000000732600000074006a017d0174026a0374046a05830083017d027c026a067c007c017407740864018d04530029024e29047226000000da066465616c6572720a000000720c00000029097219000000721a0000007229000000722a000000721c0000007221000000da0a73746172745f68616e64722c00000072440000002903722600000072450000007231000000721e000000721e000000721f0000007246000000760000007308000000000206010e010a0172460000002901da0768616e645f6964630100000000000000030000000600000043000000732a00000074006a017d0174026a0374046a05830083017d027c026a067c007c017407740864018d0401006400530029024e290472470000007228000000720a000000720c00000029097219000000721a0000007229000000722a000000721c0000007221000000da07616e74655f7570722c00000072440000002903724700000072280000007231000000721e000000721e000000721f00000072480000007e0000007306000000000206010e017248000000630100000000000000040000000700000043000000734000000074006a017d0174026a0374046a05830083017d02740674076a05830064016402640364048d047d037c026a087c007c017409740a7c0364058d0501006400530029064eda086d657461646174617204000000da0f706c617965725f6d6574616461746129047206000000720700000072080000007209000000290572470000007245000000720a000000720c000000724a000000290b7219000000721a0000007229000000722a000000721c0000007221000000da0b466f726569676e48617368721b000000da0a6465616c5f6361726473722c00000072440000002904724700000072450000007231000000da115f5f706c617965725f6d65746164617461721e000000721e000000721f000000724c00000086000000730e000000000206010e01020108010a010a01724c00000029047247000000da03706164da0473616c74da05696e646578630400000000000000060000000800000043000000732e00000074006a017d0474026a0374046a05830083017d057c056a067c007c017c027c037c04740764018d0601006400530029024e29067247000000724e000000724f00000072500000007228000000720c00000029087219000000721a0000007229000000722a000000721c0000007221000000da0a72657665616c5f6f7470724400000029067247000000724e000000724f000000725000000072280000007231000000721e000000721e000000721f0000007251000000910000007308000000000206010e010c017251000000290372470000007250000000723d000000630200000000000000030000000500000043000000731e00000074006a0174026a03830083017d027c026a047c007c01740564018d03530029024e290372470000007250000000720c00000029067229000000722a000000721c0000007221000000da0672657665616c72440000002903724700000072500000007231000000721e000000721e000000721f000000725200000099000000730400000000020e01725200000029027247000000da03626574630200000000000000040000000700000043000000732c00000074006a017d0274026a0374046a05830083017d037c036a067c007c017c027407740864018d0501006400530029024e2905724700000072530000007228000000720a000000720c00000029097219000000721a0000007229000000722a000000721c0000007221000000da116265745f636865636b5f6f725f666f6c64722c000000724400000029047247000000725300000072280000007231000000721e000000721e000000721f00000072540000009f0000007308000000000206010e010a01725400000029037247000000da0f706c617965725f68616e645f737472723d000000630200000000000000040000000700000043000000732800000074006a017d0274026a0374046a05830083017d037c036a067c007c017c027407740864018d05530029024e2905724700000072550000007228000000720a000000720c00000029097219000000721a0000007229000000722a000000721c0000007221000000da0b7665726966795f68616e64722c000000724400000029047247000000725500000072280000007231000000721e000000721e000000721f0000007256000000a70000007308000000000206010e0106017256000000630100000000000000020000000500000043000000732200000074006a0174026a03830083017d017c016a047c007405740664018d0301006400530029024e29037247000000720a000000720c00000029077229000000722a000000721c0000007221000000da0b7061796f75745f68616e64722c0000007244000000290272470000007231000000721e000000721e000000721f0000007257000000af000000730400000000020e01725700000029017227000000630100000000000000010000000400000043000000732a00000074006a0174026a0383006b027316740464018301820174056a067c0074006a0164028d0201006400530029034e7a2c4f6e6c7920746865206f776e65722063616e2063616c6c20656d657267656e63795f7769746864726177282929027227000000723200000029077219000000721a000000721700000072210000007222000000722f000000723400000029017227000000721e000000721e000000721f000000da12656d657267656e63795f7769746864726177b5000000730600000000021001060172580000002901da096e65775f6f776e6572630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174026a057c00830101006400530029024e7a244f6e6c7920746865206f776e65722063616e206368616e6765206f776e6572736869702129067219000000721a000000721700000072210000007222000000721800000029017259000000721e000000721e000000721f000000da106368616e67655f6f776e657273686970bc000000730400000000021601725a000000290146292d7202000000722f000000da09696d706f72746c69627229000000724b000000722d000000da0448617368722c0000007244000000724000000072380000007237000000da085661726961626c65721b000000721d000000721c00000072170000007220000000da085f5f6578706f7274da03737472722300000072240000007225000000da05666c6f6174722b0000007233000000da04626f6f6c72360000007239000000da046c697374da0464696374723f0000007242000000724300000072460000007248000000724c000000da03696e74725100000072520000007254000000725600000072570000007258000000725a000000721e000000721e000000721e000000721f000000da083c6d6f64756c653e01000000737a000000080104010401040108010601080106010801060108010601080104010a010401080104010801040108010c0308070601100606011006060110060601120a0601120806011208100806021a09060112070601100806011207060110070601100a0601160706011405060112070601140706011005060110060601