Skip to content

Commit 876fb5d

Browse files
lock in colors
Signed-off-by: Jonathan Irvin <djfoxyslpr@gmail.com>
1 parent 6f3fffb commit 876fb5d

2 files changed

Lines changed: 71 additions & 14 deletions

File tree

main.py

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
FREE_SPACE_TEXT_COLOR = "#FF7f33"
1616

1717
# --- New: Color constants and font ---
18-
TILE_CLICKED_BG_COLOR = "#3b82f6" # Blue background for clicked tiles
19-
TILE_CLICKED_TEXT_COLOR = "white"
20-
TILE_UNCLICKED_BG_COLOR = "#facc15" # Yellow background for unclicked tiles
21-
TILE_UNCLICKED_TEXT_COLOR = "black"
18+
TILE_CLICKED_BG_COLOR = "#100079"
19+
TILE_CLICKED_TEXT_COLOR = "#1BEFF5"
20+
TILE_UNCLICKED_BG_COLOR = "#1BEFF5"
21+
TILE_UNCLICKED_TEXT_COLOR = "#100079"
2222

2323

2424
HOME_BG_COLOR = "#100079" # Background for home page
@@ -63,7 +63,34 @@ def get_line_style_for_lines(line_count: int, default_text_color: str) -> str:
6363

6464
# Read phrases from a text file and convert them to uppercase.
6565
with open("phrases.txt", "r") as f:
66-
phrases = [line.strip().upper() for line in f if line.strip()]
66+
raw_phrases = [line.strip().upper() for line in f if line.strip()]
67+
68+
# Remove duplicates while preserving order.
69+
unique_phrases = []
70+
seen = set()
71+
for p in raw_phrases:
72+
if p not in seen:
73+
seen.add(p)
74+
unique_phrases.append(p)
75+
76+
# Optional: filter out phrases with too many repeated words.
77+
def has_too_many_repeats(phrase, threshold=0.5):
78+
"""
79+
Returns True if too many of the words in the phrase repeat.
80+
For example, if the ratio of unique words to total words is less than the threshold.
81+
Logs a debug message if the phrase is discarded.
82+
"""
83+
words = phrase.split()
84+
if not words:
85+
return False
86+
unique_count = len(set(words))
87+
ratio = unique_count / len(words)
88+
if ratio < threshold:
89+
logging.debug(f"Discarding phrase '{phrase}' due to repeats: {unique_count}/{len(words)} = {ratio:.2f} < {threshold}")
90+
return True
91+
return False
92+
93+
phrases = [p for p in unique_phrases if not has_too_many_repeats(p)]
6794

6895
# Use today's date as the seed for deterministic shuffling
6996
today_seed = datetime.date.today().strftime("%Y%m%d")
@@ -256,7 +283,7 @@ def create_board_view(background_color: str, is_global: bool):
256283
ui.timer(0.1, lambda: update_tile_styles(local_tile_buttons))
257284
# Display the seed beneath the board.
258285
with ui.element("div").classes("w-full mt-4"):
259-
ui.label(f"Seed: {today_seed}").classes("text-md text-gray-300 text-center")
286+
ui.label(f"Seed: {today_seed}").classes("text-md text-center").style(f"color: {TILE_UNCLICKED_BG_COLOR};")
260287

261288
@ui.page("/")
262289
def home_page():
@@ -441,7 +468,34 @@ def check_phrases_file_change():
441468
last_phrases_mtime = mtime
442469
# Re-read phrases.txt
443470
with open("phrases.txt", "r") as f:
444-
phrases = [line.strip().upper() for line in f if line.strip()]
471+
raw_phrases = [line.strip().upper() for line in f if line.strip()]
472+
473+
# Remove duplicates while preserving order.
474+
unique_phrases = []
475+
seen = set()
476+
for p in raw_phrases:
477+
if p not in seen:
478+
seen.add(p)
479+
unique_phrases.append(p)
480+
481+
# Optional: filter out phrases with too many repeated words.
482+
def has_too_many_repeats(phrase, threshold=0.5):
483+
"""
484+
Returns True if too many of the words in the phrase repeat.
485+
For example, if the ratio of unique words to total words is less than the threshold.
486+
Logs a debug message if the phrase is discarded.
487+
"""
488+
words = phrase.split()
489+
if not words:
490+
return False
491+
unique_count = len(set(words))
492+
ratio = unique_count / len(words)
493+
if ratio < threshold:
494+
logging.debug(f"Discarding phrase '{phrase}' due to repeats: {unique_count}/{len(words)} = {ratio:.2f} < {threshold}")
495+
return True
496+
return False
497+
498+
phrases = [p for p in unique_phrases if not has_too_many_repeats(p)]
445499
# Rebuild board data: re-shuffle and re-create board structure.
446500
shuffled_phrases = random.sample(phrases, 24)
447501
shuffled_phrases.insert(12, FREE_SPACE_TEXT)

phrases.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
Can't have nice things
1+
Can't nice things
22
Techno babble
33
Hell yeah!
4-
We get a raid
5-
That's so Noice
4+
Raided
5+
That's Noice
66
Position one
7-
Hows my audio
7+
How's my audio
88
Someone redeems hydrate
99
Threaten good time
1010
Mentions mods
1111
Says texas
1212
Spins bonus wheel
1313
Join discord
14-
Holy smokes
15-
Says cats or dogs
14+
Holy smokes!
15+
Says Cats or Dogs
1616
Doot doots
1717
Makes air quotes
1818
Talks about ellee
@@ -21,4 +21,7 @@ Sight lines
2121
Talks about palia
2222
Says discord
2323
Dance party
24-
That's nuts!
24+
That's nuts!
25+
Says vel
26+
Says LGS
27+
Says Harlequin Law

0 commit comments

Comments
 (0)