Show what is spotted and not worked yet

The Available Mults and Qs window: a column per band, the multipliers at the top
of each column and then the stations that are only points. Clicking one puts the
radio there with the call in the entry window, the same as the bandmap does.
Every spot on the bandmap goes through ContestLog.Judge, and what comes back a
dupe is dropped, so the colours and the ordering agree with every other window.

A spot holds a callsign and a frequency and nothing else. For CQ WW that gives
the country multiplier, which is derived from the call, but not the zone, which
is what the other station sends. Where a call history file has an entry for the
call its exchange is filled into the candidate first, so a published CQZone
column brings the zone in and a Sect column makes Sweepstakes work at all.
Filling the zone from the country file instead was rejected: it is wrong for
every large country, and a multiplier that is not there is better than one that
is not real.

A spot has no mode either, so the candidate is judged in the mode the radio is
in. In a mixed-mode contest that means the answer follows the operator.

RadioPosition kept two private mappings — exchange value into a contact, and
call history field into an exchange box — and both are needed here, so they move
to ExchangeSlots and both callers share them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 23:01:11 +00:00
co-authored by Claude Opus 5
parent 1fda1696f2
commit d375d86466
11 changed files with 483 additions and 43 deletions
+72
View File
@@ -0,0 +1,72 @@
using Nonemm.Contests;
using Nonemm.Core;
using Nonemm.Core.Calls;
namespace Nonemm.Session;
/// Moving exchange values between the entry boxes, the call history file and a
/// contact.
public static class ExchangeSlots
{
public static Qso Apply(Qso qso, ExchangeSlot slot, string value) => slot switch
{
ExchangeSlot.ReceivedReport => qso with { ReceivedReport = value },
ExchangeSlot.SerialNumber => qso with { ReceivedNumber = Number(value) },
ExchangeSlot.Zone => qso with { Zone = Number(value) },
ExchangeSlot.Section => qso with { Section = value.ToUpperInvariant() },
ExchangeSlot.Check => qso with { Check = Number(value) },
ExchangeSlot.Precedence => qso with { Precedence = value.ToUpperInvariant() },
ExchangeSlot.Exchange1 => qso with { Exchange1 = value.ToUpperInvariant() },
ExchangeSlot.MiscText => qso with { MiscText = value.ToUpperInvariant() },
ExchangeSlot.Name => qso with { Name = value },
ExchangeSlot.Qth => qso with { Qth = value },
ExchangeSlot.GridSquare => qso with { GridSquare = value.ToUpperInvariant() },
ExchangeSlot.Power => qso with { Power = value },
ExchangeSlot.Comment => qso with { Comment = value },
_ => qso,
};
/// What the call history file says this station sends in one exchange box,
/// or an empty string when the file holds nothing for it.
public static string ValueFrom(CallHistoryEntry known, ExchangeField field) => field.Slot switch
{
ExchangeSlot.Name => known.Name,
// a file for a section contest often carries the state instead
ExchangeSlot.Section => known.Section.Length > 0 ? known.Section : known.State,
ExchangeSlot.Check => Digits(known.Check),
ExchangeSlot.Zone => field.Kind == ExchangeFieldKind.ItuZone
? Digits(known.ItuZone)
: Digits(known.CqZone),
ExchangeSlot.Exchange1 => known.Exchange1,
ExchangeSlot.MiscText => known.MiscText,
ExchangeSlot.GridSquare => known.GridSquare,
ExchangeSlot.Power => known.Power,
ExchangeSlot.Qth => known.State,
_ => "",
};
/// Fills the exchange the call history file published for this station into
/// a contact. Used where nobody has copied the exchange yet: a spotted
/// station the operator has not worked.
public static Qso ApplyHistory(Qso qso, CallHistory history, IReadOnlyList<ExchangeField> exchange)
{
CallHistoryEntry? known = history.Find(qso.Call.Text);
if (known is null)
{
return qso;
}
foreach (ExchangeField field in exchange)
{
string value = ValueFrom(known, field);
if (value.Length > 0)
{
qso = Apply(qso, field.Slot, value);
}
}
return qso;
}
private static string Digits(int value) => value > 0 ? value.ToString() : "";
private static int Number(string value) => int.TryParse(value, out int parsed) ? parsed : 0;
}