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
106 lines
4.1 KiB
C#
106 lines
4.1 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Contests.Rules;
|
|
|
|
/// The EU DX Contest. Its "Europe" is the European Union: the member states,
|
|
/// their outermost regions and their overseas territories, and nothing else.
|
|
/// The exchange is the country and district code of the other station.
|
|
///
|
|
/// A contact with a station in that list is worth 10 points, or 2 inside your
|
|
/// own country. Everything else is 3 points on your own continent and 5 from
|
|
/// another.
|
|
public sealed class EuDxContest : Contest
|
|
{
|
|
/// The member states, and the entities that are legally part of one: the
|
|
/// Azores and Madeira, the Canaries, Ceuta and Melilla, the French overseas
|
|
/// departments, Cyprus, and the Dutch and Danish territories.
|
|
private static readonly IReadOnlySet<string> Union = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
"9A", "9H", "CT", "CU", "DL", "EA", "EA6", "EI", "ES", "F", "HA", "I", "IS", "IT9",
|
|
"LX", "LY", "LZ", "OE", "OH", "OH0", "OJ0", "OK", "OM", "ON", "OX", "OZ", "PA", "S5",
|
|
"SM", "SP", "SV", "SV5", "SV9", "TK", "YL", "YO",
|
|
"5B", "CT3", "EA8", "EA9", "FO", "FP", "FY", "IG9", "IH9", "P4",
|
|
"PJ0", "PJ2", "PJ4", "PJ5", "PJ6", "PJ7", "PJ8",
|
|
};
|
|
|
|
public string Name => "EUDXC";
|
|
|
|
public string DisplayName => "EU DX Contest";
|
|
|
|
public string CabrilloName => "EUDXC";
|
|
|
|
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 = 5 },
|
|
];
|
|
|
|
/// A station in the union sends a district code, which goes in the section
|
|
/// column; everyone else sends a CQ zone, which goes in the zone column.
|
|
public Qso FromExchange1(Qso qso, string typed) =>
|
|
IsUnion(qso.CountryPrefix)
|
|
? qso with { Section = typed.Trim().ToUpperInvariant() }
|
|
: qso with { Zone = int.TryParse(typed, out int zone) ? zone : 0 };
|
|
|
|
public IReadOnlyList<string> MultiplierNames => ["Codes", "Countries"];
|
|
|
|
public DupeScope DupeScope => DupeScope.PerBandAndMode;
|
|
|
|
public bool HasSerialNumbers => false;
|
|
|
|
public IReadOnlyList<ModeCategory> Modes => [ModeCategory.Cw, ModeCategory.Phone];
|
|
|
|
public string SentExchangeFor(StationInfo me) => "";
|
|
|
|
public int PointsFor(QsoContext qso)
|
|
{
|
|
if (IsUnion(qso.CountryPrefix))
|
|
{
|
|
return qso.IsSameCountry ? 2 : 10;
|
|
}
|
|
if (!qso.IsSameContinent)
|
|
{
|
|
return 5;
|
|
}
|
|
return IsUnion(qso.Me.CountryPrefix) || !qso.IsSameCountry ? 3 : 2;
|
|
}
|
|
|
|
/// The district code and the country each count once per band. Only a
|
|
/// station in the union sends a code; everyone else sends a CQ zone, which
|
|
/// counts for nothing.
|
|
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
|
|
{
|
|
string band = qso.Band?.Name ?? "";
|
|
List<Multiplier> found = [];
|
|
string code = qso.Qso.Section.Trim().ToUpperInvariant();
|
|
if (IsUnion(qso.CountryPrefix) && code.Length > 0)
|
|
{
|
|
found.Add(new Multiplier(1, code, band));
|
|
}
|
|
if (qso.CountryPrefix.Length > 0)
|
|
{
|
|
found.Add(new Multiplier(2, qso.CountryPrefix, band));
|
|
}
|
|
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(entry.SentExchange, 5),
|
|
],
|
|
[
|
|
new CabrilloField(qso.Call.Text, 13),
|
|
new CabrilloField(qso.ReceivedReport, 3),
|
|
new CabrilloField(qso.Section.Length > 0 ? qso.Section : qso.Exchange1, 5),
|
|
]);
|
|
|
|
private static bool IsUnion(string countryPrefix) => Union.Contains(countryPrefix);
|
|
}
|