-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoker Room Python Widget.py
More file actions
422 lines (317 loc) · 12.9 KB
/
Poker Room Python Widget.py
File metadata and controls
422 lines (317 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
import RLPy
import random
import time
from PySide2 import QtWidgets
from PySide2.shiboken2 import wrapInstance
def RotateChip(chipName, reset = False):
#-- Loop through props --#prop
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, chipName)
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
rotationValue = 0
if (reset):
# set to 0 for reset #
rotationValue = 0
else:
# create a random value #
rotationValue = random.randint(101771, 124193) % 89 - 45
print(rotationValue)
#-- Set Rotation Z = by a random amount
ts_data_block.SetData("Rotation/RotationZ", FrameTime, RLPy.RVariant(rotationValue * RLPy.RMath.CONST_DEG_TO_RAD))
def ScrambleRedChips(reset = False):
# Red Chips #
sum = 0
n = 82
propName = "RedChip"
chipName = ""
for counter in range(2, n+1):
if (counter != 51):
chipName = propName + str(counter)
print ("attempting to rotate " + chipName)
RotateChip(chipName, reset)
sum += 1
# show a message #
if (reset):
print("Reset " + str(sum) + " Red Chips.");
text_edit.insertPlainText("Red Chips Unscrambled: " + str(sum) + "\r\n")
else:
print("Rotated " + str(sum) + " Red Chips.");
text_edit.insertPlainText("Red Chips Scrambled: " + str(sum) + "\r\n")
text_edit.update()
# return value #
return sum
def ScrambleBlackChips(reset = False):
# Black Chips #
sum = 0
n = 50
propName = "BlackChip"
chipName = ""
for counter in range(2, n+1):
chipName = propName + str(counter)
print ("attempting to rotate " + chipName)
RotateChip(chipName, reset)
sum += 1
# show a message #
if (reset):
print("Reset " + str(sum) + " Black Chips.");
text_edit.insertPlainText("Black Chips Unscrambled: " + str(sum) + "\r\n")
else:
print("Rotated " + str(sum) + " Black Chips.");
text_edit.insertPlainText("Black Chips Scrambled: " + str(sum) + "\r\n")
text_edit.update()
# return value #
return sum
def ScramblePurpleChips(reset = False):
# Purple Chips #
sum = 0
n = 30
propName = "PurpleChip"
chipName = ""
for counter in range(2, n+1):
chipName = propName + str(counter)
print ("attempting to rotate " + chipName)
RotateChip(chipName, reset)
sum += 1
# show a message #
if (reset):
print("Reset " + str(sum) + " Purple Chips.");
text_edit.insertPlainText("Purple Chips Unscrambled: " + str(sum) + "\r\n")
else:
print("Rotated " + str(sum) + " Purple Chips.");
text_edit.insertPlainText("Purple Chips Scrambled: " + str(sum) + "\r\n")
text_edit.update()
# return value #
return sum
def ScrambleGoldChips(reset = False):
# Gold Chips #
sum = 0
n = 20
propName = "GoldChip"
chipName = ""
for counter in range(2, n+1):
chipName = propName + str(counter)
print ("attempting to rotate " + chipName)
RotateChip(chipName, reset)
sum += 1
# show a message #
if (reset):
print("Reset " + str(sum) + " Gold Chips.");
text_edit.insertPlainText("Gold Chips Unscrambled: " + str(sum) + "\r\n")
else:
print("Rotated " + str(sum) + " Gold Chips.");
text_edit.insertPlainText("Gold Chips Scrambled: " + str(sum) + "\r\n")
text_edit.update()
# return value #
return sum
def ScrambleWhiteChips(reset = False):
# White Chips #
sum = 0
n = 50
propName = "WhiteChip"
chipName = ""
for counter in range(2, n+1):
chipName = propName + str(counter)
print ("attempting to rotate " + chipName)
RotateChip(chipName, reset)
sum += 1
# show a message #
if (reset):
print("Reset " + str(sum) + " White Chips.");
text_edit.insertPlainText("White Chips Unscrambled: " + str(sum) + "\r\n")
else:
print("Rotated " + str(sum) + " White Chips.");
text_edit.insertPlainText("White Chips Scrambled: " + str(sum) + "\r\n")
text_edit.update()
# return value #
return sum
def ScrambleGreenChips(reset = False):
# Green Chips #
sum = 0
n = 82
propName = "GreenChip"
chipName = ""
for counter in range(2, n+1):
if (counter != 51):
chipName = propName + str(counter)
print ("attempting to rotate " + chipName)
RotateChip(chipName, reset)
sum += 1
# show a message #
if (reset):
print("Reset " + str(sum) + " Green Chips.");
text_edit.insertPlainText("Green Chips Unscrambled: " + str(sum) + "\r\n")
else:
print("Rotated " + str(sum) + " Green Chips.");
text_edit.insertPlainText("Green Chips Scrambled: " + str(sum) + "\r\n")
text_edit.update()
# return value #
return sum
def ScrambleChips():
FrameTime = RLPy.RGlobal.GetTime()
text_edit.clear()
text_edit.update()
total = 0
expectedTotal = 306
progress_bar.setRange(1, expectedTotal)
# This isn't really 26%, but for some reason the first time it refreshes again this is always behind. #
progress_bar.setFormat(f"Scrambling: {26}%")
progress_bar.update()
total += ScrambleRedChips()
# Update the progress bar #
UpdateProgress(total, expectedTotal)
total += ScrambleBlackChips()
# Update the progress bar #
UpdateProgress(total, expectedTotal)
total += ScramblePurpleChips()
# Update the progress bar #
UpdateProgress(total, expectedTotal)
total += ScrambleGoldChips()
# Update the progress bar #
UpdateProgress(total, expectedTotal)
total += ScrambleGreenChips()
# Update the progress bar #
UpdateProgress(total, expectedTotal)
total += ScrambleWhiteChips()
# Update the progress bar #
UpdateProgress(total, expectedTotal)
# Final Message #
progress_bar.setFormat(f"{total} chips scrambled.")
progress_bar.update()
# Refresh Code Hack That Seemed to Work. Waiting For Better Way Answer. #
Refresh2()
def UnscrambleChips():
FrameTime = RLPy.RGlobal.GetTime()
text_edit.clear()
text_edit.update()
total = 0
expectedTotal = 306
progress_bar.setRange(1, expectedTotal)
# This isn't really 26%, but for some reason the first time it refreshes again this is always behind. #
progress_bar.setFormat(f"Unscrambling: {26}%")
progress_bar.update()
total += ScrambleRedChips(True)
# Update the progress bar #
UpdateProgress(total, expectedTotal, True)
total += ScrambleBlackChips(True)
# Update the progress bar #
UpdateProgress(total, expectedTotal, True)
total += ScramblePurpleChips(True)
# Update the progress bar #
UpdateProgress(total, expectedTotal, True)
total += ScrambleGoldChips(True)
# Update the progress bar #
UpdateProgress(total, expectedTotal, True)
total += ScrambleGreenChips(True)
# Update the progress bar #
UpdateProgress(total, expectedTotal, True)
total += ScrambleWhiteChips(True)
# Update the progress bar #
UpdateProgress(total, expectedTotal, True)
# Final Message #
progress_bar.setFormat(f"{total} chips unscrambled.")
progress_bar.update()
# Refresh Code Hack That Seemed to Work. Waiting For Better Way Answer. #
Refresh2()
def Refresh2():
# Refresh Code Hack That Seemed to Work. Waiting For Better Way Answer. #
RLPy.RGlobal.Play(RLPy.RTime(FrameTime), RLPy.RTime(FrameTime))
RLPy.RGlobal.Stop()
result = RLPy.RGlobal.SetTime(RLPy.RTime(FrameTime))
print(result) # Success or fail
def UpdateProgress(progressValue, expectedTotal, reset = False):
progress_bar.setValue(progressValue)
if (reset):
progress_bar.setFormat(f"Unscrambling: {round((progressValue / expectedTotal) * 100)}%")
else:
progress_bar.setFormat(f"Scrambling: {round((progressValue / expectedTotal) * 100)}%")
progress_bar.update()
def OpenShuffleMachine():
# Get the current frame #
frameTime = RLPy.RGlobal.GetTime()
# Turn the glow light on first #
propName = "Green Light Glow"
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
# Turn the glow light off first #
propName = "Green Light Glow"
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
ret = prop.SetVisible(RLPy.RTime(frameTime + 1999), True)
# Lid #
propName = "Lid"
#-- Loop through props --#prop
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
rotationValue = -104
lidFinishOpenTime = frameTime + 4999
#-- Set Rotation Z To -104 which is a little more than 90 degrees open so the dealers hands doesn't get in the way picking up cards #
ts_data_block.SetData("Rotation/RotationX", RLPy.RTime(lidFinishOpenTime), RLPy.RVariant(rotationValue * RLPy.RMath.CONST_DEG_TO_RAD))
# Left Deck Holder #
propName = "Left Deck Holder"
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
leftColumnUp = 6
leftColumnUpTime = frameTime + 6999
#-- Set Potation Z To -104 which is a little more than 90 degrees open so the dealers hands doesn't get in the way picking up cards #
ts_data_block.SetData("Position/PositionZ", RLPy.RTime(leftColumnUpTime), RLPy.RVariant(leftColumnUp))
RLPy.RGlobal.Play(frameTime, leftColumnUpTime)
def CloseShuffleMachine():
# Get the current frame #
frameTime = RLPy.RGlobal.GetTime()
# Turn the glow light off first #
propName = "Green Light Glow"
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
ret = prop.SetVisible(RLPy.RTime(frameTime + 999), False)
# Left Deck Holder #
propName = "Left Deck Holder"
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
leftColumnDown = 2
leftColumnDownTime = frameTime + 4999
#-- Set Potation Z To -104 which is a little more than 90 degrees open so the dealers hands doesn't get in the way picking up cards #
ts_data_block.SetData("Position/PositionZ", leftColumnDownTime, RLPy.RVariant(leftColumnDown))
# Lid #
propName = "Lid"
#-- Loop through props --#prop
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, propName)
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
rotationValue = 0
# The lid needs to close a little after the Left Deck Holder #
lidFinishCloseTime = frameTime + 5999
#-- Set Rotation Z To 0 #
ts_data_block.SetData("Rotation/RotationX", lidFinishCloseTime, RLPy.RVariant(rotationValue * RLPy.RMath.CONST_DEG_TO_RAD))
RLPy.RGlobal.Play(frameTime, lidFinishCloseTime)
FrameTime = RLPy.RGlobal.GetTime()
window = RLPy.RUi.CreateRDockWidget()
window.SetWindowTitle("Poker Room Python Widget")
dock = wrapInstance(int(window.GetWindow()), QtWidgets.QDockWidget)
dock.setFixedSize(350, 350)
dock.setStyleSheet(
""" QProgressBar{ font: bold; color: black; border: 1px solid black; background-color: grey;}
QProgressBar::chunk { width: 1px; background-color: #13c1ec}""")
widget = QtWidgets.QWidget()
dock.setWidget(widget)
layout = QtWidgets.QVBoxLayout()
widget.setLayout(layout)
progress_bar = QtWidgets.QProgressBar()
text_edit = QtWidgets.QTextEdit(readOnly=True)
# Chip Buttons #
ScrambleButton = QtWidgets.QPushButton("Scramble Chips")
ScrambleButton.clicked.connect(ScrambleChips)
UnscrambleButton = QtWidgets.QPushButton("Unscramble Chips")
UnscrambleButton.clicked.connect(UnscrambleChips)
# Shuffle Machine Buttons #
OpenShuffleMachineButton = QtWidgets.QPushButton("Open Shuffle Machine")
OpenShuffleMachineButton.clicked.connect(OpenShuffleMachine)
CloseShuffleMachineButton = QtWidgets.QPushButton("Close Shuffle Machine")
CloseShuffleMachineButton.clicked.connect(CloseShuffleMachine)
for widget in [progress_bar, text_edit, ScrambleButton, UnscrambleButton, OpenShuffleMachineButton, CloseShuffleMachineButton]:
layout.addWidget(widget)
window.Show()