Пример #1
0
    def event_createPlayer_submit(self):
        """
            used to handle creation of tournament
        """
        global input_playerDCI
        global input_playerName

        global text_createPlayer_failMsg

        # get the input values
        playerDCI = self.input_playerDCI.get()
        playerName = self.input_playerName.get()

        if (playerDCI.isdigit() and len(playerName) >= 3):  # check values
            self.win_createPlayer.destroy()  # destroy window on db submission
        else:  # values are not valid, check what failed
            if (len(playerName) < 3):
                self.text_createPlayer_failMsg.set(
                    "player name length must be at least 3")
            if (not playerDCI.isdigit()):
                self.text_createPlayer_failMsg.set(
                    "max rounds must be a number")

        tr_api.createPlayer(playerDCI, playerName)
Пример #2
0
def setUpHelper(self):
    global done
    tr_api.createTournament('8Man Test', 25)
    tr_api.createPlayer(6, 'Green')
    tr_api.createPlayer(7, 'Red')
    tr_api.createPlayer(8, 'Blue')
    tr_api.addPlayer(1, 4)
    tr_api.addPlayer(2, 4)
    tr_api.addPlayer(3, 4)
    tr_api.addPlayer(4, 4)
    tr_api.addPlayer(5, 4)
    tr_api.addPlayer(6, 4)
    tr_api.addPlayer(7, 4)
    tr_api.addPlayer(8, 4)
    tr_api.startTournament(4)
    done = True
Пример #3
0
 def setUp(self):
     tr_api.createPlayer(5, 'Brown')
     self.topdict = tr_api.searchPlayers('E')
     self.topdict2 = tr_api.searchPlayers('Evan')
     self.topdict3 = tr_api.searchPlayers('B')
     self.topdict4 = tr_api.searchPlayers('-1')
Пример #4
0
def main():
    
    while True: # no do while in python :(
        result = None
        command = input(">")
        if len(command) == 0:
            continue
        command = command.split()

        try:
            if command[0].lower() == 'cp':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 2)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.createPlayer(int(command[1]), name)
                table_print(result)
            elif command[0].lower() == 'ct':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 2)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.createTournament(name, int(command[1]))
                table_print(result)
            elif command[0].lower() == 'sp':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 1)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.searchPlayers(name)
                table_print(result)
            elif command[0].lower() == 'ap':
                result = tr_api.addPlayer(int(command[1]),int(command[2]))
                table_print(result)
            elif command[0].lower() == 'rp':
                result = tr_api.removePlayer(int(command[1]),int(command[2]))
                table_print(result)
            elif command[0].lower() == 'lp':
                result = tr_api.listPlayers()
                table_print(result)
            elif command[0].lower() == 'lt':
                result = tr_api.listTournaments(None, None)
                table_print(result)
            elif command[0].lower() == 'ltp':
                result = tr_api.listTournamentPlayers(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'latp':
                result = tr_api.listActiveTournamentPlayers(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'fr':
                result = tr_api.finishRound(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'genpairings':
                result = tr_api.generatePairings(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'gtp':
                result = tr_api.getTournamentPlayer(int(command[1]))
                print(result)
            elif command[0].lower() == 'gp':
                result = tr_api.getPlayer(int(command[1]))
                player_print(result)
            elif command[0].lower() == 'lm':
                result = tr_api.matchList(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'lr':
                result = tr_api.roundList(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'st':
                result = tr_api.startTournament(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'smr':
                result = tr_api.setMatchResults(
                        int(command[1]), int(command[2]), int(command[3]), int(command[4]))
                table_print(result)

            elif command[0].lower() == 'help':
                print_help()
                continue

            elif command[0].lower() == 'exit':
                return

            else:
                print("Invalid command")
                continue
        except ValueError:
            print("Invalid parameter type")
            continue
        except IndexError:
            print("Invalid number of parameters")
            continue
Пример #5
0
 def tearDown(self):
     tr_api.createPlayer(2, 'Ben')
     tr_api.createPlayer(3, 'Will')
     tr_api.createPlayer(4, 'Jon')
Пример #6
0
 def setUp(self):
     tr_api.createPlayer(1, 'Evan')
     self.topdict = tr_api.listPlayers()
     self.topdict2 = tr_api.createPlayer(1, "Fail2")