Skip to content

Instantly share code, notes, and snippets.

@ncurran02
Last active May 31, 2019 00:06
Show Gist options
  • Save ncurran02/1b3faeace95cde196a932e53eb943678 to your computer and use it in GitHub Desktop.
Save ncurran02/1b3faeace95cde196a932e53eb943678 to your computer and use it in GitHub Desktop.

Add players

BEGIN (add player)
  player <- Array[dropPlayerAmount.Value]

  INPUT txtPlayerName
  count <- 0
  filled <- False
  
  REPEAT
    IF player[count] is empty THEN
      player[count].Name <- txtPlayerName
      filled <- True
    ENDIF
    count <- count + 1
  UNTIL filled = True OR count > dropPlayerAmount.Value
END

Generate a new round

BEGIN (generate new round)
  roundNo <- roundNo + 1
  count <- 0
  findNo <- 0
  found <- False
  REPEAT
    player[count].Opponent <- Empty
    IF player[count].Opponent is empty THEN
      REPEAT
        IF player[findNo].Opponent is empty AND (player[findNo].Wins = player[count].Wins OR player[count].Wins = player[findNo].Wins - 1 OR player[count].Wins = player[findNo].Wins + 1) AND player[findNo].Name is not player[count].Name THEN
          found <- True
          player[count].Opponent = player[findNo].Name
          player[findNo].Opponent = player[count].Name
        ENDIF
        findNo <- findNo + 1
      UNTIL found = True OR findNo > dropPlayerAmount.Value
      IF player[count].Opponent is empty THEN
        player[count].Opponent = 'Bye'
        player[count].Wins = player[count].Wins + 1
      ENDIF
    ENDIF
    count <- count + 1
  UNTIL count > dropPlayerAmount.Value
END

Write to a file/End and save a tournament

BEGIN (end and save tournament)
  tournamentFileName <- 'tournament.xml'
  OPEN tournamentFile
  count <- 0
  REPEAT
    WRITE roundNo, player[count].Wins
  UNTIL count > 20
  CLOSE roundInfoFile
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment