You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
byes stored as Bye objects (separate from games) with kind: 'full' | 'half' | 'zero' | 'pairing'
TRF metadata mapped to TournamentMetadata (chiefArbiter, city, comments, roundDates, etc.)
AbnormalPoints (tag 299) mapped to PointAdjustment[]
game construction from TRF lines
TRF stores results per-player (each 001 line has that player's round results). parse builds Game objects by taking the white player's entry as canonical. black player's entry is cross-checked — if it disagrees, a warning is emitted via onWarning.
mapping from TRF result codes to Game:
TRF code
result
forfeit
rated
1
'white' (or 'black')
-
true
0
'black' (or 'white')
-
true
=
'draw'
-
true
W
'white' (or 'black')
-
false
D
'draw'
-
false
L
'black' (or 'white')
-
false
+
winner side
loser side
-
-
winner side
loser side
-
F
-
-
bye: 'full'
H
-
-
bye: 'half'
Z
-
-
bye: 'zero'
U
-
-
bye: 'pairing'
result direction depends on which player's line we're reading (white or black).
stringify() input
takes TournamentData + StringifyOptions
StringifyOptions.version controls TRF16 vs TRF26 output (default: TRF26)
reconstructs per-player result columns from CompletedRound[].games
for each player in each round: finds the game involving that player, determines their color, maps Game.result + Game.forfeit + Game.rated back to a TRF result code
reads Player.points and Player.rank directly (no recomputation)
uses Player.startingRank for pairing number when present, otherwise assigns sequential numbers
maps PointAdjustment[] back to AbnormalPoints (tag 299)
writes TournamentMetadata fields to header tags
derives NRS line fields (name, birthDate, sex) from the Player object
removed exports
ResultCode — internal to parse/stringify
RoundResult — replaced by Game (from tournament)
Sex, Title — on Player (from tournament)
Tournament type — replaced by TournamentData (from tournament)
Version — stays but not on the data model, only in StringifyOptions
new dependency
@echecs/tournament becomes a dependency (for types only — no runtime code imported).
encoding types that stay in trf
these are TRF format details, not domain concepts:
Version ('TRF16' | 'TRF26')
TeamRoundResult / TeamRoundResult801 / TeamRoundResult802 — two encoding variants for team round results. parse maps both into the clean TeamRoundResult domain shape (if added to tournament). stringify picks the encoding based on version/context.
AbnormalPoints raw type codes — parse maps to PointAdjustment, stringify maps back
OutOfOrderLineup — TRF-specific team lineup exception record
ForfeitedMatch with '+-' | '-+' | '--' codes — derivable from games with forfeits
TeamPairingAllocatedBye — TRF-specific team bye allocation format
couple trf directly to
@echecs/tournamenttypes.parse()returnsTournamentData,stringify()takesTournamentData. the adapter in endorsement (trfToSwiss()) becomes unnecessary.supersedes #23.
depends on echecsjs/tournament#20.
what changes
parse() output
TournamentData | null(from@echecs/tournament)Player.idisstring(wasnumberaspairingNumber)Player.startingRankset to the numeric pairing numberPlayer.pointsandPlayer.rankread from file as-is (source of truth)CompletedRound[]withGame[]— not per-playerRoundResult[]ResultCodemapped internally toGame.result('white'/'black'/'draw'/'none') +Game.forfeit+Game.ratedByeobjects (separate from games) withkind: 'full' | 'half' | 'zero' | 'pairing'TournamentMetadata(chiefArbiter, city, comments, roundDates, etc.)AbnormalPoints(tag 299) mapped toPointAdjustment[]game construction from TRF lines
TRF stores results per-player (each 001 line has that player's round results). parse builds
Gameobjects by taking the white player's entry as canonical. black player's entry is cross-checked — if it disagrees, a warning is emitted viaonWarning.mapping from TRF result codes to Game:
1'white'(or'black')true0'black'(or'white')true='draw'trueW'white'(or'black')falseD'draw'falseL'black'(or'white')false+-F'full'H'half'Z'zero'U'pairing'result direction depends on which player's line we're reading (white or black).
stringify() input
TournamentData+StringifyOptionsStringifyOptions.versioncontrols TRF16 vs TRF26 output (default: TRF26)CompletedRound[].gamesGame.result+Game.forfeit+Game.ratedback to a TRF result codePlayer.pointsandPlayer.rankdirectly (no recomputation)Player.startingRankfor pairing number when present, otherwise assigns sequential numbersPointAdjustment[]back toAbnormalPoints(tag 299)TournamentMetadatafields to header tagsname,birthDate,sex) from thePlayerobjectremoved exports
ResultCode— internal to parse/stringifyRoundResult— replaced byGame(from tournament)Sex,Title— onPlayer(from tournament)Tournamenttype — replaced byTournamentData(from tournament)Version— stays but not on the data model, only inStringifyOptionsnew dependency
@echecs/tournamentbecomes a dependency (for types only — no runtime code imported).encoding types that stay in trf
these are TRF format details, not domain concepts:
Version('TRF16' | 'TRF26')TeamRoundResult/TeamRoundResult801/TeamRoundResult802— two encoding variants for team round results. parse maps both into the cleanTeamRoundResultdomain shape (if added to tournament). stringify picks the encoding based on version/context.AbnormalPointsraw type codes — parse maps toPointAdjustment, stringify maps backOutOfOrderLineup— TRF-specific team lineup exception recordForfeitedMatchwith'+-' | '-+' | '--'codes — derivable from games with forfeitsTeamPairingAllocatedBye— TRF-specific team bye allocation formatParseError,ParseWarning,ParseOptions,StringifyOptionstest migration
~387 tests. every assertion that checks
player.results,player.points,player.rank, orResultCodevalues needs updating. the main categories:pairingNumber→id(string),results→ gone (check rounds instead),points/rankstill presentResultCodestrings →Game.result/Game.forfeit/Game.ratedimplementation order
@echecs/tournamentas dependencysrc/types.ts— import from tournament, keep encoding typessrc/parse.ts— buildTournamentDatawithCompletedRound[], map result codessrc/stringify.ts— consumeTournamentData, reconstruct per-player linessrc/index.tsexports