fix(clearance): generate octal squawks and skip reserved codes

genSquawk() drew a decimal number in 1000-8999, so clearances could contain
the digits 8 or 9 — codes no transponder can dial. Replace it with a shared
generateSquawk() that draws four octal digits and re-rolls the reserved codes
(7500/7600/7700, 7000, 2000, 1200, 0000).

shared/learn/scenario.ts had its own octal generator that could still draw an
emergency code; it now uses the same helper.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
itsrubberduck
2026-07-26 19:27:21 +02:00
parent c828ffe221
commit a9f6e6df42
4 changed files with 91 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import type { AirlineData, AirportData, Frequency, FrequencyType, Scenario } from './types'
import { generateSquawk } from '../utils/transponder'
const natoMap: Record<string, string> = {
A: 'Alpha',
@@ -214,14 +215,6 @@ function codeToPhonetic(value: string): string {
.trim()
}
function generateSquawk(): string {
let code = ''
for (let i = 0; i < 4; i++) {
code += String(randInt(0, 7))
}
return code
}
export function digitsToWords(value: string): string {
return value
.split('')