Package org.swtpra1

Class TournamentControl

  • All Implemented Interfaces:
    java.io.Serializable

    public class TournamentControl
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      TournamentControl​(java.lang.String gameServerUrl, java.lang.String authenticationToken, long maxTurnTime)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String constructUrl​(java.lang.String target)
      Constructs the whole url for a specific target including the token parameter.
      java.io.File getResultsFile()  
      java.io.File getStateFile()  
      DoubleRoundRobinTournament getTournament()  
      boolean initialize()
      Verifies that enough of the listed players respond to messages and registers them on the server.
      void launchNextGame()
      If the next game of the tournament is able to be started the appropriate request is sent to the server.
      boolean parsePlayerListFile​(java.lang.String filename)
      Parses csv file containing player names und urls of participating players and creates List of Player objects.
      void setResultsFile​(java.io.File resultsFile)  
      void setStateFile​(java.io.File stateFile)  
      void startTournament()
      If it does not exist already a new tournament is generated and the first batch of games started manually.
      boolean verifyCredentials()
      Verifies the given URL and authenticationToken by requesting the /games once and expecting a positive response.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TournamentControl

        public TournamentControl​(java.lang.String gameServerUrl,
                                 java.lang.String authenticationToken,
                                 long maxTurnTime)
        Constructor.
        Parameters:
        gameServerUrl - URL of the game server.
        authenticationToken - Token which is used for authentication
        maxTurnTime - The maximum turn time in milliseconds. After that the turn is invalid.
    • Method Detail

      • constructUrl

        public java.lang.String constructUrl​(java.lang.String target)
        Constructs the whole url for a specific target including the token parameter.
        Parameters:
        target - the target without the leading / (!)
        Returns:
        the whole URL including the token, empty string if URL is malformed.
      • parsePlayerListFile

        public boolean parsePlayerListFile​(java.lang.String filename)
        Parses csv file containing player names und urls of participating players and creates List of Player objects.
        Parameters:
        filename - the file path of the csv file containing participants name and url.
        Returns:
        boolean indicating successful parse
      • verifyCredentials

        public boolean verifyCredentials()
        Verifies the given URL and authenticationToken by requesting the /games once and expecting a positive response.
        Returns:
        true if server can be accessed with the given credentials; false otherwise
      • initialize

        public boolean initialize()
        Verifies that enough of the listed players respond to messages and registers them on the server.
        Returns:
        whether the tournament can be executed now
      • startTournament

        public void startTournament()
        If it does not exist already a new tournament is generated and the first batch of games started manually. We need to start manually here, because afterwards new games are only started when old ones end. In case tournament already exists(continue mode), games in runningGames list will be resumed on game server.
      • launchNextGame

        public void launchNextGame()
        If the next game of the tournament is able to be started the appropriate request is sent to the server. In case this is not the case nothing happens
      • getStateFile

        public java.io.File getStateFile()
      • setStateFile

        public void setStateFile​(java.io.File stateFile)
      • getResultsFile

        public java.io.File getResultsFile()
      • setResultsFile

        public void setResultsFile​(java.io.File resultsFile)