Viktorani API - v0.0.8
    Preparing search index...

    Function useBuzzer

    • All buzzer logic for the GM side.

      Parameters

      • game: Game

        The active game record. Used for configuration flags and IDs.

      • questionId: string | null

        ID of the currently displayed question, or null if none.

      Returns UseBuzzerResult

      This hook does not subscribe to transport events itself — the caller is responsible for forwarding BUZZ events via handleIncomingBuzz. This keeps the single transport subscription in the GameMaster component and avoids duplicate registrations when the hook re-renders.

      False-start handling: If game.allowFalseStarts is false, buzzes that arrive while the buzzer is locked are silently ignored. If true, they are recorded with isFalseStart: true and shown in the GM's buzz list.

      Auto-lock: When game.autoLockOnFirstCorrect is true, the buzzer is locked automatically after the GM rules a buzz as 'Correct'.

      Scoring: When game.scoringEnabled is true, a correct ruling increments the player's score by the difficulty point value of the current question.

      const { displayBuzzes, toggleLock, adjudicate } = useBuzzer(game, currentQuestionId)

      useTransportEvents(useCallback(event => {
      if (event.type === 'BUZZ') {
      handleIncomingBuzz(event)
      }
      }, [handleIncomingBuzz]))