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
This commit is contained in:
@@ -29,6 +29,20 @@ public interface Contest
|
||||
/// contests skip nothing.
|
||||
bool SkipsField(ExchangeField field, CountryLookup? their) => false;
|
||||
|
||||
/// Spreads what was typed in the one exchange box across the other log
|
||||
/// columns. A lot of contests are a serial number from one station and a
|
||||
/// district code from another, and N1MM gives them a single box and sorts
|
||||
/// the value into the section, number or zone column from there. The
|
||||
/// contact already holds the typed text in `Exchange1` and the country of
|
||||
/// the call. Contests with a box per column change nothing.
|
||||
Qso FromExchange1(Qso qso, string typed) => qso;
|
||||
|
||||
/// The exchange columns of the log window. N1MM keeps a column list per
|
||||
/// contest that is not the entry box list: Sweepstakes types the whole
|
||||
/// exchange in one box and logs it in four columns. The columns follow the
|
||||
/// boxes where a contest does not say otherwise.
|
||||
IReadOnlyList<ExchangeField> LogFieldsFor(StationInfo me) => ExchangeFieldsFor(me);
|
||||
|
||||
/// Up to three names, in the order the score summary shows them.
|
||||
IReadOnlyList<string> MultiplierNames { get; }
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ public sealed record ExchangeField(
|
||||
/// How wide the box needs to be, in characters.
|
||||
public int Width { get; init; } = DefaultWidth(Kind);
|
||||
|
||||
/// True for a box holding what this station sends. N1MM shows those boxes,
|
||||
/// fills them in and steps over them, so nothing here waits for one.
|
||||
public bool IsSent => Slot is ExchangeSlot.SentReport or ExchangeSlot.SentNumber;
|
||||
|
||||
private static int DefaultWidth(ExchangeFieldKind kind) => kind switch
|
||||
{
|
||||
ExchangeFieldKind.Report => 3,
|
||||
@@ -22,6 +26,7 @@ public sealed record ExchangeField(
|
||||
ExchangeFieldKind.Precedence => 1,
|
||||
ExchangeFieldKind.Check => 2,
|
||||
ExchangeFieldKind.Power => 4,
|
||||
ExchangeFieldKind.SweepstakesExchange => 16,
|
||||
_ => 8,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,4 +15,8 @@ public enum ExchangeFieldKind
|
||||
Power,
|
||||
Precedence,
|
||||
Check,
|
||||
|
||||
/// The whole Sweepstakes exchange in one box: number, precedence, check
|
||||
/// and section, typed in any order. N1MM has one box for it too.
|
||||
SweepstakesExchange,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace Nonemm.Contests;
|
||||
/// columns so an exchange lands in the same place N1MM would put it.
|
||||
public enum ExchangeSlot
|
||||
{
|
||||
SentReport,
|
||||
SentNumber,
|
||||
ReceivedReport,
|
||||
SerialNumber,
|
||||
Zone,
|
||||
|
||||
@@ -10,6 +10,8 @@ public static class QsoExchange
|
||||
/// box it holds nothing for.
|
||||
public static string ValueOf(Qso qso, ExchangeSlot slot) => slot switch
|
||||
{
|
||||
ExchangeSlot.SentReport => qso.SentReport,
|
||||
ExchangeSlot.SentNumber => Digits(qso.SentNumber),
|
||||
ExchangeSlot.ReceivedReport => qso.ReceivedReport,
|
||||
ExchangeSlot.SerialNumber => Digits(qso.ReceivedNumber),
|
||||
ExchangeSlot.Zone => Digits(qso.Zone),
|
||||
|
||||
@@ -20,7 +20,8 @@ public sealed class AllAsian : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Age", ExchangeSlot.Exchange1, ExchangeFieldKind.Number) { Width = 3 },
|
||||
];
|
||||
|
||||
|
||||
@@ -17,19 +17,29 @@ public sealed class Arrl10Metre : Contest
|
||||
|
||||
public string CabrilloName => "ARRL-10";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("S/P", ExchangeSlot.Section, ExchangeFieldKind.UsStateOrCanadianProvince),
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Number),
|
||||
];
|
||||
/// One box takes the state, province or serial number the other station
|
||||
/// sends, as N1MM has it. The sent serial box is there only where this
|
||||
/// station sends a number rather than a state.
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => SendsState(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
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 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
|
||||
];
|
||||
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) => field.Slot switch
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && !SendsState(their.Entity.PrimaryPrefix),
|
||||
ExchangeSlot.Exchange1 => their is not null && SendsState(their.Entity.PrimaryPrefix),
|
||||
_ => false,
|
||||
};
|
||||
/// A number is a serial and anything else is a state or province.
|
||||
public Qso FromExchange1(Qso qso, string typed) =>
|
||||
int.TryParse(typed, out int number)
|
||||
? qso with { ReceivedNumber = number, Section = "" }
|
||||
: qso with { ReceivedNumber = 0, Section = typed.Trim().ToUpperInvariant() };
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["States", "Countries"];
|
||||
|
||||
|
||||
@@ -21,12 +21,16 @@ public sealed class ArrlDx : Contest
|
||||
|
||||
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("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
IsNorthAmericanHome(me)
|
||||
? new ExchangeField("Pwr", ExchangeSlot.Section, ExchangeFieldKind.Power)
|
||||
: new ExchangeField("S/P", ExchangeSlot.Section, ExchangeFieldKind.UsStateOrCanadianProvince),
|
||||
? new ExchangeField("Pwr", ExchangeSlot.Power, ExchangeFieldKind.Power)
|
||||
: new ExchangeField("State", ExchangeSlot.Section, ExchangeFieldKind.UsStateOrCanadianProvince),
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Mults"];
|
||||
@@ -74,7 +78,7 @@ public sealed class ArrlDx : Contest
|
||||
[
|
||||
new CabrilloField(qso.Call.Text, 13),
|
||||
new CabrilloField(qso.ReceivedReport, 3),
|
||||
new CabrilloField(qso.Section, 6),
|
||||
new CabrilloField(IsNorthAmericanHome(me) ? qso.Power : qso.Section, 6),
|
||||
]);
|
||||
|
||||
private static bool IsNorthAmericanHome(StationInfo me) => IsNorthAmerican(me.CountryPrefix);
|
||||
|
||||
@@ -25,8 +25,10 @@ public sealed class BartgSprint : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("RcvNr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("Time", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 4 },
|
||||
];
|
||||
|
||||
|
||||
@@ -24,19 +24,21 @@ public sealed class CqOneSixty : Contest
|
||||
|
||||
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("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("S/P", ExchangeSlot.Section, ExchangeFieldKind.UsStateOrCanadianProvince),
|
||||
new ExchangeField("Zone", ExchangeSlot.Exchange1, ExchangeFieldKind.CqZone),
|
||||
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 },
|
||||
];
|
||||
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) => field.Slot switch
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && !IsUsOrCanadian(their.Entity.PrimaryPrefix),
|
||||
ExchangeSlot.Exchange1 => their is not null && IsUsOrCanadian(their.Entity.PrimaryPrefix),
|
||||
_ => false,
|
||||
};
|
||||
/// 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"];
|
||||
|
||||
|
||||
@@ -39,14 +39,16 @@ public sealed class CqWorldWide : Contest
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsRtty
|
||||
?
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Zone", ExchangeSlot.Zone, ExchangeFieldKind.CqZone),
|
||||
new ExchangeField("S/P", ExchangeSlot.Section, ExchangeFieldKind.UsStateOrCanadianProvince, IsRequired: false),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("CQ-Zone", ExchangeSlot.Zone, ExchangeFieldKind.CqZone),
|
||||
new ExchangeField("State/RAC", ExchangeSlot.Section, ExchangeFieldKind.UsStateOrCanadianProvince, IsRequired: false),
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Zone", ExchangeSlot.Zone, ExchangeFieldKind.CqZone),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("CQ-Zone", ExchangeSlot.Zone, ExchangeFieldKind.CqZone),
|
||||
];
|
||||
|
||||
/// On RTTY the exchange carries a state or province, but only from the US
|
||||
|
||||
@@ -33,8 +33,10 @@ public sealed class CqWpx : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("SntNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("RcvNR", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Prefixes"];
|
||||
|
||||
@@ -31,10 +31,18 @@ public sealed class EuDxContest : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Code", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 5 },
|
||||
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;
|
||||
@@ -90,7 +98,7 @@ public sealed class EuDxContest : Contest
|
||||
[
|
||||
new CabrilloField(qso.Call.Text, 13),
|
||||
new CabrilloField(qso.ReceivedReport, 3),
|
||||
new CabrilloField(qso.Section, 5),
|
||||
new CabrilloField(qso.Section.Length > 0 ? qso.Section : qso.Exchange1, 5),
|
||||
]);
|
||||
|
||||
private static bool IsUnion(string countryPrefix) => Union.Contains(countryPrefix);
|
||||
|
||||
@@ -15,7 +15,9 @@ public sealed class FieldDayRegionOne : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
];
|
||||
|
||||
|
||||
@@ -27,19 +27,36 @@ public sealed class FrenchRef : Contest
|
||||
|
||||
public string CabrilloName => mode == ModeCategory.Cw ? "REF-CW" : "REF-SSB";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Dept", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 3 },
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Number),
|
||||
];
|
||||
/// A French operator works both sides and gets one box for whichever the
|
||||
/// other station sends; everyone else works French stations alone, so the
|
||||
/// box is the department and this station sends a serial number.
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsFrench(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Department", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
];
|
||||
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) => field.Slot switch
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && their.Entity.PrimaryPrefix != "F",
|
||||
ExchangeSlot.Exchange1 => their is not null && their.Entity.PrimaryPrefix == "F",
|
||||
_ => false,
|
||||
};
|
||||
public Qso FromExchange1(Qso qso, string typed) =>
|
||||
qso.CountryPrefix == "F"
|
||||
? qso with { Section = typed.Trim().ToUpperInvariant() }
|
||||
: qso with { ReceivedNumber = int.TryParse(typed, out int number) ? number : 0 };
|
||||
|
||||
/// N1MM's log for this contest keeps what the one box was sorted into in a
|
||||
/// column of its own beside the exchange.
|
||||
public IReadOnlyList<ExchangeField> LogFieldsFor(StationInfo me) =>
|
||||
[
|
||||
.. ExchangeFieldsFor(me),
|
||||
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 5 },
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Mults"];
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ public sealed class GeneralLogging : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", 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 },
|
||||
];
|
||||
|
||||
@@ -17,8 +17,9 @@ public sealed class IaruHf : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Zone/HQ", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 6 },
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("ITU-Zone", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 6 },
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Zones", "HQ"];
|
||||
|
||||
@@ -19,7 +19,9 @@ public sealed class Iota : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("IOTA", ExchangeSlot.Section, ExchangeFieldKind.Text, IsRequired: false)
|
||||
{
|
||||
|
||||
@@ -15,18 +15,26 @@ public sealed class MexicoRtty : Contest
|
||||
|
||||
public string CabrilloName => "XE-RTTY";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("State", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 3 },
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Number),
|
||||
];
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsMexican(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("SentNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
];
|
||||
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) => field.Slot switch
|
||||
/// A Mexican station sends a state, which goes in the section column; the
|
||||
/// serial everyone else sends stays in the exchange column.
|
||||
public Qso FromExchange1(Qso qso, string typed) => qso with
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && !IsMexican(their.Entity.PrimaryPrefix),
|
||||
ExchangeSlot.Exchange1 => their is not null && IsMexican(their.Entity.PrimaryPrefix),
|
||||
_ => false,
|
||||
Section = IsMexican(qso.CountryPrefix) ? typed.Trim().ToUpperInvariant() : "",
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Countries", "States"];
|
||||
|
||||
@@ -25,7 +25,7 @@ public sealed class NorthAmericanQsoParty : Contest
|
||||
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 },
|
||||
new ExchangeField("State", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 6 },
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Mults"];
|
||||
@@ -44,7 +44,7 @@ public sealed class NorthAmericanQsoParty : Contest
|
||||
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
|
||||
{
|
||||
string band = qso.Band?.Name ?? "";
|
||||
string exchange = qso.Qso.Exchange1.Trim().ToUpperInvariant();
|
||||
string exchange = qso.Qso.Section.Trim().ToUpperInvariant();
|
||||
if (StatesAndProvinces.IsStateOrProvince(exchange))
|
||||
{
|
||||
return [new Multiplier(1, exchange, band)];
|
||||
@@ -66,7 +66,7 @@ public sealed class NorthAmericanQsoParty : Contest
|
||||
[
|
||||
new CabrilloField(qso.Call.Text, 13),
|
||||
new CabrilloField(qso.Name, 10),
|
||||
new CabrilloField(qso.Exchange1, 6),
|
||||
new CabrilloField(qso.Section, 6),
|
||||
]);
|
||||
|
||||
private string ModeLabel() => mode switch
|
||||
|
||||
@@ -20,8 +20,10 @@ public sealed class OceaniaDx : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SntNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("RcvNR", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Prefixes"];
|
||||
|
||||
@@ -22,22 +22,30 @@ public sealed class OkOmDx : Contest
|
||||
|
||||
public string CabrilloName => "OK-OM-DX";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("County", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 4 },
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Number),
|
||||
];
|
||||
/// An OK or OM operator works everybody, so the one box takes a county or
|
||||
/// a serial number; everyone else works OK and OM stations alone and sends
|
||||
/// a serial number of their own.
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsOkOm(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 4 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SntNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 4 },
|
||||
];
|
||||
|
||||
/// An OK or OM station sends a county and no serial; everyone else the
|
||||
/// other way round, so one of the two boxes is stepped over.
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) =>
|
||||
field.Slot switch
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && !IsOkOm(their.Entity.PrimaryPrefix),
|
||||
ExchangeSlot.Exchange1 => their is not null && IsOkOm(their.Entity.PrimaryPrefix),
|
||||
_ => false,
|
||||
};
|
||||
/// A county goes in the section column as well, which is where the
|
||||
/// multiplier is read from; a serial number stays in the exchange column.
|
||||
public Qso FromExchange1(Qso qso, string typed) => qso with
|
||||
{
|
||||
Section = IsOkOm(qso.CountryPrefix) ? typed.Trim().ToUpperInvariant() : "",
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Mults"];
|
||||
|
||||
|
||||
@@ -13,11 +13,30 @@ public sealed class RttyRoundup : Contest
|
||||
|
||||
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 },
|
||||
];
|
||||
/// A North American station sends a state or province and no serial;
|
||||
/// everyone else sends a serial number, and N1MM shows the sent serial box
|
||||
/// only for them.
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => me.State.Length > 0
|
||||
?
|
||||
[
|
||||
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 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
|
||||
];
|
||||
|
||||
/// A number is a serial; anything else is a state or province, which goes
|
||||
/// in the section column as well.
|
||||
public Qso FromExchange1(Qso qso, string typed) =>
|
||||
int.TryParse(typed, out int number)
|
||||
? qso with { ReceivedNumber = number, Section = "" }
|
||||
: qso with { ReceivedNumber = 0, Section = typed.Trim().ToUpperInvariant() };
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Mults"];
|
||||
|
||||
|
||||
@@ -13,11 +13,27 @@ public sealed class RussianDistrictAward : Contest
|
||||
|
||||
public string CabrilloName => "RDAC";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("RDA", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 5 },
|
||||
];
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsRussian(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
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 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 5 },
|
||||
];
|
||||
|
||||
/// A district goes in the section column, where the multiplier is read
|
||||
/// from; everyone else sends a serial number.
|
||||
public Qso FromExchange1(Qso qso, string typed) =>
|
||||
IsRussian(qso.CountryPrefix)
|
||||
? qso with { Section = typed.Trim().ToUpperInvariant() }
|
||||
: qso with { ReceivedNumber = int.TryParse(typed, out int number) ? number : 0 };
|
||||
|
||||
/// N1MM names a country multiplier for this contest and never counts one,
|
||||
/// and the score summary shows both, so the districts stay in the second
|
||||
@@ -59,4 +75,7 @@ public sealed class RussianDistrictAward : Contest
|
||||
]);
|
||||
|
||||
private static string District(Qso qso) => qso.Section.Trim().ToUpperInvariant();
|
||||
|
||||
private static bool IsRussian(string countryPrefix) =>
|
||||
countryPrefix is "UA" or "UA2" or "UA9";
|
||||
}
|
||||
|
||||
@@ -15,11 +15,27 @@ public sealed class RussianDxRtty : Contest
|
||||
|
||||
public string CabrilloName => "RADIO-WW-RTTY";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Oblast/Zone", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 3 },
|
||||
];
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsRussian(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
];
|
||||
|
||||
/// A Russian station sends an oblast, which goes in the section column
|
||||
/// where the multiplier is read from; everyone else sends a CQ zone.
|
||||
public Qso FromExchange1(Qso qso, string typed) => qso with
|
||||
{
|
||||
Section = typed.Trim().ToUpperInvariant(),
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Countries", "Oblasts"];
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ public sealed class SartgRtty : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("SntNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("RcvNr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Countries", "Areas"];
|
||||
|
||||
@@ -17,12 +17,36 @@ public sealed class Sweepstakes : Contest
|
||||
|
||||
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("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
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("Sec", ExchangeSlot.Section, ExchangeFieldKind.ArrlSection),
|
||||
new ExchangeField("CK", ExchangeSlot.Check, ExchangeFieldKind.Check),
|
||||
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.ArrlSection),
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Sections"];
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
using Nonemm.Contests.Multipliers;
|
||||
|
||||
namespace Nonemm.Contests.Rules;
|
||||
|
||||
/// The four parts of a Sweepstakes exchange, read out of the one box the
|
||||
/// operator types them into: `72 A 74 SCV`, or `72A 74SCV`, or any other order.
|
||||
/// N1MM reads the same box the same way, from the last word back, so a part
|
||||
/// typed again replaces nothing that was already found.
|
||||
public sealed record SweepstakesExchange(int Number, string Precedence, int Check, string Section)
|
||||
{
|
||||
private const int HighestNumber = 10000;
|
||||
|
||||
private const int HighestCheck = 99;
|
||||
|
||||
private static readonly IReadOnlySet<string> Precedences =
|
||||
new HashSet<string> { "A", "B", "Q", "U", "M", "S" };
|
||||
|
||||
public static SweepstakesExchange Parse(string typed)
|
||||
{
|
||||
string rest = typed.Trim().ToUpperInvariant();
|
||||
string number = "";
|
||||
string check = "";
|
||||
string section = "";
|
||||
string precedence = "";
|
||||
bool foundSection = false;
|
||||
bool foundNumber = false;
|
||||
while (rest.Trim().Length > 0)
|
||||
{
|
||||
string word = LastWord(rest);
|
||||
rest = AllButLastWord(rest);
|
||||
string before = LastWord(rest);
|
||||
// "72 A" and "74 SCV" are one part typed with a space in it
|
||||
if ((word.Length == 1 && char.IsAsciiLetter(word[0]) && IsNumber(before))
|
||||
|| (word.Length is >= 2 and < 4 && word.All(char.IsAsciiLetter) && IsNumber(before)))
|
||||
{
|
||||
word = before + word;
|
||||
rest = AllButLastWord(rest);
|
||||
}
|
||||
if (word.Length > 1 && !IsNumber(word[^1..]) && IsNumber(word[..^1]))
|
||||
{
|
||||
if (!foundNumber)
|
||||
{
|
||||
number = word[..^1];
|
||||
foundNumber = true;
|
||||
}
|
||||
precedence = precedence.Length == 0 ? PrecedenceFrom(word[^1..]) : precedence;
|
||||
}
|
||||
else if (word.Length > 3 && !IsNumber(word) && IsNumber(word[..2]) && word[2..].All(char.IsAsciiLetter))
|
||||
{
|
||||
check = check.Length == 0 ? word[..2] : check;
|
||||
(section, foundSection) = SectionFrom(word[2..], section, foundSection);
|
||||
}
|
||||
else if (word.Length > 2 && !IsNumber(word) && IsNumber(word[..1]) && word[1..].All(char.IsAsciiLetter))
|
||||
{
|
||||
check = check.Length == 0 ? word[..1] : check;
|
||||
(section, foundSection) = SectionFrom(word[1..], section, foundSection);
|
||||
}
|
||||
else if (IsNumber(word) && ((word.Length == 1 && word != "0") || word.Length > 2))
|
||||
{
|
||||
number = foundNumber ? number : word;
|
||||
foundNumber = true;
|
||||
}
|
||||
else if (IsNumber(word) && check.Length > 0 && !foundNumber)
|
||||
{
|
||||
number = number.Length == 0 ? word : number;
|
||||
}
|
||||
else if (IsNumber(word))
|
||||
{
|
||||
check = check.Length == 0 ? word : check;
|
||||
}
|
||||
else if (word.Length > 1)
|
||||
{
|
||||
(section, foundSection) = SectionFrom(word, section, foundSection);
|
||||
}
|
||||
else if (precedence.Length == 0)
|
||||
{
|
||||
precedence = PrecedenceFrom(word);
|
||||
}
|
||||
}
|
||||
return new SweepstakesExchange(
|
||||
Math.Min(Value(number), HighestNumber),
|
||||
precedence,
|
||||
Math.Min(Value(check), HighestCheck),
|
||||
section);
|
||||
}
|
||||
|
||||
private static (string Section, bool Found) SectionFrom(string word, string section, bool found) =>
|
||||
found || !ArrlSections.IsSection(word) ? (section, found) : (word, true);
|
||||
|
||||
private static string PrecedenceFrom(string word) => Precedences.Contains(word) ? word : "";
|
||||
|
||||
private static string LastWord(string text)
|
||||
{
|
||||
string trimmed = text.Trim();
|
||||
int space = trimmed.LastIndexOf(' ');
|
||||
return space < 0 ? trimmed : trimmed[(space + 1)..];
|
||||
}
|
||||
|
||||
private static string AllButLastWord(string text)
|
||||
{
|
||||
string trimmed = text.Trim();
|
||||
int space = trimmed.LastIndexOf(' ');
|
||||
return space < 0 ? "" : trimmed[..space];
|
||||
}
|
||||
|
||||
private static bool IsNumber(string text) => text.Length > 0 && text.All(char.IsAsciiDigit);
|
||||
|
||||
private static int Value(string text) => int.TryParse(text, out int number) ? number : 0;
|
||||
}
|
||||
@@ -15,19 +15,35 @@ public sealed class UkrainianDx : Contest
|
||||
|
||||
public string CabrilloName => "UKRAINIAN-DX";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Oblast", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 3 },
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Number),
|
||||
];
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => IsUkrainian(me.CountryPrefix)
|
||||
?
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SntNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
];
|
||||
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) => field.Slot switch
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && !IsUkrainian(their.Entity.PrimaryPrefix),
|
||||
ExchangeSlot.Exchange1 => their is not null && IsUkrainian(their.Entity.PrimaryPrefix),
|
||||
_ => false,
|
||||
};
|
||||
/// A number is the serial everyone outside Ukraine sends; anything else is
|
||||
/// an oblast, which goes in the section column as well.
|
||||
public Qso FromExchange1(Qso qso, string typed) =>
|
||||
int.TryParse(typed, out int number)
|
||||
? qso with { ReceivedNumber = number, Section = "" }
|
||||
: qso with { ReceivedNumber = 0, Section = typed.Trim().ToUpperInvariant() };
|
||||
|
||||
/// N1MM's log for this contest keeps what the one box was sorted into in a
|
||||
/// column of its own beside the exchange.
|
||||
public IReadOnlyList<ExchangeField> LogFieldsFor(StationInfo me) =>
|
||||
[
|
||||
.. ExchangeFieldsFor(me),
|
||||
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 5 },
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Countries", "Oblasts"];
|
||||
|
||||
|
||||
@@ -49,7 +49,9 @@ public sealed class Wae : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("SentNR", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
];
|
||||
|
||||
|
||||
@@ -15,20 +15,36 @@ public sealed class YoDxHf : Contest
|
||||
|
||||
public string CabrilloName => "YO-DX-HF";
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("County", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 3 },
|
||||
new ExchangeField("Nr", ExchangeSlot.Exchange1, ExchangeFieldKind.Number),
|
||||
];
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => me.CountryPrefix == "YO"
|
||||
?
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
]
|
||||
:
|
||||
[
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Nr", ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Exch", ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 3 },
|
||||
];
|
||||
|
||||
public bool SkipsField(ExchangeField field, CountryLookup? their) => field.Slot switch
|
||||
/// A YO station sends a county, which goes in the section column where the
|
||||
/// multiplier is read from; everyone else sends a serial number.
|
||||
public Qso FromExchange1(Qso qso, string typed) => qso with
|
||||
{
|
||||
ExchangeSlot.Section => their is not null && their.Entity.PrimaryPrefix != "YO",
|
||||
ExchangeSlot.Exchange1 => their is not null && their.Entity.PrimaryPrefix == "YO",
|
||||
_ => false,
|
||||
Section = qso.CountryPrefix == "YO" ? typed.Trim().ToUpperInvariant() : "",
|
||||
};
|
||||
|
||||
/// N1MM's log for this contest keeps what the one box was sorted into in a
|
||||
/// column of its own beside the exchange.
|
||||
public IReadOnlyList<ExchangeField> LogFieldsFor(StationInfo me) =>
|
||||
[
|
||||
.. ExchangeFieldsFor(me),
|
||||
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.Text) { Width = 5 },
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames => ["Countries", "Counties"];
|
||||
|
||||
public DupeScope DupeScope => DupeScope.PerBandAndMode;
|
||||
|
||||
@@ -18,7 +18,8 @@ public sealed class Yota : Contest
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) =>
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Snt", ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
new ExchangeField("Rcv", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Age", ExchangeSlot.Exchange1, ExchangeFieldKind.Number) { Width = 3 },
|
||||
];
|
||||
|
||||
|
||||
@@ -281,10 +281,11 @@ public sealed class UserDefinedContest : Contest
|
||||
|
||||
/// The names are N1MM's `LogItem.LogItemNameType` members, which is what a
|
||||
/// published `.udc` file holds. `SectText` is not one of them but files in
|
||||
/// the wild use it. The sent-side boxes — `SNTText`, `SntNrText` — are not
|
||||
/// exchange boxes here and fall through.
|
||||
/// the wild use it.
|
||||
private static ExchangeField? BoxToField(string box, string label) => box.ToUpperInvariant() switch
|
||||
{
|
||||
"SNTTEXT" => new ExchangeField(label, ExchangeSlot.SentReport, ExchangeFieldKind.Report, IsRequired: false),
|
||||
"SNTNRTEXT" => new ExchangeField(label, ExchangeSlot.SentNumber, ExchangeFieldKind.Number, IsRequired: false),
|
||||
"RCVTEXT" => new ExchangeField(label, ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
"RCVNRTEXT" => new ExchangeField(label, ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
"EXCHANGE1TEXT" => new ExchangeField(label, ExchangeSlot.Exchange1, ExchangeFieldKind.Text) { Width = 6 },
|
||||
|
||||
Reference in New Issue
Block a user