using Nonemm.Contests.Multipliers; using Nonemm.Core; namespace Nonemm.Contests.Rules; /// ARRL RTTY Roundup. One point a contact; states, provinces and DXCC entities /// each count once for the whole contest. public sealed class RttyRoundup : Contest { public string Name => "ARRLRTTY"; public string DisplayName => "ARRL RTTY Roundup"; public string CabrilloName => "ARRL-RTTY"; /// 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 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 MultiplierNames => ["Mults"]; public DupeScope DupeScope => DupeScope.PerBand; public bool HasSerialNumbers => true; public IReadOnlyList Modes => [ModeCategory.Digital]; public string SentExchangeFor(StationInfo me) => me.State.Length > 0 ? me.State : "001"; public int PointsFor(QsoContext qso) => 1; /// A North American station sends a state or province and counts as that; /// everyone else counts as their DXCC entity. public IReadOnlyList MultipliersFor(QsoContext qso) { string exchange = qso.Qso.Exchange1.Trim().ToUpperInvariant(); if (StatesAndProvinces.IsStateOrProvince(exchange)) { return [new Multiplier(1, exchange, "")]; } return qso.CountryPrefix.Length == 0 ? [] : [new Multiplier(1, qso.CountryPrefix, "")]; } 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(me.State.Length > 0 ? me.State : $"{qso.SentNumber}", 6), ], [ new CabrilloField(qso.Call.Text, 13), new CabrilloField(qso.ReceivedReport, 3), new CabrilloField(qso.Exchange1, 6), ]); }