using Nonemm.Core; namespace Nonemm.Contests.Rules; /// The YOTA contest. The exchange is the operator's age, a contact with a /// young operator is worth more, and every age worked on a band is a /// multiplier. /// /// N1MM has no class for this one — it is logged there through a `.udc` file, /// which is why the contest name is plain `YOTA`. public sealed class Yota : Contest { public string Name => "YOTA"; public string DisplayName => "YOTA Contest"; public string CabrilloName => "YOTA"; public IReadOnlyList ExchangeFieldsFor(StationInfo me) => [ 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 }, ]; public IReadOnlyList MultiplierNamesFor(StationInfo me) => ["Ages"]; public DupeScope DupeScope => DupeScope.PerBandAndMode; public bool HasSerialNumbers => false; public IReadOnlyList Modes => [ModeCategory.Cw, ModeCategory.Phone]; /// The operator's own age, which the contest setup asks for. public string SentExchangeFor(StationInfo me) => ""; /// A contact with an operator of 25 or under is worth 10 to 13 points by /// age, whatever the continent. Everyone else is worth 1 point on your own /// continent and 3 from another. public int PointsFor(QsoContext qso) => Age(qso) switch { null or > 25 => qso.IsSameContinent ? 1 : 3, <= 12 => 13, <= 16 => 12, <= 21 => 11, _ => 10, }; /// Each age worked on a band, whatever the mode. public IReadOnlyList MultipliersFor(QsoContext qso) => Age(qso) is { } age ? [new Multiplier(1, age.ToString(), qso.Band?.Name ?? "")] : []; 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, 3), ], [ new CabrilloField(qso.Call.Text, 13), new CabrilloField(qso.ReceivedReport, 3), new CabrilloField(qso.Exchange1, 3), ]); private static int? Age(QsoContext qso) => int.TryParse(qso.Qso.Exchange1.Trim(), out int age) && age > 0 ? age : null; }