Files
Nonemm/src/Nonemm.Contests/Rules/YoDxHf.cs
T
erikbrockoandClaude Opus 5 a15bc8a6a2 Keep an excluded contact out of the score the way N1MM does
Three things were wrong with a contact the operator takes out of the claimed
score. The decompiled reference gives the rule in four places:

- `Contest.cs:437` returns zero points when `IsClaimedQso` is 0.
- `ContestInstance.cs:307` builds the where clause `CLAIMEDQSO = 1`, which the
  dupe search (`DBSupport.cs:1189`) and the multiplier search
  (`DBSupport.cs:1327`) both use, so an unclaimed contact takes nothing away
  from a later one.
- The score query (`DBSupport.cs:1807`) adds `ContactType <> 'D'`, which the
  other two do not. A contact marked as a dupe is therefore still searched for
  dupes and multipliers, and is left out of the score alone.
- `Contact.cs:1563`, `3307` and `3881` write `X-QSO:` rather than dropping the
  contact from the Cabrillo file.

`ContestLog` scored an unclaimed contact in full, and the Cabrillo writer left
it out of the file. `Qso.IsInScore` now holds the score rule and
`StatisticsPivot` uses it instead of its own copy.

The same reference also fixes the sent serial in three Cabrillo exporters.
ARRL 10M, Ukrainian DX and YO DX HF formatted the sent exchange from the
station rather than the contact, so a DX entrant exported `001` on every line.
N1MM reads the contact's own number: `CArrl10m.cs:122` writes it unpadded,
`CUkrainian.cs:232` and `CYOHFDX.cs:167` pad it to three digits.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
2026-09-09 20:12:51 +00:00

106 lines
4.1 KiB
C#

using Nonemm.Core;
using Nonemm.Core.Country;
namespace Nonemm.Contests.Rules;
/// The Romanian YO DX HF contest. A Romanian station sends its county and is
/// worth 8 points; everyone else is 1 point inside your own country, 2 on your
/// continent and 4 from another. The countries and the Romanian counties are
/// multipliers, each once per band.
public sealed class YoDxHf : Contest
{
public string Name => "YOHFDX";
public string DisplayName => "YO DX HF";
public string CabrilloName => "YO-DX-HF";
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 },
];
/// 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
{
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;
public bool HasSerialNumbers => true;
public IReadOnlyList<ModeCategory> Modes => [ModeCategory.Cw, ModeCategory.Phone];
public string SentExchangeFor(StationInfo me) => me.CountryPrefix == "YO" ? me.County : "001";
/// What went out on this contact. A YO station sends the same county
/// every time; everyone else sends a serial, so the Cabrillo file reads the
/// contact's own number and not the first one. N1MM pads it to three
/// digits.
private string SentExchangeOn(Qso qso, StationInfo me) =>
me.CountryPrefix == "YO" ? me.County : $"{qso.SentNumber:000}";
public int PointsFor(QsoContext qso)
{
if (qso.CountryPrefix == "YO")
{
return 8;
}
return qso.IsSameCountry ? 1 : qso.IsSameContinent ? 2 : 4;
}
public IReadOnlyList<Multiplier> MultipliersFor(QsoContext qso)
{
string band = qso.Band?.Name ?? "";
List<Multiplier> found = [];
if (qso.CountryPrefix.Length > 0)
{
found.Add(new Multiplier(1, qso.CountryPrefix, band));
}
string county = qso.Qso.Section.Trim().ToUpperInvariant();
if (qso.CountryPrefix == "YO" && county.Length > 0)
{
found.Add(new Multiplier(2, county, 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(SentExchangeOn(qso, me), 6),
],
[
new CabrilloField(qso.Call.Text, 13),
new CabrilloField(qso.ReceivedReport, 3),
new CabrilloField(qso.Section.Length > 0 ? qso.Section : qso.Exchange1, 6),
]);
}