Read the .udc CallHist multiplier and BonusPoints2
MultSqlString = CallHist counts every station the call history file lists, once per callsign, which is how N1MM dedups it. The file reaches the scoring code through ContestLog.History, and a QsoContext now carries it; without a file loaded nothing counts. BonusPoints2 = +50, calls.txt reads the callsigns from the support-files folder and adds 50 to the contact, *2 doubles it and a plain 50 scores 50 instead. The folder comes from the registry, which the app passes when it reads the .udc files. N1MM's other form, where the file is grids.txt and the bonus is looked up by grid square, is not read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Nonemm.Contests.Udc;
|
||||
using Nonemm.Core.Calls;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests.Tests;
|
||||
@@ -291,6 +292,67 @@ public class UdcScoringTests
|
||||
.Judge(TestLog.Contact("OM3XYZ", section: section))
|
||||
.NewMultipliers.Count);
|
||||
|
||||
/// `BonusPoints2` names how much a station on a list is worth and the file
|
||||
/// the list is in. `+50` adds to what the contact scored.
|
||||
[Theory]
|
||||
[InlineData("+50, bonus.txt", 53)]
|
||||
[InlineData("*2, bonus.txt", 6)]
|
||||
[InlineData("50, bonus.txt", 50)]
|
||||
public void BonusPoints2PaysForTheCallsignsInAFile(string setting, int expected)
|
||||
{
|
||||
string folder = Directory.CreateTempSubdirectory().FullName;
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Path.Combine(folder, "bonus.txt"), "OM3XYZ,a club station\nOM5ZZZ,\n");
|
||||
UserDefinedContest contest = new(
|
||||
UdcFile.Parse($"[Contest]\nName=BONUS\nPointsPerContact=3\nBonusPoints2={setting}"),
|
||||
folder);
|
||||
|
||||
Assert.Equal(expected, Points(contest, TestLog.Contact("OM3XYZ")));
|
||||
Assert.Equal(3, Points(contest, TestLog.Contact("IK2XYZ")));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(folder, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// A file that is not there leaves the bonus off and the contest opens.
|
||||
[Fact]
|
||||
public void BonusPoints2WithoutItsFileScoresTheContactAsItIs() =>
|
||||
Assert.Equal(
|
||||
3,
|
||||
Points(
|
||||
new UserDefinedContest(
|
||||
UdcFile.Parse("[Contest]\nName=BONUS\nPointsPerContact=3\nBonusPoints2=+50, missing.txt"),
|
||||
Path.Combine(Path.GetTempPath(), "nonemm-no-such-folder")),
|
||||
TestLog.Contact("OM3XYZ")));
|
||||
|
||||
/// `MultSqlString = CallHist` counts every station the call history file
|
||||
/// lists, once per callsign. A station the file says nothing about brings
|
||||
/// no multiplier.
|
||||
[Fact]
|
||||
public void CallHistCountsTheStationsTheFileLists()
|
||||
{
|
||||
UserDefinedContest contest = Contest("MultSqlString=CallHist", "IsMultPer=4");
|
||||
ContestLog log = LogFor(contest);
|
||||
log.History = CallHistory.Parse("OM3XYZ,JOE\nOM5ZZZ,SAM\n");
|
||||
|
||||
Assert.Equal(
|
||||
"OM3XYZ",
|
||||
log.Judge(TestLog.Contact("OM3XYZ")).NewMultipliers.Single().Value);
|
||||
Assert.Empty(log.Judge(TestLog.Contact("IK2XYZ")).NewMultipliers);
|
||||
}
|
||||
|
||||
/// Without a call history file loaded, a `CallHist` multiplier counts
|
||||
/// nothing rather than counting everybody.
|
||||
[Fact]
|
||||
public void CallHistCountsNothingWithoutAFile() =>
|
||||
Assert.Empty(
|
||||
LogFor(Contest("MultSqlString=CallHist", "IsMultPer=4"))
|
||||
.Judge(TestLog.Contact("OM3XYZ"))
|
||||
.NewMultipliers);
|
||||
|
||||
/// Published files hold `Country` in this key; the UDC editor puts
|
||||
/// `CountryPrefix` there.
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user