The entry window had a fixed set of boxes with a Name and Comment box beside the exchange. N1MM lays out one row of boxes per contest and nothing else, so this does the same: general logging keeps Name and Comment, and a contest gets the boxes it exchanges. Two new members on `Contest` carry the cases where the boxes and the log columns are not the same list: - `FromExchange1` spreads what was typed in one box across the log columns. Where the other station sends a serial or a district code depending on where it is, N1MM gives it one box and sorts the value into the number, section or zone column from there, so the score and the Cabrillo file read it from the same column N1MM does. - `LogFieldsFor` gives the log window its own column list. Sweepstakes takes the whole exchange in one box and logs it in four columns; `SweepstakesExchange` parses `72 A 74 SCV` in any order, reading from the last word back as N1MM does. The sent serial is now marked as not required and space steps over it along with the two report boxes, because nobody types the number going out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
94 lines
3.6 KiB
C#
94 lines
3.6 KiB
C#
using Nonemm.Contests.Multipliers;
|
|
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Contests.Rules;
|
|
|
|
/// ARRL November Sweepstakes. A station counts once for the whole contest
|
|
/// whatever the band, and the multiplier is the ARRL or RAC section.
|
|
public sealed class Sweepstakes : Contest
|
|
{
|
|
private readonly ModeCategory mode;
|
|
|
|
public Sweepstakes(ModeCategory mode) => this.mode = mode;
|
|
|
|
public string Name => mode == ModeCategory.Cw ? "SSCW" : "SSSSB";
|
|
|
|
public string DisplayName => $"ARRL Sweepstakes {ModeLabel()}";
|
|
|
|
public string CabrilloName => mode == ModeCategory.Cw ? "ARRL-SS-CW" : "ARRL-SS-SSB";
|
|
|
|
/// The whole exchange goes in one box, as it does in N1MM: the number,
|
|
/// precedence, check and section are read back out of what was typed.
|
|
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
|
[
|
|
new ExchangeField("Snt Nr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
|
new ExchangeField(
|
|
"Nr Prec CK Section",
|
|
ExchangeSlot.Exchange1,
|
|
ExchangeFieldKind.SweepstakesExchange),
|
|
];
|
|
|
|
public Qso FromExchange1(Qso qso, string typed)
|
|
{
|
|
SweepstakesExchange exchange = SweepstakesExchange.Parse(typed);
|
|
return qso with
|
|
{
|
|
ReceivedNumber = exchange.Number,
|
|
Precedence = exchange.Precedence,
|
|
Check = exchange.Check,
|
|
Section = exchange.Section,
|
|
};
|
|
}
|
|
|
|
/// The log keeps the four parts in four columns, as N1MM's does.
|
|
public IReadOnlyList<ExchangeField> LogFieldsFor(StationInfo me) =>
|
|
[
|
|
new ExchangeField("NR", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
|
new ExchangeField("Prec", ExchangeSlot.Precedence, ExchangeFieldKind.Precedence),
|
|
new ExchangeField("CK", ExchangeSlot.Check, ExchangeFieldKind.Check),
|
|
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.ArrlSection),
|
|
];
|
|
|
|
public IReadOnlyList<string> MultiplierNames => ["Sections"];
|
|
|
|
public DupeScope DupeScope => DupeScope.Once;
|
|
|
|
public bool HasSerialNumbers => true;
|
|
|
|
public IReadOnlyList<ModeCategory> Modes => [mode];
|
|
|
|
public string SentExchangeFor(StationInfo me) =>
|
|
$"{me.Precedence} {me.Callsign} {me.Check:00} {me.ArrlSection}";
|
|
|
|
public int PointsFor(QsoContext qso) => 2;
|
|
|
|
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
|
|
{
|
|
string section = qso.Qso.Section.Trim().ToUpperInvariant();
|
|
return ArrlSections.IsSection(section) ? [new Multiplier(1, section, "")] : [];
|
|
}
|
|
|
|
public int TotalScore(ScoreTally tally, ContestEntry entry) => tally.Points * tally.TotalMultipliers;
|
|
|
|
/// Sweepstakes puts the callsign after the serial number and precedence
|
|
/// rather than first, which is why the writer takes the whole column list.
|
|
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me, ContestEntry entry) =>
|
|
new(
|
|
[
|
|
new CabrilloField($"{qso.SentNumber}", 4),
|
|
new CabrilloField(me.Precedence, 1),
|
|
new CabrilloField(me.Callsign, 13),
|
|
new CabrilloField($"{me.Check:00}", 2),
|
|
new CabrilloField(me.ArrlSection, 3),
|
|
],
|
|
[
|
|
new CabrilloField($"{qso.ReceivedNumber}", 4),
|
|
new CabrilloField(qso.Precedence, 1),
|
|
new CabrilloField(qso.Call.Text, 13),
|
|
new CabrilloField($"{qso.Check:00}", 2),
|
|
new CabrilloField(qso.Section, 3),
|
|
]);
|
|
|
|
private string ModeLabel() => mode == ModeCategory.Cw ? "CW" : "SSB";
|
|
}
|