Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer showing "Scramble Set A" if there is only one scramble set/group #578

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.util.*

data class CompetitionDrawingData(val competitionTitle: String, val scrambleSheets: List<ScrambleDrawingData>)

data class ScrambleDrawingData(val scrambleSet: ScrambleSet, val activityCode: ActivityCode, val watermark: String? = null) {
data class ScrambleDrawingData(val scrambleSet: ScrambleSet, val activityCode: ActivityCode, val watermark: String? = null, val hasGroupID: Boolean = true) {
val isFmc: Boolean
get() = scrambleSet.findExtension<FmcExtension>()
?.isFmc ?: (activityCode.eventModel == EventData.THREE_FM)
Expand Down Expand Up @@ -59,7 +59,7 @@ data class ScrambleDrawingData(val scrambleSet: ScrambleSet, val activityCode: A
}

val genericSheet = GeneralScrambleSheet(scrambleSet, activityCode) // encrypt when watermarking
return WatermarkPdfWrapper(genericSheet, activityCode.compileTitleString(), creationDate, versionTag, sheetTitle, watermark)
return WatermarkPdfWrapper(genericSheet, activityCode.compileTitleString(includeGroupID = hasGroupID), creationDate, versionTag, sheetTitle, watermark)
}

fun copyForAttempt(attempt: Int): ScrambleDrawingData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object WCIFDataBuilder {
val frontendStatus = findExtension<TNoodleStatusExtension>()
val frontendWatermark = frontendStatus?.pickWatermarkPhrase()

ScrambleDrawingData(extendedScrSet, copyCode, frontendWatermark)
ScrambleDrawingData(extendedScrSet, copyCode, frontendWatermark, r.scrambleSetCount > 1)
}
}
}
Expand All @@ -63,7 +63,7 @@ object WCIFDataBuilder {
val drawingData = wcif.toScrambleSetData()

val namedSheets = drawingData.scrambleSheets
.withUniqueTitles { it.activityCode.compileTitleString() }
.withUniqueTitles { it.activityCode.compileTitleString(includeGroupID = it.hasGroupID) }

val zippingData = CompetitionZippingData(wcif, namedSheets)
return requestsToZip(zippingData, pdfPassword, generationDate, versionTag, generationUrl)
Expand All @@ -87,7 +87,7 @@ object WCIFDataBuilder {
}

val configurations = scrambleRequests.map {
Triple(it.activityCode.compileTitleString(false), it.activityCode.eventModel?.description.orEmpty(), it.numCopies)
Triple(it.activityCode.compileTitleString(false, includeGroupID = it.hasGroupID), it.activityCode.eventModel?.description.orEmpty(), it.numCopies)
}

return MergedPdfWithOutline(originalPdfs, configurations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ data class ActivityCode(val activityCodeString: String) : EventIdProvider {
return compile(eventId, roundNumber, groupNumber, attemptNumber)
}

fun compileTitleString(includeEvent: Boolean = true): String {
fun compileTitleString(includeEvent: Boolean = true, includeGroupID: Boolean = false): String {
val parts = structureParts.map { (k, v) ->
val translatePrefix = PREFIX_TRANSLATIONS[k]
val translateValue = v.takeUnless { k == WCIF_PREFIX_GROUP }
?: v.toIntOrNull()?.toColumnIndexString()

"$translatePrefix $translateValue"
"$translatePrefix $translateValue".takeUnless { !includeGroupID && k == WCIF_PREFIX_GROUP }.orEmpty()
}.joinToString(TRANSLATION_DELIMITER)

if (!includeEvent) {
Expand Down