Lay out a Cabrillo line the way a .udc file asks for it
`CabrilloString` names a field and a column width in turn. The line it makes follows N1MM: the operator's callsign in the first 13 columns, then every column padded to its width with one space after it, and a value longer than its column cut rather than pushed sideways. The cut is new for every contest, not just the user-defined ones — the columns are the sponsor's, not ours. `CabrilloVersion` is read too, so a contest whose sponsor still asks for 2.0 gets it in the header. A contest that lays out its own line can put the transmitter column where it wants it, or leave it out, so the writer no longer adds one at the end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
@@ -14,6 +14,7 @@ public sealed class UserDefinedContest : Contest
|
||||
private readonly IReadOnlyList<UdcMultiplier> multipliers;
|
||||
private readonly IReadOnlyList<ExchangeField> exchangeFields;
|
||||
private readonly IReadOnlyList<string> workableStations;
|
||||
private readonly UdcCabrillo cabrillo;
|
||||
|
||||
public UserDefinedContest(UdcFile file)
|
||||
{
|
||||
@@ -24,6 +25,7 @@ public sealed class UserDefinedContest : Contest
|
||||
multipliers = ReadMultipliers(file);
|
||||
exchangeFields = ReadExchangeFields(file);
|
||||
workableStations = file.List("IsWorkable");
|
||||
cabrillo = new UdcCabrillo(file.Text("CabrilloString"));
|
||||
}
|
||||
|
||||
public static UserDefinedContest Load(string path) =>
|
||||
@@ -35,6 +37,8 @@ public sealed class UserDefinedContest : Contest
|
||||
|
||||
public string CabrilloName => file.Text("CabrilloName", Name);
|
||||
|
||||
public string CabrilloVersion => file.Text("CabrilloVersion", "3.0");
|
||||
|
||||
public IReadOnlyList<ExchangeField> ExchangeFieldsFor(StationInfo me) => exchangeFields;
|
||||
|
||||
public IReadOnlyList<string> MultiplierNames =>
|
||||
@@ -115,18 +119,26 @@ public sealed class UserDefinedContest : Contest
|
||||
return (int)Math.Round(total * pointsMultiplier.ForEntry(entry));
|
||||
}
|
||||
|
||||
/// `CabrilloString` lays out the whole line, which is how a contest whose
|
||||
/// sponsor asks for its own columns is written. Without it the line is the
|
||||
/// usual one: each station, its report and its exchange.
|
||||
public CabrilloExchange CabrilloExchange(Qso qso, StationInfo me, ContestEntry entry) =>
|
||||
new(
|
||||
[
|
||||
new CabrilloField(me.Callsign, 13),
|
||||
new CabrilloField(qso.SentReport, 3),
|
||||
new CabrilloField(SentExchangePart(qso), 6),
|
||||
],
|
||||
[
|
||||
new CabrilloField(qso.Call.Text, 13),
|
||||
new CabrilloField(qso.ReceivedReport, 3),
|
||||
new CabrilloField(ReceivedExchangePart(qso), 6),
|
||||
]);
|
||||
cabrillo.IsDefined
|
||||
? new CabrilloExchange(cabrillo.Fields(qso, me, entry), [])
|
||||
{
|
||||
AddsTransmitter = cabrillo.HasTransmitter,
|
||||
}
|
||||
: new CabrilloExchange(
|
||||
[
|
||||
new CabrilloField(me.Callsign, 13),
|
||||
new CabrilloField(qso.SentReport, 3),
|
||||
new CabrilloField(SentExchangePart(qso), 6),
|
||||
],
|
||||
[
|
||||
new CabrilloField(qso.Call.Text, 13),
|
||||
new CabrilloField(qso.ReceivedReport, 3),
|
||||
new CabrilloField(ReceivedExchangePart(qso), 6),
|
||||
]);
|
||||
|
||||
/// `IsWorkable` names the stations the contest counts: a continent, my own
|
||||
/// country, everything but my own country, or a list of country prefixes. A
|
||||
|
||||
Reference in New Issue
Block a user