Add the rest of the major contests, .udc files and the registry

ARRL DX, IARU HF, Sweepstakes, RTTY Roundup, NAQP and general logging join
CQ WW and CQ WPX. The Cabrillo QSO line is now built column by column by the
contest, because Sweepstakes puts the callsign after the serial number where
everyone else puts it first.

User-defined contests read the subset of N1MM's .udc settings that covers the
exchange, the dupe rule, points and up to three multipliers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik
2026-08-27 10:35:28 +00:00
parent 0f84bc8972
commit ef631f1dc4
26 changed files with 1162 additions and 13 deletions

View File

@@ -0,0 +1,92 @@
using Nonemm.Contests.Multipliers;
using Nonemm.Core;
namespace Nonemm.Contests.Rules;
/// ARRL International DX, CW and SSB. W and VE stations work DX and nobody
/// else, so the exchange and the multiplier both depend on which side the
/// operator is on.
public sealed class ArrlDx : Contest
{
private readonly ModeCategory mode;
public ArrlDx(ModeCategory mode) => this.mode = mode;
public string Name => "ARRLDX";
public string DisplayName => $"ARRL International DX {ModeLabel()}";
public string CabrilloName => mode == ModeCategory.Cw ? "ARRL-DX-CW" : "ARRL-DX-SSB";
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
IsNorthAmericanHome(me)
? new ExchangeField("Pwr", ExchangeSlot.Exchange1, ExchangeFieldKind.Power)
: new ExchangeField("S/P", ExchangeSlot.Exchange1, ExchangeFieldKind.UsStateOrCanadianProvince),
];
public IReadOnlyList<string> MultiplierNames => ["Mults"];
public DupeScope DupeScope => DupeScope.PerBand;
public bool HasSerialNumbers => false;
public IReadOnlyList<ModeCategory> Modes => [mode];
public string SentExchangeFor(StationInfo me) =>
IsNorthAmericanHome(me)
? $"{DefaultReport()} {StateOrProvince(me)}"
: $"{DefaultReport()} {me.Power}";
/// Only contacts across the W/VE line count, so a DX station working DX or
/// a W station working W scores nothing.
public int PointsFor(QsoContext qso) =>
IsNorthAmericanHome(qso.Me) == IsNorthAmerican(qso.CountryPrefix) ? 0 : 3;
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
if (PointsFor(qso) == 0)
{
return [];
}
string band = qso.Band?.Name ?? "";
if (IsNorthAmericanHome(qso.Me))
{
return qso.CountryPrefix.Length == 0 ? [] : [new Multiplier(1, qso.CountryPrefix, band)];
}
string received = qso.Qso.Exchange1.Trim().ToUpperInvariant();
return StatesAndProvinces.ArrlDxMultipliers.Contains(received)
? [new Multiplier(1, received, band)]
: [];
}
public int TotalScore(ScoreTally tally) => tally.Points * tally.TotalMultipliers;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[
new CabrilloField(me.Callsign, 13),
new CabrilloField(qso.SentReport, 3),
new CabrilloField(IsNorthAmericanHome(me) ? StateOrProvince(me) : me.Power, 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField(qso.Exchange1, 6),
]);
private static bool IsNorthAmericanHome(StationInfo me) => IsNorthAmerican(me.CountryPrefix);
/// The contest's W/VE side is the 48 states, DC and Canada; KH6 and KL7
/// count as DX for it.
private static bool IsNorthAmerican(string countryPrefix) =>
countryPrefix is "K" or "VE";
private static string StateOrProvince(StationInfo me) =>
me.State.Length > 0 ? me.State : me.Province;
private string ModeLabel() => mode == ModeCategory.Cw ? "CW" : "SSB";
private string DefaultReport() => mode == ModeCategory.Cw ? "599" : "59";
}

View File

@@ -17,7 +17,7 @@ public sealed class CqWorldWide : Contest
public string CabrilloName => mode == ModeCategory.Cw ? "CQ-WW-CW" : "CQ-WW-SSB";
public IReadOnlyList<ExchangeField> ExchangeFields =>
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Zone", ExchangeSlot.Zone, ExchangeFieldKind.CqZone),
@@ -70,8 +70,16 @@ public sealed class CqWorldWide : Contest
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[new CabrilloField(qso.SentReport, 3), new CabrilloField(me.CqZone.ToString(), 6)],
[new CabrilloField(qso.ReceivedReport, 3), new CabrilloField(qso.Zone.ToString(), 6)]);
[
new CabrilloField(me.Callsign, 13),
new CabrilloField(qso.SentReport, 3),
new CabrilloField(me.CqZone.ToString(), 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField(qso.Zone.ToString(), 6),
]);
private string ModeLabel() => mode == ModeCategory.Cw ? "CW" : "SSB";

