Code Monkey home page Code Monkey logo

libkts's Introduction

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!

Quick Start

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.

Enum fields

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.');

Enum.TournamentStyle

Values are ADVANCED, TRADITIONAL, SEALED, and OPEN_DUELING, corresponding to the "Style" tournament setting in KTS.

Enum.TournamentStructure

Values are SWISS and SINGLE_ELIMINATION, corresponding to the "Structure" tournament setting in KTS.

Enum.PlayerStructure

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.

Enum.EventType

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.

Enum.StaffRole

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.

Object structure documentation

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)

Tournament object

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 converting id 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
  • .entrants Object the participants in the tournament (consisting of one or more players, depending on player structure)
    • .entrants.all Array of Entrant all enrolled entrants
    • .entrants.active Array of Entrant all active entrants (that have not dropped from the tournament)
    • .entrants.dropped Array of Entrant 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 of Round all rounds of the tournament
    • .rounds.current Round or null the current round of the tournament
    • .rounds.swiss Array of Round all Swiss rounds of the tournament
    • .rounds.playoff Array of Round 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)
    • .matches.all Array of Match all matches in the tournament
    • .matches.complete Array of Match all matches in the tournament that have a recorded result
    • .matches.ongoing Array of Match all matches in the tournament that do not have a recorded result
  • .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)

Player object

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:

  • .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

Entrant object

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 of Match all matches the entrant has participated in
    • .matches.swiss Array of Match all swiss matches the entrant has participated in
    • .matches.playoff Array of Match 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

Match object

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 match
    • null 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

Round object

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
    • .matches.all Array of Match all matches in this round
    • .matches.byTable[int] Match or undefined the match played on the specified table in this round
    • .matches.byEntrant[Entrant] Match or undefined the match played by the specified entrant in this round

libkts's People

Contributors

treeston avatar gallantron avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.