using Nonemm.Core; using Nonemm.Core.Country; namespace Nonemm.Contests.Rules; /// The Ukrainian DX contest. A Ukrainian station sends its oblast, everyone /// else a serial number, and a contact with Ukraine is worth 10 points to a /// station outside it. The multipliers are the countries and the oblasts, each /// once per band. public sealed class UkrainianDx : Contest { public string Name => "UKRAINDX"; public string DisplayName => "Ukrainian DX"; public string CabrilloName => "UKRAINIAN-DX"; public IReadOnlyList 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 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, }; public IReadOnlyList MultiplierNames => ["Countries", "Oblasts"]; public DupeScope DupeScope => DupeScope.PerBandAndMode; public bool HasSerialNumbers => true; public IReadOnlyList Modes => [ModeCategory.Cw, ModeCategory.Phone]; public string SentExchangeFor(StationInfo me) => IsUkrainian(me.CountryPrefix) ? me.County : "001"; public int PointsFor(QsoContext qso) { if (IsUkrainian(qso.CountryPrefix)) { return IsUkrainian(qso.Me.CountryPrefix) ? 1 : 10; } if (qso.IsSameCountry) { return 1; } return qso.IsSameContinent ? 2 : 3; } public IReadOnlyList MultipliersFor(QsoContext qso) { string band = qso.Band?.Name ?? ""; List found = []; if (qso.CountryPrefix.Length > 0) { found.Add(new Multiplier(1, qso.CountryPrefix, band)); } string oblast = qso.Qso.Section.Trim().ToUpperInvariant(); if (IsUkrainian(qso.CountryPrefix) && oblast.Length > 0) { found.Add(new Multiplier(2, oblast, 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(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 IsUkrainian(string countryPrefix) => countryPrefix == "UR"; }