All files / web/src/arcade-games/know-your-world/components MapRenderer.stories.tsx

0% Statements 0/188
0% Branches 0/1
0% Functions 0/1
0% Lines 0/188

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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189                                                                                                                                                                                                                                                                                                                                                                                         
import type { Meta, StoryObj } from '@storybook/react'
import { MapRenderer } from './MapRenderer'
import { getFilteredMapDataSync } from '../maps'
import type { ContinentId } from '../continents'

// Custom args type for stories (not actual component props)
type StoryArgs = {
  continent: ContinentId | 'all'
  difficulty: 'easy' | 'hard'
  showArrows: boolean
  centeringStrength: number
  collisionPadding: number
  simulationIterations: number
  useObstacles: boolean
  obstaclePadding: number
}

const meta: Meta<StoryArgs> = {
  title: 'Arcade/KnowYourWorld/MapRenderer',
  parameters: {
    layout: 'fullscreen',
  },
  argTypes: {
    continent: {
      control: 'select',
      options: [
        'all',
        'africa',
        'asia',
        'europe',
        'north-america',
        'south-america',
        'oceania',
        'antarctica',
      ],
      description: 'Select a continent to filter the map',
    },
    difficulty: {
      control: 'select',
      options: ['easy', 'hard'],
      description: 'Game difficulty',
    },
    showArrows: {
      control: 'boolean',
      description: 'Show arrow labels for small regions (experimental feature)',
    },
    centeringStrength: {
      control: { type: 'range', min: 0.1, max: 10, step: 0.1 },
      description: 'Force pulling labels back to regions (higher = stronger)',
    },
    collisionPadding: {
      control: { type: 'range', min: 0, max: 50, step: 1 },
      description: 'Extra padding around labels for collision detection',
    },
    simulationIterations: {
      control: { type: 'range', min: 0, max: 500, step: 10 },
      description: 'Number of simulation iterations (more = more settled)',
    },
    useObstacles: {
      control: 'boolean',
      description: 'Use region obstacles to push labels away from map',
    },
    obstaclePadding: {
      control: { type: 'range', min: 0, max: 50, step: 1 },
      description: 'Extra padding around region obstacles',
    },
  },
}

export default meta
type Story = StoryObj<StoryArgs>

// Mock data
const mockPlayerMetadata = {
  'player-1': {
    id: 'player-1',
    name: 'Player 1',
    emoji: '😊',
    color: '#3b82f6',
  },
  'player-2': {
    id: 'player-2',
    name: 'Player 2',
    emoji: '🎮',
    color: '#ef4444',
  },
}

// Story template
const Template = (args: StoryArgs) => {
  const mapData = getFilteredMapDataSync('world', args.continent, args.difficulty)

  // Simulate some found regions (first 5 regions)
  const regionsFound = mapData.regions.slice(0, 5).map((r) => r.id)

  // Mock guess history
  const guessHistory = regionsFound.map((regionId, index) => ({
    playerId: index % 2 === 0 ? 'player-1' : 'player-2',
    regionId,
    correct: true,
  }))

  // Map difficulty to assistance level for rendering
  const assistanceLevel = args.difficulty === 'easy' ? 'helpful' : 'standard'

  return (
    <div style={{ padding: '20px', minHeight: '100vh', background: '#111827' }}>
      <MapRenderer
        mapData={mapData}
        regionsFound={regionsFound}
        currentPrompt={mapData.regions[5]?.id || null}
        assistanceLevel={assistanceLevel}
        selectedMap="world"
        selectedContinent={args.continent}
        onRegionClick={(id, name) => console.log('Clicked:', id, name)}
        guessHistory={guessHistory}
        playerMetadata={mockPlayerMetadata}
        giveUpReveal={null}
        hintActive={null}
        onGiveUp={() => console.log('Give Up clicked')}
        forceTuning={{
          showArrows: args.showArrows,
          centeringStrength: args.centeringStrength,
          collisionPadding: args.collisionPadding,
          simulationIterations: args.simulationIterations,
          useObstacles: args.useObstacles,
          obstaclePadding: args.obstaclePadding,
        }}
      />
    </div>
  )
}

export const Oceania: Story = {
  render: Template,
  args: {
    continent: 'oceania',
    difficulty: 'easy',
    showArrows: false,
    centeringStrength: 2.0,
    collisionPadding: 5,
    simulationIterations: 200,
    useObstacles: true,
    obstaclePadding: 10,
  },
}

export const Europe: Story = {
  render: Template,
  args: {
    continent: 'europe',
    difficulty: 'easy',
    showArrows: false,
    centeringStrength: 2.0,
    collisionPadding: 5,
    simulationIterations: 200,
    useObstacles: true,
    obstaclePadding: 10,
  },
}

export const Africa: Story = {
  render: Template,
  args: {
    continent: 'africa',
    difficulty: 'easy',
    showArrows: false,
    centeringStrength: 2.0,
    collisionPadding: 5,
    simulationIterations: 200,
    useObstacles: true,
    obstaclePadding: 10,
  },
}

export const AllWorld: Story = {
  render: Template,
  args: {
    continent: 'all',
    difficulty: 'easy',
    showArrows: false,
    centeringStrength: 2.0,
    collisionPadding: 5,
    simulationIterations: 200,
    useObstacles: true,
    obstaclePadding: 10,
  },
}