def bomb_timer(seconds, player_name): """Timer thread that waits and then explodes.""" time.sleep(seconds) print(f"\nš£ BOOM! {player_name} took too long! š£") print(f"Required letters were: {required_letters}") exit(0) GAME SETUP ------------------------------ print("\nš„š„š„ WORD BOMB š„š„š„") print("Players take turns. You must say a word containing the given letters.") print("You have 5 seconds before the bomb explodes!") print("Type 'quit' to exit.\n")
# Start bomb timer timer = threading.Thread(target=bomb_timer, args=(5, current_player)) timer.daemon = True timer.start() Word Bomb Script
print("\n" + "="*50) print(f"š£ {current_player}'s turn! Bomb is ticking...") print(f"š¤ Required letters: {required_letters.upper()}") print("ā±ļø You have 5 seconds!") You must say a word containing the given letters
print(f"ā Correct! '{user_word}' contains '{required_letters}'.") print(f"šŖ Bomb defused! Passing to next player...") Passing to next player
if user_word == 'quit': print("Game ended.") break
# If bomb hasn't exploded yet, cancel by not calling exit (thread is still alive, but we'll just not let it affect) # Better: just check if time's up if elapsed > 5: print(f"\nš£ BOOM! Too slow, {current_player}!") print(f"Required letters were: {required_letters}") break
if not is_valid_word(user_word, required_letters): print(f"\nā WRONG! '{user_word}' does not contain '{required_letters}'.") print(f"{current_player} loses!") break