Exemplo n.º 1
0
    def check(self, parsedInput: list, settings: dict) -> int:

        if len(parsedInput) != 3:
            Log('ERROR', 'Info command - Invalid arguments.')
            return 84
        if parsedInput[1] not in settings.keys():
            Log('ERROR', 'Info command - Invalid key.')
            return 84
        return 0
Exemplo n.º 2
0
    def check(self, parsedInput: list) -> int:

        if len(parsedInput) != 2 or isInt(parsedInput[1]) is False:
            Log('ERROR', 'Start command - Invalid arguments.')
            return 84
        if int(parsedInput[1]) < 5:
            Log('ERROR', 'Start command - Invalid size.')
            return 84
        return 0
Exemplo n.º 3
0
    def check(self, parsedInput: list, gameBoard: GameBoard) -> int:

        if len(parsedInput) != 3:
            Log('ERROR', 'Turn command - Invalid arguments.')
            return 84
        if isInt(parsedInput[1]) is False or isInt(parsedInput[2]) is False:
            Log('ERROR', 'Turn command - Invalid size.')
            return 84
        if int(parsedInput[1]) not in range(gameBoard._size)\
            or int(parsedInput[2]) not in range(gameBoard._size):
            Log('ERROR', 'Turn command - Invalid size.')
            return 84
        return 0
Exemplo n.º 4
0
    def action(self, parsedInput: list):
        """Fetch the right command to process and process it.

        Args:
            parsedInput (list): Input command to process.
        """

        try:
            self._commands[parsedInput[0]](parsedInput, self._gameBoard)
        except KeyError:
            Log('Error', 'Invalid command.')
Exemplo n.º 5
0
    def setBoard(self, gameBoard: GameBoard) -> list:
        def checkInput(coords: str) -> int:
            cs = coords.split(',')
            if len(cs) != 3:
                return 84
            for c in cs:
                if isInt(c) is False:
                    return 84
            if int(cs[2]) not in [1, 2, 3]:
                return 84
            if int(cs[0]) not in range(gameBoard._size) or int(
                    cs[1]) not in range(gameBoard._size):
                return 84
            return 0

        while True:
            inpt = input()
            if inpt == "DONE":
                break
            elif checkInput(inpt) == 84:
                Log('ERROR', 'Board command - Wrong coordinates format.')
            else:
                cs = inpt.split(',')
                gameBoard._board[int(cs[0])][int(cs[1])] = int(cs[2])
Exemplo n.º 6
0
    def check(self, parsedInput: list) -> int:

        if len(parsedInput) != 1:
            Log('ERROR', 'Board command - No arguments expected.')
            return 84
        return 0