View File

@@ -26,7 +26,7 @@ public sealed class CqWpx : Contest
_ => "CQ-WPX-RTTY",
};
public IReadOnlyList<ExchangeField> ExchangeFields =>
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
@@ -71,8 +71,16 @@ public sealed class CqWpx : Contest
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[new CabrilloField(qso.SentReport, 3), new CabrilloField($"{qso.SentNumber:0000}", 6)],
[new CabrilloField(qso.ReceivedReport, 3), new CabrilloField($"{qso.ReceivedNumber:0000}", 6)]);
[
new CabrilloField(me.Callsign, 13),
new CabrilloField(qso.SentReport, 3),
new CabrilloField($"{qso.SentNumber:0000}", 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField($"{qso.ReceivedNumber:0000}", 6),
]);
private string ModeLabel() => mode switch
{

View File

@@ -0,0 +1,42 @@
using Nonemm.Core;
namespace Nonemm.Contests.Rules;
/// Everyday logging outside a contest: a report either way, no score and no
/// dupe check beyond telling the operator this station is in the log already.
public sealed class GeneralLogging : Contest
{
public string Name => "DX";
public string DisplayName => "General logging";
public string CabrilloName => "DX";
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Name", ExchangeSlot.Name, ExchangeFieldKind.Text, IsRequired: false) { Width = 10 },
new ExchangeField("Comment", ExchangeSlot.Comment, ExchangeFieldKind.Text, IsRequired: false) { Width = 20 },
];
public IReadOnlyList<string> MultiplierNames => [];
public DupeScope DupeScope => DupeScope.PerBandAndMode;
public bool HasSerialNumbers => false;
public IReadOnlyList<ModeCategory> Modes => [];
public string SentExchangeFor(StationInfo me) => "599";
public int PointsFor(QsoContext qso) => 0;
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso) => [];
public int TotalScore(ScoreTally tally) => tally.Qsos;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[new CabrilloField(me.Callsign, 13), new CabrilloField(qso.SentReport, 3)],
[new CabrilloField(qso.Call.Text, 13), new CabrilloField(qso.ReceivedReport, 3)]);
}

View File

@@ -0,0 +1,75 @@
using Nonemm.Core;
namespace Nonemm.Contests.Rules;
/// IARU HF World Championship. The exchange is an ITU zone or, for a society
/// headquarters station, its abbreviation; both count as multipliers per band.
public sealed class IaruHf : Contest
{
public string Name => "IARUHF";
public string DisplayName => "IARU HF World Championship";
public string CabrilloName => "IARU-HF";
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Zone/HQ", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
];
public IReadOnlyList<string> MultiplierNames => ["Zones", "HQ"];
public DupeScope DupeScope => DupeScope.PerBandAndMode;
public bool HasSerialNumbers => false;
public IReadOnlyList<ModeCategory> Modes => [ModeCategory.Cw, ModeCategory.Phone];
public string SentExchangeFor(StationInfo me) => $"599 {me.ItuZone}";
public int PointsFor(QsoContext qso)
{
string exchange = Exchange(qso);
if (!IsZone(exchange))
{
return 1;
}
if (int.TryParse(exchange, out int zone) && zone == qso.Me.ItuZone)
{
return 1;
}
return qso.IsSameContinent ? 3 : 5;
}
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
string exchange = Exchange(qso);
if (exchange.Length == 0)
{
return [];
}
string band = qso.Band?.Name ?? "";
return [new Multiplier(IsZone(exchange) ? 1 : 2, exchange, band)];
}
public int TotalScore(ScoreTally tally) => tally.Points * tally.TotalMultipliers;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[
new CabrilloField(me.Callsign, 13),
new CabrilloField(qso.SentReport, 3),
new CabrilloField(me.ItuZone.ToString(), 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField(qso.Exchange1, 6),
]);
private static string Exchange(QsoContext qso) => qso.Qso.Exchange1.Trim().ToUpperInvariant();
private static bool IsZone(string exchange) =>
exchange.Length > 0 && exchange.All(char.IsAsciiDigit);
}

