All files / src/missions season-config.ts

83.17% Statements 178/214
50% Branches 4/8
80% Functions 4/5
83.17% Lines 178/214

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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247                                          1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x   1x 3x               3x 3x   1x 45x 45x                 45x   1x 2x 2x 2x 2x       1x 1x                               1x 1x   1x                    
/**
 * FLL Challenge 2026-2027 Season Mission Model Configuration
 * 
 * Controls default loaded state, mat positions, and metadata for all official
 * season mission models. Allows selective loading to maintain fast boot times
 * and low GPU/physics overhead.
 */
 
export interface SeasonMissionSpec {
  id: string;
  missionNumber: number;
  name: string;
  book: string;
  ioFile: string;
  enabledByDefault: boolean;
  isFixedBase: boolean;
  arenaPosition: { x: number; y: number; z: number };
  yawDegrees: number;
  description: string;
}
 
export const SEASON_MISSIONS_CONFIG: SeasonMissionSpec[] = [
  {
    id: 'M01',
    missionNumber: 1,
    name: 'Mission 01: Drone Survey',
    book: 'Book 01',
    ioFile: '/missions/M01.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: -0.75, y: 0.002, z: -0.32 },
    yawDegrees: 0,
    description: 'Drone survey track mechanism with sliding cart and sensor target.',
  },
  {
    id: 'M02',
    missionNumber: 2,
    name: 'Mission 02: Exploding Seeds',
    book: 'Book 02',
    ioFile: '/missions/M02.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: -0.42, y: 0.002, z: -0.36 },
    yawDegrees: 0,
    description: 'Spring-release seed pods mechanism triggered by pushing latch.',
  },
  {
    id: 'M03',
    missionNumber: 3,
    name: 'Mission 03: Flip the Rock',
    book: 'Book 03',
    ioFile: '/missions/M03.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.05, y: 0.002, z: -0.34 },
    yawDegrees: 0,
    description: 'Hinged rock boulder requiring lever arm lift.',
  },
  {
    id: 'M04',
    missionNumber: 4,
    name: 'Mission 04: Lucky Leaves',
    book: 'Book 04',
    ioFile: '/missions/M04.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.48, y: 0.002, z: -0.34 },
    yawDegrees: 0,
    description: 'Flippable leaf clusters with counter-balanced linkage.',
  },
  {
    id: 'M05',
    missionNumber: 5,
    name: 'Mission 05: Reaching Roots',
    book: 'Book 05',
    ioFile: '/missions/M05.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.85, y: 0.002, z: -0.18 },
    yawDegrees: -90,
    description: 'Telescoping root linkage pushed along guide rails.',
  },
  {
    id: 'M06',
    missionNumber: 6,
    name: 'Mission 06: Leafcutter Frenzy',
    book: 'Book 06',
    ioFile: '/missions/M06.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.70, y: 0.002, z: 0.22 },
    yawDegrees: 90,
    description: 'Leafcutter ant conveyor with rotary gear drives.',
  },
  {
    id: 'M07',
    missionNumber: 7,
    name: 'Mission 07: Humongous Fungus',
    book: 'Book 06',
    ioFile: '/missions/M07.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.32, y: 0.002, z: 0.18 },
    yawDegrees: 0,
    description: 'Mushroom cap riser with ratchet and friction pins.',
  },
  {
    id: 'M08',
    missionNumber: 8,
    name: 'Mission 08: Tangled',
    book: 'Book 07',
    ioFile: '/missions/M08.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: -0.06, y: 0.002, z: 0.12 },
    yawDegrees: 0,
    description: 'Vine entanglement mechanism requiring precise rotational release.',
  },
  {
    id: 'M09',
    missionNumber: 9,
    name: 'Mission 09: Research Platform',
    book: 'Book 07',
    ioFile: '/missions/M09.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: -0.46, y: 0.002, z: 0.18 },
    yawDegrees: 0,
    description: 'Elevated fungal research station with payload delivery basket.',
  },
  {
    id: 'M10',
    missionNumber: 10,
    name: 'Mission 10: Fragile Microhabitats',
    book: 'Book 08',
    ioFile: '/missions/M10.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: -0.74, y: 0.002, z: 0.28 },
    yawDegrees: 0,
    description: 'Equilibrium scale mechanism balancing microhabitat blocks.',
  },
  {
    id: 'M11',
    missionNumber: 11,
    name: 'Mission 11: Window to the Past',
    book: 'Book 09',
    ioFile: '/missions/M11.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: -0.22, y: 0.002, z: 0.36 },
    yawDegrees: 0,
    description: 'Amber core cylinder extraction gate with sliding pane.',
  },
  {
    id: 'M12',
    missionNumber: 12,
    name: 'Mission 12: Forest Elder',
    book: 'Book 10',
    ioFile: '/missions/M12.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.82, y: 0.002, z: 0.28 },
    yawDegrees: 180,
    description: 'Ancient tree canopy dial with counterweight balance.',
  },
  {
    id: 'M13',
    missionNumber: 13,
    name: 'Mission 13: Interchangeable Dock',
    book: 'Book 11-13',
    ioFile: '/missions/M13.io',
    enabledByDefault: false,
    isFixedBase: true,
    arenaPosition: { x: 0.54, y: 0.002, z: 0.36 },
    yawDegrees: 0,
    description: 'Dual-lock interchangeable dock for Keystone Species and Biocentric Architecture.',
  },
];
 
