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
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using Nonemm.Contests.Rules;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests.Tests;
|
||||
|
||||
/// What N1MM does with a contact the operator has taken out of the claimed
|
||||
/// score, and with one a log N1MM wrote has marked as a dupe. The two are not
|
||||
/// the same: an unclaimed contact is left out of the score and out of both the
|
||||
/// dupe search and the multiplier search, while a contact marked `D` still
|
||||
/// takes a dupe and a multiplier away from a later contact.
|
||||
public class ExcludedContactTests
|
||||
{
|
||||
private static ContestLog LogFor() =>
|
||||
new(new CqWorldWide(ModeCategory.Cw), TestLog.Germany, TestLog.CountryFile);
|
||||
|
||||
private static Qso Japan(string call = "JA1XYZ", DateTime? at = null) =>
|
||||
TestLog.Contact(call, zone: 25, at: at);
|
||||
|
||||
private static readonly DateTime Later = new(2026, 5, 30, 13, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
[Fact]
|
||||
public void AnUnclaimedContactScoresNothing()
|
||||
{
|
||||
ContestLog log = LogFor();
|
||||
log.Add(Japan() with { IsClaimed = false });
|
||||
Assert.Equal(0, log.Tally.Qsos);
|
||||
Assert.Equal(0, log.Tally.Points);
|
||||
Assert.Equal(0, log.Tally.TotalMultipliers);
|
||||
Assert.Equal(0, log.TotalScore);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnUnclaimedContactDoesNotDupeALaterOne()
|
||||
{
|
||||
ContestLog log = LogFor();
|
||||
log.Add(Japan() with { IsClaimed = false });
|
||||
Assert.False(log.IsWorked(Japan(at: Later)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnUnclaimedContactLeavesItsMultipliersForALaterOne()
|
||||
{
|
||||
ContestLog log = LogFor();
|
||||
log.Add(Japan() with { IsClaimed = false });
|
||||
Verdict later = log.Judge(Japan("JH1ABC", Later));
|
||||
Assert.Equal([1, 2], later.NewMultipliers.Select(m => m.Index).ToList());
|
||||
}
|
||||
|
||||
/// N1MM searches for dupes and multipliers among the claimed contacts
|
||||
/// whether or not they are marked as a dupe, so the second contact here
|
||||
/// gets no multiplier and the multiplier is lost from the score.
|
||||
[Fact]
|
||||
public void AContactMarkedAsADupeTakesItsMultipliersOutOfTheScore()
|
||||
{
|
||||
ContestLog log = LogFor();
|
||||
log.Add(Japan() with { ContactType = "D" });
|
||||
Assert.Equal(0, log.Tally.Qsos);
|
||||
Assert.Equal(0, log.Tally.TotalMultipliers);
|
||||
Assert.Empty(log.Judge(Japan("JH1ABC", Later)).NewMultipliers);
|
||||
Assert.True(log.IsWorked(Japan(at: Later)));
|
||||
}
|
||||
}
|
||||
@@ -73,14 +73,36 @@ public class CabrilloWriterTests
|
||||
Assert.EndsWith("END-OF-LOG:\r\n", log);
|
||||
}
|
||||
|
||||
/// N1MM writes a contact the operator left out of the claimed score under
|
||||
/// `X-QSO:`, which the sponsors read as a contact the entrant is not
|
||||
/// claiming. It is not dropped from the file.
|
||||
[Fact]
|
||||
public void ContactsLeftOutOfTheClaimedScoreAreNotSent()
|
||||
public void ContactsLeftOutOfTheClaimedScoreAreSentAsXQso()
|
||||
{
|
||||
CabrilloWriter writer = new(new CqWorldWide(ModeCategory.Cw), Me);
|
||||
string log = writer.Write(
|
||||
new CabrilloHeader { Contest = "CQ-WW-CW", Callsign = "DL1ABC" },
|
||||
[Contact() with { IsClaimed = false }]);
|
||||
Assert.DoesNotContain("QSO:", log);
|
||||
Assert.Contains("\r\nX-QSO: ", log);
|
||||
Assert.DoesNotContain("\r\nQSO: ", log);
|
||||
}
|
||||
|
||||
/// The three contests where a DX entrant sends a serial. N1MM writes the
|
||||
/// serial of that contact, so a log cannot come out with `001` on every
|
||||
/// line. ARRL 10M sends it unpadded, the other two pad it to three digits.
|
||||
[Fact]
|
||||
public void ADxEntrantSendsTheSerialOfTheContact()
|
||||
{
|
||||
Qso qso = Contact(28_025) with { SentNumber = 42 };
|
||||
Assert.Contains(
|
||||
"599 42 JA1XYZ",
|
||||
new CabrilloWriter(new Arrl10Metre(), Me).QsoLine(qso));
|
||||
Assert.Contains(
|
||||
"599 042 JA1XYZ",
|
||||
new CabrilloWriter(new UkrainianDx(), Me).QsoLine(qso));
|
||||
Assert.Contains(
|
||||
"599 042 JA1XYZ",
|
||||
new CabrilloWriter(new YoDxHf(), Me).QsoLine(qso));
|
||||
}
|
||||
|
||||
/// The SA 10 file, whose sponsor asks for its own columns: the operator's
|
||||
|
||||
Reference in New Issue
Block a user