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
.labelmember. - To represent an enum value to KTS software, use the value's
.codemember.
✔️ 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:
.namestring the tournament name specified in KTS.idObject the tournament ID specified in KTS.id.idstring the actual ID (e.g.,X99-124558), can also be obtained by convertingidto a string.id.isTemporarybool whether this is a temporary ID (generated by KTS) or a unique ID (issued by KCGN)
.startTimeDate the tournament's start time, as entered in KTS.eventTypeEnum.EventType the event type set in KTS.tournamentStyleEnum.TournamentStyle the tournament style set in KTS.tournamentStructureEnum.TournamentStructure the tournament structure set in KTS.playerStructureEnum.PlayerStructure the player structure (i.e., team size settings) set in KTS.staffObject any staff members entered in KTS.staff.allArray of{ player: Player, role: Enum.StaffRole }all staff members.staff.byRole[Enum.StaffRole]Array ofPlayerall players with the given staff role
.entrantsObject the participants in the tournament (consisting of one or more players, depending on player structure).entrants.allArray ofEntrantall enrolled entrants.entrants.activeArray ofEntrantall active entrants (that have not dropped from the tournament).entrants.droppedArray ofEntrantall 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
.roundsObject the tournament's rounds (consisting of one or more matches).rounds.allArray ofRoundall rounds of the tournament.rounds.currentRound or null the current round of the tournament.rounds.swissArray ofRoundall Swiss rounds of the tournament.rounds.playoffArray ofRoundall Playoff rounds of the tournament.rounds.byRoundIdx[int]Round or undefined Round with the specified numeric index.rounds.firstPlayoffRoundint 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
.matchesObject the tournament's matches (for by-round access, go via.rounds).locationObject{ id, name, address, city, country, phoneNumber, state, webSite, zipCode }the tournament location info specified in KTS.isFinalizedbool whether "Finalize Tournament" has been clicked, and the tournament can no longer be edited in KTS.firstTableinteger 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 Entrants consisting of one or more players, not players themselves.
A player object has the following members:
.kcgnIdstring or null the player's assigned KCGN ID, if provided;nullfor players enrolled with a temporary ID.temporaryIdstring or null the temporary ID assigned by KTS, for players without a KCGN ID; not globally unique!.namestring the player's "full name" as displayed in KTS.lastNamestring or null the player's last name, as entered in KTS.firstNamestring 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:
.idstring the entrant's ID.namestring the entrant's name.playersArray of Player the players that are part of this entrant.rankint current ranking within the tournament.recordObject the entrant's record in the tournament.record.swissObject.record.swiss.pointsint the points achieved in swiss play.record.swiss.winsint the number of swiss rounds won.record.swiss.lossesint the number of swiss rounds lost.record.swiss.drawsint the number of swiss rounds drawn.record.swiss.tiebreakers[ float, float ] the entrant's tiebreaker scores, each between 0 and 1, inclusive
.record.playoffObject.record.playoff.winsint the number of playoff rounds won.record.playoff.lossesint the number of playoff rounds lost
.record.allObject{ wins, losses, draws }record across both swiss rounds and playoffs
.currentMatchMatch or null the entrant's ongoing match.matchesObject the matches that the entrant participates in.matches.allArray ofMatchall matches the entrant has participated in.matches.swissArray ofMatchall swiss matches the entrant has participated in.matches.playoffArray ofMatchall playoff matches the entrant has participated in- To get the entrant's match for a specific round, use
.matches.byEntranton Round
.droppedObject or null non-nullif and only if the entrant has been dropped from the tournament.dropped.roundRound the round in which the entrant was dropped.dropped.reasonstring the reason for which the entrant was dropped
.assignedSeatingint or null fixed table number assigned to this entrant
A match object has the following members:
.roundRound.tableint the table this match is played on.isCompletebool whether a result has been recorded for this match.entrantsArray [ Entrant or null, Entrant or null ] the participants in the matchnullparticipant(s) will be recorded for round byes
.winnerEntrant or null the winner of the match, if determined.opponentFor[Entrant]Entrant or undefined the specified entrant's opponent in this match.resultForObject or undefined the result of this complete match from the point of view of a given entrant,undefinedfor incomplete matches.resultFor[Entrant]string or undefined one of the strings'win','draw'or'loss'
.pointsForObject or undefined the points received by any given entrant for this complete swiss match,undefinedfor 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:
.idxint the round's numeric index.labelstring text describing the round (e.g., "Round 3" or "Top 32").isPlayoffbool whether this round is a playoff round.matchesObject the matches in this round