Esempio n. 1
0
def getUserCoordinate(user, coordinateName):
    response = None
    while 1:
        sendMessageToUser(user.clientSocket, "send a rocket to which " + coordinateName)
        response = getMessageFromUser(user.clientSocket)
        if response.isdigit():
            if Utils.isValidCoordinate(int(response), Utils.BOARDSIZE):
                break
        sendMessageToUser(
            user.clientSocket, "Invalid input, please enter a positive number between 0 and " + str(Utils.BOARDSIZE - 1)
        )
    return int(response)
Esempio n. 2
0
 def isValidPosition(self, position):
     if Utils.isValidCoordinate(position.getRow(), self.size) and Utils.isValidCoordinate(position.getColumn(), self.size):
         if not self.grid[position.getRow()][position.getColumn()].getIsBoat():
             return True
     return False