All files / web/src/arcade-games/know-your-world/utils guidanceVisibility.ts

100% Statements 82/82
100% Branches 15/15
100% Functions 5/5
100% Lines 82/82

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 831x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 36x 36x 1x 1x 1x 1x 1x 1x 36x 36x 1x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x 1x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 2x 2x 6x 6x 4x 4x 6x 6x 4x 3x 4x 1x 1x 6x 1x 1x 6x 6x 6x 4x 4x 6x 6x 6x  
/**
 * Guidance Visibility Utilities
 *
 * Pure functions for determining which guidance options should be visible
 * based on assistance level configuration. These are extracted for testability.
 */
 
import type { AssistanceLevelConfig } from '../maps'
 
/**
 * Determines if the guidance dropdown should be shown at all.
 * Hidden when there are no configurable guidance options.
 */
export function shouldShowGuidanceDropdown(config: AssistanceLevelConfig): boolean {
  return config.hintsMode !== 'none' || config.hotColdEnabled
}
 
/**
 * Determines if the "Auto-Show Hints" toggle should be visible.
 * Only shown when hints are available in any form.
 */
export function shouldShowAutoHintToggle(config: AssistanceLevelConfig): boolean {
  return config.hintsMode !== 'none'
}
 
/**
 * Determines if the "Auto Speak" toggle should be visible.
 * Only shown when hints are available (speech reads hints aloud).
 */
export function shouldShowAutoSpeakToggle(config: AssistanceLevelConfig): boolean {
  return config.hintsMode !== 'none'
}
 
/**
 * Determines if the "Hot/Cold" toggle should be visible.
 * Only shown when the assistance level enables hot/cold feedback.
 */
export function shouldShowHotColdToggle(config: AssistanceLevelConfig): boolean {
  return config.hotColdEnabled
}
 
/**
 * Feature badge for display in setup UI
 */
export interface FeatureBadge {
  label: string
  icon: string
}
 
/**
 * Generates feature badges for an assistance level.
 * Used in the setup UI to show what features are enabled.
 */
export function getFeatureBadges(level: AssistanceLevelConfig): FeatureBadge[] {
  const badges: FeatureBadge[] = []
 
  // Name confirmation requirement (Learning mode)
  if (level.nameConfirmationLetters) {
    badges.push({ label: 'Type to unlock', icon: '⌨️' })
  }
 
  if (level.hotColdEnabled) {
    badges.push({ label: 'Hot/cold', icon: '🔥' })
  }
 
  if (level.hintsMode === 'onRequest') {
    if (level.autoHintDefault) {
      badges.push({ label: 'Auto-hints', icon: '💡' })
    } else {
      badges.push({ label: 'Hints', icon: '💡' })
    }
  } else if (level.hintsMode === 'limited' && level.hintLimit) {
    badges.push({ label: `${level.hintLimit} hints`, icon: '💡' })
  }
 
  // Wrong click feedback
  if (level.wrongClickShowsName) {
    badges.push({ label: 'Shows names', icon: '👁️' })
  }
 
  return badges
}