from game import CardColor# Available valuesCardColor.RED # Red team wordCardColor.BLUE # Blue team wordCardColor.NEUTRAL # Neutral bystanderCardColor.BOMB # Assassin (game-ending)# Access string valuecolor = CardColor.BOMBprint(color.value) # "bomb"
from game import GameOutcome# Available valuesGameOutcome.RED_WIN # Red team wonGameOutcome.BLUE_WIN # Blue team wonGameOutcome.IN_PROGRESS # Game still in progress# Access string valueoutcome = GameOutcome.BLUE_WINprint(outcome.value) # "blue_win"
from game import TurnResult, CardColor# TurnResult is returned by GameState.make_guess()result = game.make_guess("apple")print(f"Word: {result.word}")print(f"Color: {result.color.value}")print(f"Correct: {result.correct}")print(f"Hit bomb: {result.hit_bomb}")# String representationprint(result)# Output: apple (blue) β# Or: apple (bomb) π£ BOMB!
from game import Turn, Team, TurnResult, CardColor# Turns are created internally by GameState# Access them from turn_historyfor turn in game.turn_history: print(f"Turn {turn.turn_number} - {turn.team.value}") print(f"Hint: {turn.hint_word} ({turn.hint_count})") for guess in turn.guesses: status = "β" if guess.correct else "β" print(f" {guess.word}: {status}") if turn.invalid_guess_word: print(f" Invalid: {turn.invalid_guess_word} - {turn.invalid_guess_reason}")# String representationprint(turn)# Output: Turn 1 (blue): 'fruit' (2) β [apple (blue) β, banana (blue) β]
from game import Team, GameState# Get current teamcurrent = game.current_teamif current == Team.BLUE: print("Blue team's turn") # Get blue team's remaining words remaining = game.get_remaining_words(Team.BLUE) print(f"Blue has {len(remaining)} words left")# Switch between teamsother_team = Team.RED if current == Team.BLUE else Team.BLUE
from game import CardColor, Board# Get words by colorblue_words = board.get_words_by_color(CardColor.BLUE)red_words = board.get_words_by_color(CardColor.RED)neutral_words = board.get_words_by_color(CardColor.NEUTRAL)bomb = board.get_words_by_color(CardColor.BOMB)# Check card colorcolor = board.get_color("apple")if color == CardColor.BOMB: print("Don't pick this word!")elif color == CardColor.NEUTRAL: print("Neutral bystander")
from game import TurnResult# Make a guess and handle resultresult = game.make_guess("apple")if result.hit_bomb: print(f"π£ BOMB! {game.current_team.value} team loses!") print(f"Winner: {game.game_outcome.value}")elif result.correct: print(f"β Correct! {result.word} is {result.color.value}") # Continue guessing if not game.is_game_over: # Make another guess or end turn passelse: print(f"β Wrong. {result.word} is {result.color.value}") game.end_turn() # End turn on wrong guess
# Get complete game historyfor turn in game.turn_history: print(f"\nTurn {turn.turn_number} - {turn.team.value.upper()}") print(f"Hint: '{turn.hint_word}' ({turn.hint_count})") # Analyze guesses correct_guesses = [g for g in turn.guesses if g.correct] wrong_guesses = [g for g in turn.guesses if not g.correct and not g.hit_bomb] bomb_guesses = [g for g in turn.guesses if g.hit_bomb] print(f" Correct: {len(correct_guesses)}") print(f" Wrong: {len(wrong_guesses)}") if bomb_guesses: print(f" π£ Hit bomb: {bomb_guesses[0].word}") if turn.invalid_guess_word: print(f" Invalid attempt: {turn.invalid_guess_word}")