Welcome to LibKTS, a JavaScript library for parsing of Yu-Gi-Oh! tournament files generated by the Konami Tournament Software.
LibKTS is developed by @gallantron#1059. Need help? Get in touch!
Simply include LibKTS.js in your project. Then, pass the text contents of the KTS .tournament file to LibKTS.Parse
.
A structured object will be returned – see the structure documentation for details.
LibKTS.Enum
members contain the constants that are used to represent certain settings in KTS.
The following applies to all Enum values:
- Enum values used in tournament objects can, and should, be compared for equality (
===
) with these constants.- You should not use a value's members for identification.
- All enum values have a suitable toString member for unique internal representation. They can, and should, be used as object keys.
- You should not use a value's members as object keys.
- To represent an enum value to the user, use the value's
.label
member. - To represent an enum value to KTS software, use the value's
.code
member.
✔️ DO:
if (staffMember.role === LibKTS.Enum.StaffRole.HEAD_JUDGE)
eventsByType[tournament.eventType].push(tournament)
description.innerText = ('The tournament used the '+tournament.tournamentStyle.label+' format.');
❌ DO NOT:
if (staffMember.role.label === 'Head Judge')
eventsByType[tournament.eventType.code].push(tournament)
description.innerText = ('The tournament used the '+tournament.tournamentStyle+' format.');
Values are ADVANCED
, TRADITIONAL
, SEALED
, and OPEN_DUELING
, corresponding to the "Style" tournament setting in KTS.
Values are SWISS
and SINGLE_ELIMINATION
, corresponding to the "Structure" tournament setting in KTS.
Values are INDIVIDUAL
, TAG_DUEL
, THREE_VS_THREE
, FOUR_VS_FOUR
, and FIVE_VS_FIVE
, corresponding to the "Player Structure" tournament setting in KTS.
To identify how many players a complete team must have, you should use the value's .teamSize
member.
There is a large number of values, matching the "Event Type" tournament setting in KTS.
Commonly used ones include LOCAL
, SNEAK_PEEK
, WCQ_REGIONAL
and YUGIOH_DAY
. (See LibKTS.js
for a full list.)
Each value's .defaultSettings
member has the {tournamentStyle, tournamentStructure, playerStructure}
tuple that KTS will select by default when the event type is chosen.
Values are TOURNAMENT_ORGANIZER
, HEAD_JUDGE
, ASSISTANT_HEAD_JUDGE
, TEAM_LEAD
, FLOOR_JUDGE
, SCOREKEEPER
, EVENT_MANAGER
, and EVENT_STAFF
, corresponding to the choices in KTS' staff list.
This section documents the objects used to represent tournament information. References to the same logical object (e.g., two references to the same player, or the same match) also reference the same JavaScript object. Objects can, and generally should, be compared for strict equality (===
).
✔️ DO:
if (match.winner === entrant)
❌ DO NOT:
if (match.winner.name === entrant.name)
The main entry point object, representing a parsed tournament file. This is what is returned by KTSLib.Parse
.
A tournament object has the following members:
.name
string the tournament name specified in KTS.id
Object the tournament ID specified in KTS.id.id
string the actual ID (e.g.,X99-124558
), can also be obtained by convertingid
to a string.id.isTemporary
bool whether this is a temporary ID (generated by KTS) or a unique ID (issued by KCGN)
.startTime
Date the tournament's start time, as entered in KTS.eventType
Enum.EventType the event type set in KTS.tournamentStyle
Enum.TournamentStyle the tournament style set in KTS.tournamentStructure
Enum.TournamentStructure the tournament structure set in KTS.playerStructure
Enum.PlayerStructure the player structure (i.e., team size settings) set in KTS.staff
Object any staff members entered in KTS.staff.all
Array of{ player: Player, role: Enum.StaffRole }
all staff members.staff.byRole[Enum.StaffRole]
Array ofPlayer
all players with the given staff role
.entrants
Object the participants in the tournament (consisting of one or more players, depending on player structure).entrants.all
Array ofEntrant
all enrolled entrants.entrants.active
Array ofEntrant
all active entrants (that have not dropped from the tournament).entrants.dropped
Array ofEntrant
all dropped entrants.entrants.byPlayer[Player]
Entrant or undefined the tournament entrant for the specified player.entrants.byKcgnId[string]
Entrant or undefined the tournament entrant containing a player with the specified KCGN ID.entrants.byId[string]
Entrant or undefined the tournament entrant with the specified ID
.rounds
Object the tournament's rounds (consisting of one or more matches).rounds.all
Array ofRound
all rounds of the tournament.rounds.current
Round or null the current round of the tournament.rounds.swiss
Array ofRound
all Swiss rounds of the tournament.rounds.playoff
Array ofRound
all Playoff rounds of the tournament.rounds.byRoundIdx[int]
Round or undefined Round with the specified numeric index.rounds.firstPlayoffRound
int or null Numeric index of the first playoff round in the tournament.rounds.byPlayoffPlayers[int]
Round or undefined Playoff round with the specified number of players remaining beforehand
.matches
Object the tournament's matches (for by-round access, go via.rounds
).location
Object{ id, name, address, city, country, phoneNumber, state, webSite, zipCode }
the tournament location info specified in KTS.isFinalized
bool whether "Finalize Tournament" has been clicked, and the tournament can no longer be edited in KTS.firstTable
integer the first table number used by the tournament (default 1, can be changed in KTS)
Represents an individual player. Note that matches are played between Entrant
s consisting of one or more players, not players themselves.
A player object has the following members:
.kcgnId
string or null the player's assigned KCGN ID, if provided;null
for players enrolled with a temporary ID.temporaryId
string or null the temporary ID assigned by KTS, for players without a KCGN ID; not globally unique!.name
string the player's "full name" as displayed in KTS.lastName
string or null the player's last name, as entered in KTS.firstName
string or null the player's first name, as entered in KTS
Represents an entrant into a given tournament.
An entrant object has the following members:
.id
string the entrant's ID.name
string the entrant's name.players
Array of Player the players that are part of this entrant.rank
int current ranking within the tournament.record
Object the entrant's record in the tournament.record.swiss
Object.record.swiss.points
int the points achieved in swiss play.record.swiss.wins
int the number of swiss rounds won.record.swiss.losses
int the number of swiss rounds lost.record.swiss.draws
int the number of swiss rounds drawn.record.swiss.tiebreakers
[ float, float ] the entrant's tiebreaker scores, each between 0 and 1, inclusive
.record.playoff
Object.record.playoff.wins
int the number of playoff rounds won.record.playoff.losses
int the number of playoff rounds lost
.record.all
Object{ wins, losses, draws }
record across both swiss rounds and playoffs
.currentMatch
Match or null the entrant's ongoing match.matches
Object the matches that the entrant participates in.matches.all
Array ofMatch
all matches the entrant has participated in.matches.swiss
Array ofMatch
all swiss matches the entrant has participated in.matches.playoff
Array ofMatch
all playoff matches the entrant has participated in- To get the entrant's match for a specific round, use
.matches.byEntrant
on Round
.dropped
Object or null non-null
if and only if the entrant has been dropped from the tournament.dropped.round
Round the round in which the entrant was dropped.dropped.reason
string the reason for which the entrant was dropped
.assignedSeating
int or null fixed table number assigned to this entrant
A match object has the following members:
.round
Round.table
int the table this match is played on.isComplete
bool whether a result has been recorded for this match.entrants
Array [ Entrant or null, Entrant or null ] the participants in the matchnull
participant(s) will be recorded for round byes
.winner
Entrant or null the winner of the match, if determined.opponentFor[Entrant]
Entrant or undefined the specified entrant's opponent in this match.resultFor
Object or undefined the result of this complete match from the point of view of a given entrant,undefined
for incomplete matches.resultFor[Entrant]
string or undefined one of the strings'win'
,'draw'
or'loss'
.pointsFor
Object or undefined the points received by any given entrant for this complete swiss match,undefined
for playoff or incomplete matches.pointsFor[Entrant]
int or undefined the points received by the specified entrant for this match
A round object has the following members:
.idx
int the round's numeric index.label
string text describing the round (e.g., "Round 3" or "Top 32").isPlayoff
bool whether this round is a playoff round.matches
Object the matches in this round