Documentation
¶
Overview ¶
Package-level note: excel.go implements the page-layout algorithm that writes pool match and elimination match data into an Excel workbook.
Layout model:
"Pool Matches" sheet: courts are placed side-by-side (8 columns each). Pools are rendered top-to-bottom within each court column. A soft page-break is inserted whenever the next pool block would overflow PoolMatchesRowsPerPage rows. Vertical page breaks separate courts so the sheet prints as distinct pages.
"Elimination Matches" section: elimination rounds are laid out top-to-bottom with all courts side-by-side. A new page break is inserted when the next match block would overflow EliminationRowsPerPage.
Tree sheets ("Tree 1", "Tree 2", …): one sheet per bracket segment. Leaf values reference pool-match winner cells via CONCATENATE formulas so the bracket updates automatically when scores are entered.
Row-count thresholds and layout constants are defined in constants.go.
Index ¶
- Constants
- Variables
- func AddPlayerDataToSheet(f *excelize.File, players []Player, sanitize bool, titlePrefix string)
- func AddPoolDataToSheet(f *excelize.File, pools []Pool, sanitize bool, titlePrefix string)
- func AddPoolsToSheet(f *excelize.File, pools []Pool) error
- func AddPoolsToTree(f *excelize.File, sheetName string, pools []Pool)
- func ApplySeeds(players []Player, assignments []domain.SeedAssignment) error
- func AssignPoolsToCourts(numPools, numCourts int) ([]int, error)
- func CalculateDepth(node *Node) int
- func CheckDuplicateEntries(input []string) []string
- func ConvertPlayersToWinners(players []Player, sanitized bool) map[string]MatchWinner
- func CreateNamesToPrint(f *excelize.File, players []Player, sanitized bool)
- func CreateNamesWithPoolToPrint(f *excelize.File, pools []Pool, sanitized bool)
- func CreatePoolMatches(pools []Pool)
- func CreatePoolRoundRobinMatches(pools []Pool)
- func CreateTagsSheet(f *excelize.File, pools []Pool) error
- func CreateTreeBracket(f *excelize.File, sheet string, col int, startRow int, size int) string
- func FillEstimations(f *excelize.File, numPools int64, totalPoolMatches int64, teamSize int64, ...)
- func FillInMatches(f *excelize.File, eliminationMatchRounds [][]*Node)
- func GenerateFinals(pools []Pool, poolWinners int) []string
- func GetBorderStyleBottomLeft(f *excelize.File) int
- func GetBorderStyleLeft(f *excelize.File) int
- func MatchHeader(f *excelize.File, sheetName string, startColName string, poolRow int, ...)
- func NextPow2(n int) int
- func ParseSeedsFile(filePath string) ([]domain.SeedAssignment, error)
- func PrintLeafNodes(node *Node, f *excelize.File, sheetName string, startCol int, startRow int, ...)
- func PrintPoolMatches(f *excelize.File, pools []Pool, teamMatches int, numWinners int, numCourts int, ...) map[string]MatchWinner
- func PrintTeamEliminationMatches(f *excelize.File, poolMatchWinners map[string]MatchWinner, ...)
- func ReadEntriesFromFile(filePath string) ([]string, error)
- func RemoveDuplicates(input []string) []string
- func RoundToPowerOf2(x, y float64) (int, error)
- func SetSheetLayoutLandscapeA3(f *excelize.File, sheetName string)
- func SetSheetLayoutPortraitA4(f *excelize.File, sheetName string)
- func SetSheetLayoutPortraitA4Centered(f *excelize.File, sheetName string)
- func SetSheetLayoutPortraitA4DownThenOver(f *excelize.File, sheetName string, numCourts int)
- func SetTreeSheetTitle(f *excelize.File, sheetName string, title string)
- func ValidateCourts(n int) error
- type Match
- type MatchWinner
- type Node
- type Player
- type Pool
- type RowStack
- type Stack
Constants ¶
const ( // PoolMatchesRowsPerPage is the soft row budget before inserting a page // break on the Pool Matches sheet. PoolMatchesRowsPerPage = 45 // PoolSpaceLines is the number of blank rows added after the pool header // before the first match block. PoolSpaceLines = 3 // PoolDrawRowsPerPage is the soft row budget before inserting a page // break on the Pool Draw sheet. PoolDrawRowsPerPage = 42 )
Pool match sheet layout constants.
const ( // EliminationRowsPerPage is the soft row budget before inserting a page // break in the elimination-match section. EliminationRowsPerPage = 44 // EliminationSpaceLines is the number of blank rows printed between // elimination match rounds. EliminationSpaceLines = 5 // EliminationMatchHeight is the row-height of a single individual // elimination match block. EliminationMatchHeight = 8 // EliminationTeamMatchHeightBase is added to the team-match count to get // the row-height of a team elimination match block. EliminationTeamMatchHeightBase = 11 )
Elimination match layout constants.
const ( DefaultPort = 8080 DefaultWinners = 2 DefaultPoolSize = 3 DefaultCourts = 2 )
Default flag values used by CLI commands and the web handler.
const ( SheetData = "data" SheetTimeEstimator = "Time Estimator" SheetPoolDraw = "Pool Draw" SheetPoolMatches = "Pool Matches" SheetEliminationMatches = "Elimination Matches" SheetNamesToPrint = "Names to Print" SheetTags = "Tags" SheetTree = "Tree" )
Sheet names for every tab in the workbook. Use these constants wherever a sheet name is needed so that a rename only requires one edit here.
const MaxCourts = 26
MaxCourts is the upper bound for the number of Shiaijo (courts). It comes from the single-letter A–Z labelling used on Shiaijo headers throughout the workbook; values above this are rejected up front by ValidateCourts so we never silently truncate a user-requested layout.
const MaxPlayersPerTree = 16
MaxPlayersPerTree is the maximum leaf count on a single tree sheet. 16 players form a balanced bracket that fits on one A4 landscape page.
const TreeTitleRows = 3
TreeTitleRows is the number of rows reserved at the top of every tree sheet for the user to add a title. Content starts below this offset.
Variables ¶
var WebFs embed.FS
Functions ¶
func AddPlayerDataToSheet ¶ added in v0.3.0
func AddPoolDataToSheet ¶ added in v0.3.0
func ApplySeeds ¶ added in v0.11.0
func ApplySeeds(players []Player, assignments []domain.SeedAssignment) error
ApplySeeds assigns seeds to the helper players, handling swaps if needed Returns an error if an assigned name could not be matched
func AssignPoolsToCourts ¶ added in v0.14.0
AssignPoolsToCourts distributes numPools pools across numCourts courts using contiguous blocks that match the tree sheet grouping. The first court gets ceil(numPools/numCourts) pools, subsequent courts get the remainder. Returns an error when numCourts exceeds numPools.
func CalculateDepth ¶
func CheckDuplicateEntries ¶ added in v0.14.0
CheckDuplicateEntries scans the raw entry list (one CSV row per element) for duplicates and returns a list of entries that appear more than once. Empty strings are ignored. The returned slice preserves first-seen order of the offending entries; an empty result means the list is unique.
func ConvertPlayersToWinners ¶ added in v0.3.0
func ConvertPlayersToWinners(players []Player, sanitized bool) map[string]MatchWinner
func CreateNamesToPrint ¶
func CreateNamesWithPoolToPrint ¶ added in v0.3.0
func CreatePoolMatches ¶
func CreatePoolMatches(pools []Pool)
func CreatePoolRoundRobinMatches ¶
func CreatePoolRoundRobinMatches(pools []Pool)
func CreateTreeBracket ¶
func FillEstimations ¶ added in v0.6.0
func FillInMatches ¶
func GenerateFinals ¶
GenerateFinals interleaves pool finalists so that when CreateBalancedTree distributes them into bracket slots, the first-place finisher of one pool is paired against the second-place finisher of another pool.
The algorithm cycles through all pools, advancing a round counter every time a full set of pools has been placed. The position rank for each slot is computed as (i + round) % poolWinners, which shifts the rank picked for successive pools so that adjacent bracket slots always contain different finishing positions.
Example with 4 pools and 2 winners per pool:
result = [Pool_A-1st, Pool_B-2nd, Pool_C-1st, Pool_D-2nd,
Pool_A-2nd, Pool_B-1st, Pool_C-2nd, Pool_D-1st]
func GetBorderStyleLeft ¶
func MatchHeader ¶
func NextPow2 ¶ added in v0.14.0
NextPow2 returns the smallest power of 2 that is >= n. Returns 1 for n <= 1.
func ParseSeedsFile ¶ added in v0.11.0
func ParseSeedsFile(filePath string) ([]domain.SeedAssignment, error)
ParseSeedsFile reads a CSV file mapping names to seed positions
func PrintLeafNodes ¶
func PrintPoolMatches ¶
func PrintTeamEliminationMatches ¶ added in v0.2.0
func ReadEntriesFromFile ¶ added in v0.9.0
func RemoveDuplicates ¶
RemoveDuplicates removes duplicate strings from the input slice and returns a new slice without duplicates.
The function takes a parameter named input, which is a slice of strings. It represents the input slice from which duplicates and empty strings will be removed.
func RoundToPowerOf2 ¶ added in v0.4.0
func SetSheetLayoutLandscapeA3 ¶ added in v0.11.0
func SetSheetLayoutPortraitA4 ¶ added in v0.11.0
func SetSheetLayoutPortraitA4Centered ¶ added in v0.14.0
SetSheetLayoutPortraitA4Centered configures portrait A4 with print-centering. Unlike SetSheetLayoutPortraitA4 it does not enable FitToPage, so smaller content keeps its natural size and the horizontal/vertical centering print option actually has room to take effect.
func SetSheetLayoutPortraitA4DownThenOver ¶ added in v0.14.0
func SetTreeSheetTitle ¶ added in v0.14.0
SetTreeSheetTitle writes a title formula into the first row of a tree sheet, spanning a wide range of columns to cover the bracket layout. The formula prepends the value of data!$B$1 (the user-supplied title prefix) to the given title string, so editing that single cell updates all tree sheets.
func ValidateCourts ¶ added in v0.14.0
ValidateCourts returns an error when n is outside the supported court range. Courts are labelled A–Z, so MaxCourts (26) is the hard upper bound. n < 1 is also rejected so the caller does not have to guess what "0 courts" should mean.
Types ¶
type MatchWinner ¶
type MatchWinner struct {
// contains filtered or unexported fields
}
type Node ¶
type Node struct {
LeafNode bool
// sheet for Cell Values
SheetName string
// Pool Number or Cell value
LeafVal string
Val int64
Left *Node
Right *Node
// contains filtered or unexported fields
}
func CreateBalancedTree ¶
func SubdivideTree ¶ added in v0.4.0
function that subdivides a tree into a specified number of subtrees
type Player ¶
type Player struct {
Name string
DisplayName string
Dojo string
Metadata []string
PoolPosition int64
Seed int
Number string // e.g. "K1" — assigned when --number-prefix is set
// contains filtered or unexported fields
}
func PoolSeeding ¶ added in v0.14.0
PoolSeeding reorders players for pool distribution so that top seeds land in pools that are appropriately spread across the given number of courts.
It assigns seeds to courts in a round-robin fashion and uses a per-court priority to ensure correct bracket placement (e.g., top and bottom of the court's bracket) after the pools are deinterleaved by ReorderPoolsForCourts.
func StandardSeeding ¶ added in v0.11.0
StandardSeeding reorders players into bracket positions such that seeded participants (Seed > 0) are spaced according to tournament standards (e.g., #1 and #2 on opposite halves). Unseeded players fill the remaining slots.
type Pool ¶
type Pool struct {
PoolName string
Players []Player
Matches []Match
// contains filtered or unexported fields
}
func ReorderPoolsForCourts ¶ added in v0.14.0
ReorderPoolsForCourts deinterleaves pools so that when divided into contiguous court blocks, each block has balanced pool sizes and seeds are spread across courts. Original pool i goes to court block (i % numCourts). Pool names are re-assigned alphabetically after reordering.
type RowStack ¶ added in v0.2.0
type RowStack struct {
// contains filtered or unexported fields
}