using Nonemm.Core; namespace Nonemm.Contests.Rules; /// RSGB Islands On The Air. A station on an island sends its IOTA reference /// after the serial number and is worth 15 points; everyone else is worth 2. /// Each reference counts once per band and mode. /// /// The operator's own island is not held anywhere, so the contest cannot yet /// score a contact with a station on the same island, which N1MM counts as 5 /// points. public sealed class Iota : Contest { public string Name => "IOTA"; public string DisplayName => "RSGB Islands On The Air"; public string CabrilloName => "RSGB-IOTA"; public IReadOnlyList ExchangeFieldsFor(StationInfo me) => [ 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) { Width = 6, }, ]; public IReadOnlyList MultiplierNamesFor(StationInfo me) => ["Islands"]; public DupeScope DupeScope => DupeScope.PerBandAndMode; public bool HasSerialNumbers => true; public IReadOnlyList Modes => [ModeCategory.Cw, ModeCategory.Phone]; public string SentExchangeFor(StationInfo me) => "001"; public int PointsFor(QsoContext qso) => Reference(qso.Qso).Length > 0 ? 15 : 2; public IReadOnlyList MultipliersFor(QsoContext qso) { string reference = Reference(qso.Qso); return reference.Length == 0 ? [] : [new Multiplier(1, reference, $"{qso.Band?.Name}|{qso.ModeCategory}")]; } 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($"{qso.SentNumber:000}", 4), new CabrilloField(entry.SentExchange, 6), ], [ new CabrilloField(qso.Call.Text, 13), new CabrilloField(qso.ReceivedReport, 3), new CabrilloField($"{qso.ReceivedNumber:000}", 4), new CabrilloField(Reference(qso), 6), ]); private static string Reference(Qso qso) => qso.Section.Trim().ToUpperInvariant(); }