mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-05 00:46:00 +08:00
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:
@@ -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('')
|
||||
|
||||
Reference in New Issue
Block a user