Files
Nonemm/src/Nonemm.Contests/Rules/CqOneSixty.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

94 lines
3.5 KiB
C#

using Nonemm.Contests.Multipliers;
using Nonemm.Core;
using Nonemm.Core.Country;
namespace Nonemm.Contests.Rules;
/// The CQ 160 metre contest, CW and phone. One band, so nothing is counted per
/// band: the multipliers are the states, provinces and countries worked, and
/// the points are 2 inside your own country, 5 on your own continent and 10
/// from another.
///
/// A US or Canadian station sends a state or province, which N1MM keeps in the
/// section column; everyone else sends a CQ zone, which it keeps in the
/// exchange column.
public sealed class CqOneSixty : Contest
{
private readonly ModeCategory mode;
public CqOneSixty(ModeCategory mode) => this.mode = mode;
public string Name => mode == ModeCategory.Cw ? "CQ160CW" : "CQ160SSB";
public string DisplayName => $"CQ World-Wide 160 Metre {ModeLabel()}";
public string CabrilloName => mode == ModeCategory.Cw ? "CQ-160-CW" : "CQ-160-SSB";
/// One box takes the state, province or CQ zone the other station sends,
/// as N1MM has it.
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
[
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
];
/// A number is a CQ zone and stays in the exchange column; anything else
/// is a state or province and goes in the section column as well.
public Qso FromExchange1(Qso qso, string typed) =>
int.TryParse(typed, out _)
? qso with { Section = "" }
: qso with { Section = typed.Trim().ToUpperInvariant() };
public IReadOnlyList<string> MultiplierNames => ["States", "Countries"];
public DupeScope DupeScope => DupeScope.Once;
public bool HasSerialNumbers => false;
public IReadOnlyList<ModeCategory> Modes => [mode];
public string SentExchangeFor(StationInfo me) =>
IsUsOrCanadian(me.CountryPrefix)
? me.State.Length > 0 ? me.State : me.Province
: me.CqZone.ToString();
public int PointsFor(QsoContext qso) =>
qso.IsSameCountry ? 2 : qso.IsSameContinent ? 5 : 10;
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
List<Multiplier> found = [];
string area = StatesAndProvinces.ArrlDxArea(qso.Qso.Section);
if (StatesAndProvinces.ArrlDxMultipliers.Contains(area))
{
found.Add(new Multiplier(1, area, ""));
}
if (qso.CountryPrefix.Length > 0)
{
found.Add(new Multiplier(2, qso.CountryPrefix, ""));
}
return found;
}
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(SentExchangeFor(me), 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField(qso.Section.Length > 0 ? qso.Section : qso.Exchange1, 6),
]);
private static bool IsUsOrCanadian(string countryPrefix) => countryPrefix is "K" or "VE";
private string ModeLabel() => mode == ModeCategory.Cw ? "CW" : "SSB";
}