added variety of free squares
17
bingo.py
Normal file → Executable file
@ -10,13 +10,13 @@ class Bingo:
|
||||
self.X_OFFSET = 10
|
||||
self.Y_OFFSET = 110
|
||||
self.SQUARES_PATH = "bingo_images/squares/*.png"
|
||||
self.FREE_SQUARE_PATH = "bingo_images/free_space.png"
|
||||
self.FREE_SQUARES_PATH = "bingo_images/free_squares/*.png"
|
||||
self.BLANK_CARD_PATH = "bingo_images/card_blank.png"
|
||||
self.TEMP_FOLDER = "bingo_images/temp/"
|
||||
|
||||
self.square_files = glob.glob(self.SQUARES_PATH)
|
||||
|
||||
def get_card(self):
|
||||
square_files = glob.glob(self.SQUARES_PATH)
|
||||
free_square_files = glob.glob(self.FREE_SQUARES_PATH)
|
||||
used_files = set()
|
||||
|
||||
with Image.open(self.BLANK_CARD_PATH) as card_img:
|
||||
@ -27,17 +27,18 @@ class Bingo:
|
||||
for y in range(5):
|
||||
for x in range(5):
|
||||
square_file = ""
|
||||
# If this is the center square, use the free square
|
||||
# If this is the center square, pick a random free square
|
||||
if x == 2 and y == 2:
|
||||
square_file = self.FREE_SQUARE_PATH
|
||||
square_file = \
|
||||
free_square_files[randrange(len(free_square_files))]
|
||||
|
||||
# otherwise, find a random file that hasn't been used yet
|
||||
else:
|
||||
rand_file_idx = randrange(len(self.square_files))
|
||||
rand_file_idx = randrange(len(square_files))
|
||||
while rand_file_idx in used_files:
|
||||
rand_file_idx = randrange(len(self.square_files))
|
||||
rand_file_idx = randrange(len(square_files))
|
||||
|
||||
square_file = self.square_files[rand_file_idx]
|
||||
square_file = square_files[rand_file_idx]
|
||||
used_files.add(rand_file_idx)
|
||||
|
||||
with Image.open(square_file) as square:
|
||||
|
BIN
bingo_images/free_squares/free_buxton_pause.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
bingo_images/free_squares/free_cofty_sir_lewis.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
bingo_images/free_squares/free_rosanna_towers.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
bingo_images/squares/dnf.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
bingo_images/squares/driver_crashes_no_contact.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
bingo_images/squares/driver_says_shutup.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
bingo_images/squares/puncture.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
bingo_images/squares/teammates_collide.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
bingo_images/squares/tifosi.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
bingo_images/temp/46f23587-3ddb-4911-af76-6f9ea5b82fee.png
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
bingo_images/temp/7d5c2afb-6a2c-4473-bb4c-48ff1c186f56.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
bingo_images/temp/99f346d2-fb0d-400d-96e7-77c66683abf1.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
bingo_images/temp/9c53d2c0-bc8e-44ed-8b38-7501c7d4b501.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
bingo_images/temp/b652b79c-f7d4-41af-888e-b18af704aaf6.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
bingo_images/temp/d0798a8c-70f2-4c12-8e6c-40452988a7c9.png
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
bingo_images/temp/e4e85cbd-0d2c-4276-90da-7a9ada55a7d1.png
Normal file
After Width: | Height: | Size: 64 KiB |