View File

@@ -0,0 +1,78 @@
using Nonemm.Contests.Multipliers;
using Nonemm.Core;
namespace Nonemm.Contests.Rules;
/// North American QSO Party. Name and location are exchanged, a contact is one
/// point, and states, provinces and North American countries count once a band.
public sealed class NorthAmericanQsoParty : Contest
{
private readonly ModeCategory mode;
public NorthAmericanQsoParty(ModeCategory mode) => this.mode = mode;
public string Name => mode switch
{
ModeCategory.Cw => "NAQPCW",
ModeCategory.Phone => "NAQPSSB",
_ => "NAQPRTTY",
};
public string DisplayName => $"North American QSO Party {ModeLabel()}";
public string CabrilloName => $"NAQP-{ModeLabel()}";
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("Name", ExchangeSlot.Name, ExchangeFieldKind.Text) { Width = 10 },
new ExchangeField("S/P/C", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
];
public IReadOnlyList<string> MultiplierNames => ["Mults"];
public DupeScope DupeScope => DupeScope.PerBand;
public bool HasSerialNumbers => false;
public IReadOnlyList<ModeCategory> Modes => [mode];
public string SentExchangeFor(StationInfo me) =>
$"{me.Name} {(me.State.Length > 0 ? me.State : me.CountryPrefix)}";
public int PointsFor(QsoContext qso) => 1;
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
string band = qso.Band?.Name ?? "";
string exchange = qso.Qso.Exchange1.Trim().ToUpperInvariant();
if (StatesAndProvinces.IsStateOrProvince(exchange))
{
return [new Multiplier(1, exchange, band)];
}
return qso.Continent == "NA" && qso.CountryPrefix.Length > 0
? [new Multiplier(1, qso.CountryPrefix, band)]
: [];
}
public int TotalScore(ScoreTally tally) => tally.Points * tally.TotalMultipliers;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[
new CabrilloField(me.Callsign, 13),
new CabrilloField(me.Name, 10),
new CabrilloField(me.State.Length > 0 ? me.State : me.CountryPrefix, 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.Name, 10),
new CabrilloField(qso.Exchange1, 6),
]);
private string ModeLabel() => mode switch
{
ModeCategory.Cw => "CW",
ModeCategory.Phone => "SSB",
_ => "RTTY",
};
}

View File

@@ -0,0 +1,61 @@
using Nonemm.Contests.Multipliers;
using Nonemm.Core;
namespace Nonemm.Contests.Rules;
/// ARRL RTTY Roundup. One point a contact; states, provinces and DXCC entities
/// each count once for the whole contest.
public sealed class RttyRoundup : Contest
{
public string Name => "ARRLRTTY";
public string DisplayName => "ARRL RTTY Roundup";
public string CabrilloName => "ARRL-RTTY";
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("S/P/Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
];
public IReadOnlyList<string> MultiplierNames => ["Mults"];
public DupeScope DupeScope => DupeScope.PerBand;
public bool HasSerialNumbers => true;
public IReadOnlyList<ModeCategory> Modes => [ModeCategory.Digital];
public string SentExchangeFor(StationInfo me) =>
me.State.Length > 0 ? $"599 {me.State}" : "599";
public int PointsFor(QsoContext qso) => 1;
/// A North American station sends a state or province and counts as that;
/// everyone else counts as their DXCC entity.
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
string exchange = qso.Qso.Exchange1.Trim().ToUpperInvariant();
if (StatesAndProvinces.IsStateOrProvince(exchange))
{
return [new Multiplier(1, exchange, "")];
}
return qso.CountryPrefix.Length == 0 ? [] : [new Multiplier(1, qso.CountryPrefix, "")];
}
public int TotalScore(ScoreTally tally) => tally.Points * tally.TotalMultipliers;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me) =>
new(
[
new CabrilloField(me.Callsign, 13),
new CabrilloField(qso.SentReport, 3),
new CabrilloField(me.State.Length > 0 ? me.State : $"{qso.SentNumber}", 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField(qso.Exchange1, 6),
]);
}

View File

@@ -0,0 +1,69 @@
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 => "SS";
public string DisplayName => $"ARRL Sweepstakes {ModeLabel()}";
public string CabrilloName => mode == ModeCategory.Cw ? "ARRL-SS-CW" : "ARRL-SS-SSB";
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(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("Sec", 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) => 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) =>
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";
}