Files
Nonemm/src/Nonemm.Contests/Rules/ArrlDx.cs
T
erikbrockoandClaude Opus 5 bae40bb04e Show the boxes N1MM shows for each contest
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
2026-09-09 20:12:37 +00:00

97 lines
3.8 KiB
C#

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.
///
/// The received power or state goes in the section column, which is where N1MM
/// keeps it, so a log written by either program scores the same in the other.
public sealed class ArrlDx : Contest
{
private readonly ModeCategory mode;
public ArrlDx(ModeCategory mode) => this.mode = mode;
public string Name => mode == ModeCategory.Cw ? "ARRLDXCW" : "ARRLDXSSB";
public string DisplayName => $"ARRL International DX {ModeLabel()}";
public string CabrilloName => mode == ModeCategory.Cw ? "ARRL-DX-CW" : "ARRL-DX-SSB";
/// A W or VE operator copies the power the DX station sends, which goes in
/// the power column; a DX operator copies a state or province, which goes
/// in the section column. Both are where N1MM keeps them.
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
IsNorthAmericanHome(me)
? new ExchangeField("Pwr", ExchangeSlot.Power, ExchangeFieldKind.Power)
: new ExchangeField("State", ExchangeSlot.Section, 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) ? StateOrProvince(me) : 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 = StatesAndProvinces.ArrlDxArea(qso.Qso.Section);
return StatesAndProvinces.ArrlDxMultipliers.Contains(received)
? [new Multiplier(1, received, band)]
: [];
}
public int TotalScore(ScoreTally tally, ContestEntry entry) => tally.Points * tally.TotalMultipliers;
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me, ContestEntry entry) =>
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(IsNorthAmericanHome(me) ? qso.Power : qso.Section, 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";
}