const STORAGE_KEY = 'fll_sim_active_season_missions';
const memoryOverrides: Record<string, boolean> = {};
 
export function getStoredSeasonMissionOverrides(): Record<string, boolean> {
  if (typeof localStorage !== 'undefined') {
    try {
      const raw = localStorage.getItem(STORAGE_KEY);
      if (raw) return JSON.parse(raw);
    } catch {
      // ignore
    }
  }
  return { ...memoryOverrides };
}
 
export function saveStoredSeasonMissionOverride(id: string, enabled: boolean): void {
  memoryOverrides[id] = enabled;
  if (typeof localStorage !== 'undefined') {
    try {
      const current = getStoredSeasonMissionOverrides();
      current[id] = enabled;
      localStorage.setItem(STORAGE_KEY, JSON.stringify(current));
    } catch {
      // ignore
    }
  }
}
 
export function isMissionConfigEnabled(config: SeasonMissionSpec): boolean {
  const overrides = getStoredSeasonMissionOverrides();
  if (config.id in overrides) {
    return overrides[config.id];
  }
  return config.enabledByDefault;
}
 
export function getMissionArenaPosition(spec: SeasonMissionSpec): { x: number; y: number; z: number; yawDegrees: number } {
  if (typeof localStorage !== 'undefined') {
    try {
      const raw = localStorage.getItem(`fll_mission_${spec.id}_arena_pose`);
      if (raw) {
        const parsed = JSON.parse(raw);
        return {
          x: typeof parsed.x === 'number' ? parsed.x : spec.arenaPosition.x,
          y: typeof parsed.y === 'number' ? parsed.y : spec.arenaPosition.y,
          z: typeof parsed.z === 'number' ? parsed.z : spec.arenaPosition.z,
          yawDegrees: typeof parsed.yaw === 'number' ? parsed.yaw : spec.yawDegrees,
        };
      }
    } catch {
      // ignore
    }
  }
  return { ...spec.arenaPosition, yawDegrees: spec.yawDegrees };
}
 
export function saveMissionArenaPosition(id: string, pos: { x: number; y: number; z: number }, yawDegrees: number): void {
  if (typeof localStorage !== 'undefined') {
    try {
      localStorage.setItem(`fll_mission_${id}_arena_pose`, JSON.stringify({ ...pos, yaw: yawDegrees }));
    } catch {
      // ignore
    }
  }
}