Skip to content

Commit

Permalink
Reply to radio check even when callsign not on scope
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmab committed Sep 10, 2024
1 parent 3c384a4 commit 534e11a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
8 changes: 6 additions & 2 deletions docs/PLAYER.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Tips:

Keyword: `RADIO` or `COMM`

Function: The GCI will respond if they both see you on scope and heard you.
Function: The GCI will respond if they heard you. They will also inform you if they cannot see you on the radar scope.

Use: Testing communication with the bot.
Use: Testing communication with the bot.

Examples:

Expand All @@ -110,6 +110,10 @@ YELLOW 13: "Goliath Yellow One Three radio"
GOLIATH: "Yellow One Three, loud and clear"
```

Tips:

* Note that if your aircraft is still sitting on the ramp, you may not be visible on the radar scope yet.

### ALPHA CHECK

Keyword: `ALPHA`
Expand Down
2 changes: 2 additions & 0 deletions pkg/brevity/radiocheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ type RadioCheckResponse struct {
// Callsign of the friendly aircraft requesting the RADIO CHECK.
// If the callsign was misheard, this may not be the actual callsign of any actual aircraft.
Callsign string
// RadarContact indicates whether the callsign was found on the radar scope.
RadarContact bool
}
45 changes: 32 additions & 13 deletions pkg/composer/radiocheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,39 @@ import (

// ComposeRadioCheckResponse implements [Composer.ComposeRadioCheckResponse].
func (c *composer) ComposeRadioCheckResponse(response brevity.RadioCheckResponse) NaturalLanguageResponse {
replies := []string{
"%s, 5 by 5.",
"%s, 5 by 5!",
"%s, I read you 5 by 5.",
"%s, I've got you 5 by 5.",
"%s, loud and clear.",
"%s, I read you loud and clear.",
"%s, I've got you loud and clear.",
"%s, Lima Charlie.",
"%s, Lima Charlie!",
var reply string
if response.RadarContact {
replies := []string{
"%s, 5 by 5.",
"%s, 5 by 5!",
"%s, I read you 5 by 5.",
"%s, I've got you 5 by 5.",
"%s, loud and clear.",
"%s, I read you loud and clear.",
"%s, I've got you loud and clear.",
"%s, Lima Charlie.",
"%s, Lima Charlie!",
}
reply = replies[rand.IntN(len(replies))]
} else {
replies1 := []string{
"%s, I've got you 5 by 5",
"%s, I read you 5 by 5",
"%s, I've got you loud and clear",
"%s, I read you loud and clear",
"%s, I heard you",
}
replies2 := []string{
"but I don't see you on the scope.",
"but I don't see you on the radar.",
"but I don't see you on the scope.",
"but I don't see you on the radar.",
"but you are not on the scope.",
"but you are not on my radar.",
}
reply = fmt.Sprintf("%s, %s", replies1[rand.IntN(len(replies1))], replies2[rand.IntN(len(replies2))])
}

variation := replies[rand.IntN(len(replies))]
reply := fmt.Sprintf(variation, response.Callsign)
reply = fmt.Sprintf(reply, response.Callsign)
return NaturalLanguageResponse{
Subtitle: reply,
Speech: reply,
Expand Down
13 changes: 8 additions & 5 deletions pkg/controller/radiocheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import (
func (c *controller) HandleRadioCheck(request *brevity.RadioCheckRequest) {
logger := log.With().Str("callsign", request.Callsign).Type("type", request).Logger()
logger.Debug().Msg("handling request")
foundCallsign, trackfile := c.scope.FindCallsign(request.Callsign, c.coalition)
if trackfile == nil {
var response brevity.RadioCheckResponse
if foundCallsign, trackfile := c.scope.FindCallsign(request.Callsign, c.coalition); trackfile == nil {
logger.Debug().Msg("no trackfile found for requestor")
c.out <- brevity.NegativeRadarContactResponse{Callsign: request.Callsign}
response.Callsign = request.Callsign
return
} else {
logger.Debug().Msg("found requestor's trackfile")
response.Callsign = foundCallsign
response.RadarContact = true
}
logger.Debug().Msg("found requestor's trackfile")
c.out <- brevity.RadioCheckResponse{Callsign: foundCallsign}
c.out <- response
}

0 comments on commit 534e11a

Please sign in to comment.