# Get player's answer start_time = time.time() user_word = input("π Your word: ").strip().lower() elapsed = time.time() - start_time
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") Word Bomb Script
================================================== π£ Alex's turn! Bomb is ticking... π€ Required letters: AP β±οΈ You have 5 seconds! π Your word: apple β Correct! 'apple' contains 'ap'. πͺ Bomb defused! Passing to next player... # Get player's answer start_time = time
if user_word == 'quit': print("Game ended.") break You must say a word containing the given letters
def is_valid_word(word, required_letters): """Check if word contains the required letters as a substring.""" return required_letters.lower() in word.lower()
# Start bomb timer timer = threading.Thread(target=bomb_timer, args=(5, current_player)) timer.daemon = True timer.start()
================================================== π£ Jamie's turn! Bomb is ticking... π€ Required letters: ZE β±οΈ You have 5 seconds! π Your word: zebra β Correct! 'zebra' contains 'ze'. πͺ Bomb defused! Passing to next player...