-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathscreenspace.py
695 lines (633 loc) · 27 KB
/
screenspace.py
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
# This file contains the logic for the terminal screen
# Player Terminal total width and height: 153x43. There is 3 extra characters for the border.
# Banker total width and height is 200x60
WIDTH = 150
HEIGHT = 40
INPUTLINE = 45
import os
from style import MYCOLORS as COLORS, choose_colorset, set_cursor, set_cursor_str, colortest, graphics as g
import networking as net
import platform
import ctypes
import shutil
import re
import keyboard
import time
import textwrap
# Each quadrant is half the width and height of the screen
global rows, cols
rows = HEIGHT//2
cols = WIDTH//2
DEBUG = False
VERBOSE = True # Set to True to see all output in the output areas. If the user does not need to see the output (any privacy concerns or in a tournament game), set to False via -silent sys.argv.
MONOPOLY_OUTPUT_COORDINATES = (1, 47) # (0, 47) is the top left corner of the monopoly output frame. Add 1 to x and y to print within in the frame.
TTT_OUTPUT_COORDINATES = (157, 13) # (157, 11) is the top left corner of the ttt output frame. Add 1 to x and y to print within in the frame.
CASINO_OUTPUT_COORDINATES = (157, 0) # (157, 0) is the top left corner of the casino output frame. Add 1 to x and y to print within in the frame.
MAIN_OUTPUT_COORDINATES = (0, 36) # (0, 0) is the top left corner of the main output frame. Add 1 to x and y to print within in the frame.
class OutputArea:
def __init__(self, name: str, coordinates: tuple, max_length: int, max_lines: int):
self.name = name
self.coordinates = coordinates
self.output_list = []
self.color_list = []
self.max_length = max_length
self.max_lines = max_lines
def add_output(self, output: str, color):
if VERBOSE:
msg = textwrap.wrap(output, self.max_length, initial_indent=">> ")
msg.reverse() # reverse so we can pop from the end and extra wrapped lines are at the end
for line in msg:
self.output_list.insert(0, line)
self.color_list.insert(0, color)
while len(self.output_list) > self.max_lines:
self.output_list.pop()
self.color_list.pop()
for i, line in enumerate(self.output_list):
print(self.color_list[i], end="")
if self.name == "Main": # Main output area is special, it doesn't have a border
set_cursor(self.coordinates[0] + 1, self.coordinates[1] + i)
print(line + " " * (self.max_length - len(line) - 2), end="") # print line and clear extra old text
else:
set_cursor(self.coordinates[0] + 1, self.coordinates[1] + 2 + i)
print(line + " " * (self.max_length - len(line)), end="") # print line and clear extra old text
print(COLORS.RESET, end="", flush=True) # reset color
class Terminal:
def __init__(self, index: int, coordinates: tuple):
self.index = index
self.x = coordinates[0] # top left corner of the terminal
self.y = coordinates[1] # top left corner of the terminal
self.data = []
self.command = ""
self.padded_data = False
self.status = "ACTIVE"
self.persistent = False
self.has_new_data = False
self.oof_callable = None
def update(self, data, padding: bool = True) -> None:
"""
Description:
Better quadrant update function.
This exceeds others because it immediately updates a single quadrant with the new data.
Previously, the screen would not update until print_screen() was called.
Furthermore, print_screen() would overwrite the entire screen, which is not ideal and slower.\n
Set padding = True if you're not sure whether your module needs padding.
Parameters:
data (str): The string (with newlines to separate lines) to populate the quadrant with.
data (function): A function that populates the quadrant manually. Useful for modules that need
to print with colors or other formatting
padding (bool): (default True) a flag whether or not your module needs extra padding
(blank spaces) to fill in any missing lines
Returns:
None
"""
self.padded_data = padding
# If you're really desparate to add padding, for some edge case you can add it to the data string.
if not padding:
if not callable(data) and 'PAD ME PLEASE!' in data:
data = data.replace('PAD ME PLEASE!', '')
self.padded_data = True
# These lines are taking any additional string fragments that use "set_cursor_string()" from
# style.py and update the x,y coordinates to the current quadrant.
self.data = self.translate_coords(data)
self.display()
def check_new_data(self, new_data: str):
"""
Only checks if the new data is different from the old data. If it is, it updates the data and sets has_new_data to True.
This will later be used to determine if the terminal needs to be redrawn, saving unnecessary print statements.
"""
if self.data != new_data:
self.data = new_data
self.has_new_data = True
else:
self.has_new_data = False
def display(self) -> None:
"""
Description:
Prints the terminal data defined in its internal data variable.
Parameters:
None
Returns:
None
"""
print(COLORS.RESET, end='') # Reset color before printing
if self.data and not callable(self.data):
if self.data:
line_list = self.data.split('\n')
if len(line_list) > rows and self.padded_data:
line_list = line_list[:rows] # Truncate if necessary bc someone might send a long string
for i in range(len(line_list)):
set_cursor(self.x,self.y+i)
if self.padded_data:
line_list[i] = line_list[i] + " " * (cols - len(line_list[i])) # Pad with spaces if necessary
print(line_list[i][:cols] if len(line_list[i]) > cols and self.padded_data else line_list[i]) # Truncate if necessary bc someone might send a long string
for i in range(len(line_list), rows):
set_cursor(self.x,self.y+i)
print(" " * cols)
elif callable(self.data):
self.data()
else:
set_cursor(x=self.x + 10, y= self.y + 4)
print(f'╔══════Terminal {self.index}══════╗')
set_cursor(x=self.x + 10, y= self.y + 5)
print('║ Awaiting commands... ║')
set_cursor(x=self.x + 10, y= self.y + 6)
print('╚══════════════════════╝')
debug_note()
print(COLORS.RESET, end='')
set_cursor(0,INPUTLINE)
def translate_coords(self, data) -> str:
pattern = r'\033\[(\d+);(\d+)H'
data = re.sub(pattern, lambda m: replace_sequence(m, self.x, self.y), data)
return data
def clear(self):
"""Prints a blank screen in the terminal."""
for i in range(rows):
set_cursor(self.x,self.y+i)
print(" " * cols)
def kill(self):
"""
Description:
Kills a terminal, triggered by a netcommand.
Parameters:
None
Returns:
None
"""
self.status = "DISABLED"
skull = g.get("skull")
print(COLORS.RED)
self.update(skull)
print(COLORS.RESET)
set_cursor(0, INPUTLINE)
def disable(self):
"""
Description:
Disables a terminal, triggered by a netcommand.
Parameters:
None
Returns:
None
"""
self.status = "DISABLED"
print(COLORS.RED)
result = (('X ' * round(cols/2+0.5) + '\n' +
(' X' * round(cols/2+0.5)) + '\n'
) * (rows//2))
self.update(result)
print(COLORS.RESET)
set_cursor(0, INPUTLINE)
def enable(self, isFromDisable, socket, player_id):
"""
Description:
Enables a terminal, triggered either by the client or by a netcommand.
Parameters:
isFromDisable(bool): Whether it is triggered from a disable.
socket(socket): The socket to update the banker's statuses.
player_id(int): The player's ID for the message send.
Returns:
None
"""
self.status = "ACTIVE"
net.send_message(socket, str(player_id) + "active " + str(self.index))
if(isFromDisable):
self.update("This terminal is now enabled!")
def busy(self, socket, player_id):
"""
Description:
Busies a terminal.
Parameters:
socket(socket): The socket to update the banker's statuses.
player_id(int): The player's ID for the message send.
Returns:
None
"""
self.status = "BUSY"
net.send_message(socket, str(player_id) + "busy " + str(self.index))
def notification(message: str, n: int, color: str, custom_x: int, custom_y: int) -> str:
"""
Generates a notification popup message for the player.
Parameters:
message (str): The message to be displayed in the notification.
n (int): The position identifier for the popup.
1 - Top-left, 2 - Top-right, 3 - Bottom-left, 4 - Bottom-right, -1 - Custom position.
color (str): The color code for the popup text.
Returns:
str: The formatted string with the notification message and its position.
"""
# Max 78 character popup for messaging the player.
message = message + " " * max(0, (78 - len(message)))
lines = textwrap.wrap(message, 78/3)
x,y = -1,-1
writeto = ""
if (n == 1):
x,y = 2+10,2+5
elif (n == 2):
x,y = cols+3+10, 2+5
elif (n == 3):
x,y = 2+10, rows+3+5
elif (n == 4):
x,y = cols+3+10, rows+3+5
elif (n == -1):
x,y = cols - 20, rows - 5
if custom_x and custom_y:
x = custom_x
y = custom_y
p = color + set_cursor_str(x, y)
outline = g["popup 1"].split("\n")
for i in range(len(outline)):
p += set_cursor_str(x, y+i) + outline[i]
if 0 < i < 4:
# Custom text wrapping
p += set_cursor_str(x+2, y+i) + message[(i-1)*26:(i-1)*26+26]
writeto += p
return writeto + set_cursor_str(0, INPUTLINE)
def replace_sequence(match, x, y):
"""
Replaces the x and y coordinates in the matched string with the new x and y coordinates.
Useful when updating the cursor position in a string, allowing for set_cursor_str() to
be used in any quadrant.
"""
# Extract the number N from the matched string
nx = int(match.group(2))
ny = int(match.group(1))
# Calculate the new x and y coordinates
new_x = nx + x
new_y = ny + y
# Return the new sequence
return f"\033[{new_y};{new_x}H"
def update_terminal(n: int, o: int): # TODO not working at the moment
"""
Updates the terminal border to indicate the active terminal. Turns off the border for the inactive terminal.
"""
x,y = -1,-1
border_chars = [('╔','╦','╠','╬'),
('╦','╗','╬','╣'),
('╠','╬','╚','╩'),
('╬','╣','╩','╝')]
if type(o) == Terminal:
o = o.index
if (o == 1):
x,y = 0,1
elif(o == 2):
x,y = cols+2, 1
elif(o == 3):
x,y = 0, rows+2
elif(o == 4):
x,y = cols+2, rows+2
o = o - 1 # 0-indexed
c = COLORS.LIGHTGRAY
set_cursor(x,y)
print(c, end='')
print(border_chars[o][0] + '═' * cols + border_chars[o][1], end='')
set_cursor(x,y+rows+1)
print(border_chars[o][2] + '═' * cols + border_chars[o][3], end='')
for i in range(y, y + rows):
set_cursor(x, i+1)
print('║')
set_cursor(x+cols + (1 if (o + 1) % 2 == 0 else 2), i+1)
print('║')
if (n == 1):
x,y = 0,1
elif (n == 2):
x,y = cols+2, 1
elif (n == 3):
x,y = 0, rows+2
elif (n == 4):
x,y = cols+2, rows+2
n = n - 1 # 0-indexed
c = COLORS.GREEN
set_cursor(x,y)
print(c, end='')
print(border_chars[n][0] + '═' * cols + border_chars[n][1], end='')
set_cursor(x,y+rows+1)
print(border_chars[n][2] + '═' * cols + border_chars[n][3], end='')
for i in range(y, y + rows):
set_cursor(x, i+1)
print('║')
set_cursor(x+cols + (1 if (n + 1) % 2 == 0 else 2), i+1)
print('║')
set_cursor(0,INPUTLINE)
print(COLORS.RESET, end='')
debug_note()
def debug_note():
if DEBUG:
message = 'DEBUG MODE'
set_cursor(WIDTH-10-len(message),0)
print(f'{COLORS.GREEN}{message}{COLORS.RESET}')
set_cursor(0,INPUTLINE)
def indicate_keyboard_hook(t: int):
"""
Indicates that the keyboard hook is active for a certain terminal.
Changes the color of the terminal border.
This is important for the player to know why they can't type on the input line.
"""
x,y = -1,-1
border_chars = [('╔','╦','╠','╬'),
('╦','╗','╬','╣'),
('╠','╬','╚','╩'),
('╬','╣','╩','╝')]
if (t == 1):
x,y = 0,1
elif (t == 2):
x,y = cols+2, 1
elif (t == 3):
x,y = 0, rows+2
elif (t == 4):
x,y = cols+2, rows+2
t = t - 1 # 0-indexed
c = COLORS.LIGHTBLUE
set_cursor(x,y)
print(c, end='')
print(border_chars[t][0] + '═' * cols + border_chars[t][1], end='')
set_cursor(x,y+rows+1)
print(border_chars[t][2] + '═' * cols + border_chars[t][3], end='')
for i in range(y, y + rows):
set_cursor(x, i+1)
print('║')
set_cursor(x+cols + (1 if (t + 1) % 2 == 0 else 2), i+1)
print('║')
def overwrite(text: str = ""):
"""
Writes text over 2nd to last line of the terminal (input line).
Use this method regularly.
Parameters:
text (str): The text to overwrite with. Default is empty string.
Returns: None
"""
set_cursor(0, INPUTLINE)
print(f'\033[1A\r{COLORS.RESET}{text}', end=' ' * (WIDTH - len(text) + 3) + '\n' + ' ' * (WIDTH + 3) + '\r')
def get_valid_int(prompt, min_val = -1000000000, max_val = 1000000000, disallowed = [], allowed = []): # arbitrary large numbers
"""
Prompts the user to enter an integer within a specified range and validates the input.
Parameters:
prompt (str): The message displayed to the user when asking for input.
min_val (int, optional): The minimum acceptable value (inclusive). Defaults to -1000000000.
max_val (int, optional): The maximum acceptable value (inclusive). Defaults to 1000000000.
disallowed (list, optional): A list of disallowed values. Defaults to an empty list.
allowed (list, optional): A list of allowed values. Defaults to an empty list.
If a space is in the whitelist, user is allowed to skip input (enter key), returning an empty string.
Returns:
int: A valid integer input by the user within the specified range. (or an empty string if allowed)
Raises:
None: All exceptions are caught and handled by the function.
"""
while True:
try:
set_cursor(0, INPUTLINE)
value = int(input(prompt))
if value in allowed:
return value
if value < min_val or value > max_val or value in disallowed:
raise ValueError
return value
except ValueError:
try:
value # check if value is defined. If not, the input was empty and the user pressed enter.
except UnboundLocalError:
if " " in allowed:
return "" # This is the signal to skip input
overwrite("Invalid input. Please enter a valid integer.")
set_cursor(0, INPUTLINE)
def clear_screen():
"""
Naively clears the terminal screen.
Parameters: None
Returns: None
"""
print(COLORS.RESET,end='')
os.system('cls' if os.name == 'nt' else 'clear')
def initialize_terminals(terminals: list[Terminal]):
"""
Initializes the terminal screen with the default number displays and terminal borders.
"""
clear_screen()
print(g.get('terminals'))
for i in range(4):
terminals[i].update('')
set_cursor(0,INPUTLINE)
def make_fullscreen():
current_os = platform.system()
if current_os == "Windows":
# Maximize terminal on Windows
user32 = ctypes.WinDLL("user32")
SW_MAXIMIZE = 3
hWnd = user32.GetForegroundWindow()
user32.ShowWindow(hWnd, SW_MAXIMIZE)
elif current_os == "Linux" or current_os == "Darwin":
# Maximize terminal on Linux/macOS
os.system("printf '\033[9;1t'")
else:
print(f"Fullscreen not supported for OS: {current_os}")
def print_with_wrap(char, start_row, start_col):
# Get the terminal size
terminal_size = shutil.get_terminal_size()
width = terminal_size.columns
# If the position exceeds the terminal width, handle wrapping
if start_col >= width:
# Calculate new row and column if it exceeds width
new_row = start_row + (start_col // width)
new_col = start_col % width
print(f"\033[{new_row};{new_col}H" + char, end="")
else:
# Default print
print(f"\033[{start_row};{start_col}H" + char, end="")
def calibrate_print_commands():
"""
Print commands, used in calibration screen.\n
"""
commandsinfo = g.get('commands').split("\n")
for i in range(len(commandsinfo)):
for j in range(len(commandsinfo[i])):
print(f"\033[{34+i};79H" + commandsinfo[i][:j], end="")
def print_banker_frames():
"""
Prints the banker frames.
Parameters: None
Returns: None
"""
gameboard = g.get('gameboard')
border = g.get('history and status').split('\n')
history = []
set_cursor(0,0)
print(gameboard)
for i in range(len(border)):
set_cursor(79,i)
if(len(history) - i<= 0):
for j in range(len(border[i])):
print(border[i][j], end="")
calibrate_print_commands()
casino_frame = g.get('casino_output_frame')
i = 0
for line in casino_frame.split('\n'):
set_cursor(CASINO_OUTPUT_COORDINATES[0], CASINO_OUTPUT_COORDINATES[1]+i)
print(line, end="")
i += 1
i -= 1
ttt_frame = g.get('ttt_output_frame')
for line in ttt_frame.split('\n'):
set_cursor(TTT_OUTPUT_COORDINATES[0], i)
print(line, end="")
i += 1
monopoly_output_frame = g.get('monopoly_output_frame')
i = 0
for line in monopoly_output_frame.split('\n'):
set_cursor(MONOPOLY_OUTPUT_COORDINATES[0], MONOPOLY_OUTPUT_COORDINATES[1]+i)
print(line, end="")
i += 1
def auto_calibrate_screen(mode: str = "player") -> None:
"""
Automatically calibrates the screen. The player doesn't really know what screen size is
optimal, but we do. This function will automatically adjust the screen size to the ensure
minimum requirements are met.
"""
if mode == "player":
if os.name == 'nt': # Windows
max_iterations = 20
while os.get_terminal_size().lines - 5 < HEIGHT or os.get_terminal_size().columns - 5 < WIDTH:
keyboard.press('ctrl')
keyboard.send('-')
keyboard.release('ctrl')
time.sleep(0.1)
max_iterations -= 1
if max_iterations <= 0:
break
max_iterations = 20
while os.get_terminal_size().lines > HEIGHT + 40 or os.get_terminal_size().columns > WIDTH + 40:
keyboard.press('ctrl')
keyboard.send('+')
keyboard.release('ctrl')
time.sleep(0.1)
max_iterations -= 1
if max_iterations <= 0:
break
elif os.name == 'posix': # Linux/macOS
print("\033[8;50;160t") # Set terminal size to 50 rows and 160 columns
elif mode == "banker":
if os.name == 'nt': # Windows
max_iterations = 20 # Safeguard to prevent infinite loop due to user error or logic error
while os.get_terminal_size().lines - 5 < 60 or os.get_terminal_size().columns - 5 < 200:
keyboard.press('ctrl')
keyboard.send('-')
keyboard.release('ctrl')
time.sleep(0.1)
max_iterations -= 1
if max_iterations <= 0:
break
max_iterations = 20
while os.get_terminal_size().lines > 60 + 20 or os.get_terminal_size().columns > 200 + 20:
keyboard.press('ctrl')
keyboard.send('+')
keyboard.release('ctrl')
time.sleep(0.1)
max_iterations -= 1
if max_iterations <= 0:
break
elif os.name == 'posix': # Linux/macOS
print("\033[8;60;200t") # Set terminal size to 60 rows and 200 columns
def calibrate_screen(type: str) -> None:
terminal_size = shutil.get_terminal_size()
width = terminal_size.columns
os.system('cls' if os.name == 'nt' else 'clear')
current_os = platform.system()
colortest()
choice = input("How does this look? Enter the number of your preferred colorset: ")
# sets the color set based on user input
global COLORS
if choice == "1":
print("Using default colorset")
choose_colorset("DEFAULT_COLORS")
elif choice == "2":
print("Using compatible colorset")
choose_colorset("COMPAT_COLORS")
elif choice == "3":
print("Using custom colorset")
choose_colorset("CRAZY_THEME")
else:
print("Please enter a valid choice")
choose_colorset("DEFAULT_COLORS") # default to default colorset
input("Press enter to continue...")
clear_screen()
if current_os == "Darwin":
# Print out instructions for macOS users
print("Please use Ctrl + \"Command\" + \"+\" or Ctrl + \"Command\" + \"-\" to zoom in/out and ensure everything is visible. Press enter to continue to scaling screen.")
else:
# Print out instructions for Linux/Windows users
print("Please use \"Ctrl\" + \"-\" or \"Ctrl\" + \"+\" to zoom in/out and ensure everything is visible. Press enter to continue to scaling screen.")
print("Proper scaling should only displays 4 cross that marks the corners of the board.")
print("If you are having trouble with scaling, try entering r to reset the display.")
print("After finishing scaling, please press enter to continue.")
scaling_test = input()
os.system('cls' if os.name == 'nt' else 'clear')
if type == "gameboard":
gameboard = g.get('gameboard')
border = g.get('history and status').split('\n')
history = []
print(f"\033[0;0H" + gameboard, end="")
for i in range(len(border)):
print(f"\033[{i};79H", end="")
if(len(history) - i<= 0):
for j in range(len(border[i])):
print(border[i][j], end="")
calibrate_print_commands()
print_with_wrap("X", 0, 0)
print_with_wrap("X", 0, 156)
print_with_wrap("X", 50, 156)
print_with_wrap("X", 50, 0)
print(f"\033[36;0H" + "Press enter to play or enter r to reset the display.", end="")
scaling_test = input()
while scaling_test != "":
if scaling_test == "r":
os.system('cls' if os.name == 'nt' else 'clear')
print(f"\033[0;0H" + gameboard, end="")
for i in range(len(border)):
print(f"\033[{i};79H", end="")
if(len(history) - i<= 0):
for j in range(len(border[i])):
print(border[i][j], end="")
calibrate_print_commands()
print_with_wrap("X", 0, 0)
print_with_wrap("X", 0, 156)
print_with_wrap("X", 50, 156)
print_with_wrap("X", 50, 0)
print(f"\033[36;0H" + "Press enter to play or enter r to reset the display.", end="")
scaling_test = input()
elif type == "player":
os.system('cls' if os.name == 'nt' else 'clear')
set_cursor(0,0)
print(g.get('terminals'))
print_with_wrap("X", 0, 0)
print_with_wrap("X", 0, 153)
print_with_wrap("X", 43, 153)
print_with_wrap("X", 43, 0)
print(f"\033[44;0H" + "Press enter to play or enter r to reset the display.", end="")
scaling_test = input()
while scaling_test != "":
os.system('cls' if os.name == 'nt' else 'clear')
set_cursor(0,0)
print(g.get('terminals'))
print_with_wrap("X", 0, 0)
print_with_wrap("X", 0, 153)
print_with_wrap("X", 43, 153)
print_with_wrap("X", 43, 0)
print(f"\033[44;0H" + "Press enter to play or enter r to reset the display.", end="")
scaling_test = input()
os.system('cls' if os.name == 'nt' else 'clear')
elif type == "banker": # gameboard is least 156 characters, but we need extra space for additional output for debugging purposes (40 chars)
# Total banker display is 60 rows x 200 columns. Default screen size usually will not accomodate, so use calibration here
os.system('cls' if os.name == 'nt' else 'clear')
def print_xs():
print_with_wrap("X", 0, 0)
print_with_wrap("X", 0, 200)
print_with_wrap("X", 59, 0)
print_with_wrap("X", 59, 200)
print(f"\033[60;0H" + "Press enter to play or enter r to reset the display.", end="")
print_banker_frames()
auto_calibrate_screen("banker")
print_xs()
scaling_test = input()
while scaling_test != "":
os.system('cls' if os.name == 'nt' else 'clear')
print_banker_frames()
print_xs()
scaling_test = input()
os.system('cls' if os.name == 'nt' else 'clear')