|
@@ -4,7 +4,7 @@ |
|
|
# |
|
|
# |
|
|
# Two files provided: |
|
|
# Two files provided: |
|
|
# - subs.txt -- 8 subscribers |
|
|
# - subs.txt -- 8 subscribers |
|
|
# - teams.txt -- 26 teams |
|
|
|
|
|
|
|
|
# - teams.txt -- 30 teams |
|
|
# |
|
|
# |
|
|
# Pseudocode: |
|
|
# Pseudocode: |
|
|
# Split screen in 1:3 |
|
|
# Split screen in 1:3 |
|
@@ -21,7 +21,7 @@ import random |
|
|
import pygame |
|
|
import pygame |
|
|
|
|
|
|
|
|
pygame.init() |
|
|
pygame.init() |
|
|
random.seed("BERTIE BEEF BAGGIO") |
|
|
|
|
|
|
|
|
random.seed("bertieb") |
|
|
|
|
|
|
|
|
HIGHLIGHTEVENT = pygame.USEREVENT + 1 # user specified event |
|
|
HIGHLIGHTEVENT = pygame.USEREVENT + 1 # user specified event |
|
|
CLEAREVENT = pygame.USEREVENT + 2 # user specified event |
|
|
CLEAREVENT = pygame.USEREVENT + 2 # user specified event |
|
@@ -31,7 +31,7 @@ SIZE = WIDTH, HEIGHT = 1920, 1080 |
|
|
|
|
|
|
|
|
BGIMG = pygame.image.load("sub_crown_bg_2.png") |
|
|
BGIMG = pygame.image.load("sub_crown_bg_2.png") |
|
|
|
|
|
|
|
|
FONT = pygame.font.SysFont("Fetamont", 50) |
|
|
|
|
|
|
|
|
FONT = pygame.font.SysFont("Fetamont", 45) |
|
|
SUBFONTHEIGHT = 35 |
|
|
SUBFONTHEIGHT = 35 |
|
|
SUBFONT = pygame.font.SysFont("Fetamont", SUBFONTHEIGHT) |
|
|
SUBFONT = pygame.font.SysFont("Fetamont", SUBFONTHEIGHT) |
|
|
OFFWHITE = (224, 224, 224) |
|
|
OFFWHITE = (224, 224, 224) |
|
@@ -41,22 +41,22 @@ RED = (186, 20, 31) |
|
|
PURPLE = (121, 35, 158) |
|
|
PURPLE = (121, 35, 158) |
|
|
|
|
|
|
|
|
screen = pygame.display.set_mode(SIZE) |
|
|
screen = pygame.display.set_mode(SIZE) |
|
|
pygame.display.set_caption("Sub Crown Nov 2020 Team Picker") |
|
|
|
|
|
|
|
|
pygame.display.set_caption("Sub Crown September 2021 Team Picker") |
|
|
|
|
|
|
|
|
# Set up team text positioning references |
|
|
# Set up team text positioning references |
|
|
# |
|
|
# |
|
|
# 26 teams so 3 cols, 9 rows |
|
|
# 26 teams so 3 cols, 9 rows |
|
|
|
|
|
|
|
|
COLSTART = int(WIDTH/3) |
|
|
|
|
|
COLWIDTH = int((WIDTH-COLSTART)/3) |
|
|
|
|
|
|
|
|
|
|
|
ROWSTART = int(HEIGHT/12) |
|
|
|
|
|
ROWHEIGHT = int((HEIGHT-ROWSTART)/10) |
|
|
|
|
|
|
|
|
|
|
|
TEAMSFILE = "teams.txt" |
|
|
TEAMSFILE = "teams.txt" |
|
|
|
|
|
|
|
|
TEAMNUMCOLS = 3 |
|
|
TEAMNUMCOLS = 3 |
|
|
TEAMNUMROWS = 9 |
|
|
|
|
|
|
|
|
TEAMNUMROWS = 12 |
|
|
|
|
|
|
|
|
|
|
|
COLSTART = int(WIDTH/TEAMNUMCOLS) |
|
|
|
|
|
COLWIDTH = int((WIDTH-COLSTART)/TEAMNUMCOLS) |
|
|
|
|
|
|
|
|
|
|
|
ROWSTART = int(HEIGHT/(TEAMNUMROWS+2)) |
|
|
|
|
|
ROWHEIGHT = int((HEIGHT-ROWSTART)/TEAMNUMROWS) |
|
|
|
|
|
|
|
|
TEAMCOLS = [] |
|
|
TEAMCOLS = [] |
|
|
TEAMROWS = [] |
|
|
TEAMROWS = [] |
|
@@ -72,7 +72,7 @@ for i in range(TEAMNUMROWS): |
|
|
SUBSFILE = "subs.txt" |
|
|
SUBSFILE = "subs.txt" |
|
|
SUBS = [] |
|
|
SUBS = [] |
|
|
|
|
|
|
|
|
SUBNUMROWS = 8 |
|
|
|
|
|
|
|
|
SUBNUMROWS = 9 |
|
|
SUBROWHEIGHT = int((HEIGHT-ROWSTART)/9) |
|
|
SUBROWHEIGHT = int((HEIGHT-ROWSTART)/9) |
|
|
SUBROWS = [] |
|
|
SUBROWS = [] |
|
|
|
|
|
|
|
@@ -138,7 +138,23 @@ class Highlighter(object): |
|
|
if self.iterations >= self.max: |
|
|
if self.iterations >= self.max: |
|
|
# Choosing time |
|
|
# Choosing time |
|
|
self.lastchoice = -1 |
|
|
self.lastchoice = -1 |
|
|
TEAMS[-1].choose() |
|
|
|
|
|
|
|
|
# # ** Name-specific choices! ** # # |
|
|
|
|
|
for tsub in SUBS: |
|
|
|
|
|
if tsub.team == "": |
|
|
|
|
|
choosing_sub = tsub |
|
|
|
|
|
break |
|
|
|
|
|
for j in range(len(TEAMS)): |
|
|
|
|
|
if "amy" not in choosing_sub.sub: |
|
|
|
|
|
if TEAMS[j].team.lower( |
|
|
|
|
|
).startswith(choosing_sub.sub[0].lower()): |
|
|
|
|
|
TEAMS[j].choose() |
|
|
|
|
|
break |
|
|
|
|
|
else: |
|
|
|
|
|
if TEAMS[j].team.lower().startswith("a"): |
|
|
|
|
|
TEAMS[j].choose() |
|
|
|
|
|
break |
|
|
|
|
|
# # End Name-specific stuff # # |
|
|
|
|
|
# TEAMS[-1].choose() |
|
|
pygame.time.set_timer(HIGHLIGHTEVENT, 0) # Disable highlight |
|
|
pygame.time.set_timer(HIGHLIGHTEVENT, 0) # Disable highlight |
|
|
pygame.time.set_timer(CHOOSEEVENT, 5000, True) # make choice |
|
|
pygame.time.set_timer(CHOOSEEVENT, 5000, True) # make choice |
|
|
self.iterations = 0 |
|
|
self.iterations = 0 |
|
@@ -152,19 +168,27 @@ def draw_text(text, font, text_col, x, y): |
|
|
screen.blit(img, (x, y)) |
|
|
screen.blit(img, (x, y)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_team_board(): |
|
|
|
|
|
|
|
|
def setup_team_board(randomise_teams=False): |
|
|
"""Grab teams from text file and set their positions""" |
|
|
"""Grab teams from text file and set their positions""" |
|
|
|
|
|
teamlist = [] |
|
|
|
|
|
|
|
|
with open(TEAMSFILE, "r") as fh: |
|
|
with open(TEAMSFILE, "r") as fh: |
|
|
for row in range(TEAMNUMROWS): |
|
|
|
|
|
for col in range(TEAMNUMCOLS): |
|
|
|
|
|
name = fh.readline().strip() |
|
|
|
|
|
if name == "": |
|
|
|
|
|
continue |
|
|
|
|
|
print("Adding {} at {},{}".format(name, |
|
|
|
|
|
TEAMCOLS[col], |
|
|
|
|
|
TEAMROWS[row])) |
|
|
|
|
|
TEAMS.append(Team(name, |
|
|
|
|
|
TEAMROWS[row], TEAMCOLS[col])) |
|
|
|
|
|
|
|
|
teams = fh.readlines() |
|
|
|
|
|
teamlist = [team.rstrip() for team in teams if team != ""] |
|
|
|
|
|
|
|
|
|
|
|
if randomise_teams: |
|
|
|
|
|
random.shuffle(teamlist) |
|
|
|
|
|
|
|
|
|
|
|
for row in range(TEAMNUMROWS): |
|
|
|
|
|
for col in range(TEAMNUMCOLS): |
|
|
|
|
|
if len(teamlist) == 0: |
|
|
|
|
|
continue |
|
|
|
|
|
name = teamlist.pop(0) |
|
|
|
|
|
print("Adding {} at {},{}".format(name, |
|
|
|
|
|
TEAMCOLS[col], |
|
|
|
|
|
TEAMROWS[row])) |
|
|
|
|
|
TEAMS.append(Team(name, |
|
|
|
|
|
TEAMROWS[row], TEAMCOLS[col])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_subs(): |
|
|
def setup_subs(): |
|
@@ -182,7 +206,7 @@ for line in open(SUBSFILE, "r"): |
|
|
print(SUBS) |
|
|
print(SUBS) |
|
|
|
|
|
|
|
|
random.shuffle(SUBS) |
|
|
random.shuffle(SUBS) |
|
|
setup_team_board() |
|
|
|
|
|
|
|
|
setup_team_board(randomise_teams=True) |
|
|
random.shuffle(TEAMS) |
|
|
random.shuffle(TEAMS) |
|
|
setup_subs() |
|
|
setup_subs() |
|
|
|
|
|
|
|
@@ -221,7 +245,13 @@ while True: |
|
|
elif event.type == CHOOSEEVENT: |
|
|
elif event.type == CHOOSEEVENT: |
|
|
for sub in SUBS: |
|
|
for sub in SUBS: |
|
|
if sub.team == "": |
|
|
if sub.team == "": |
|
|
sub.team = TEAMS.pop().team |
|
|
|
|
|
|
|
|
# # Name-specific again # # |
|
|
|
|
|
for k in range(len(TEAMS)): |
|
|
|
|
|
if TEAMS[k].colour == RED: |
|
|
|
|
|
sub.team = TEAMS.pop(k).team |
|
|
|
|
|
break |
|
|
|
|
|
# # End name-specific # # |
|
|
|
|
|
# sub.team = TEAMS.pop().team |
|
|
pygame.time.set_timer(CLEAREVENT, 100, True) |
|
|
pygame.time.set_timer(CLEAREVENT, 100, True) |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|