public void chat(String message) {
   message = message.substring(5);
   if (isServer) {
     for (ServerService s : services)
       s.sendMessageToClients(
           "chat " + gameData.getPlayerName() + " " + gameData.getPlayerSide() + " " + message);
     parseChatMessage(
         "chat " + gameData.getPlayerName() + " " + gameData.getPlayerSide() + " " + message);
   }
   if (!isServer)
     requestToServer.println(
         "chat " + gameData.getPlayerName() + " " + gameData.getPlayerSide() + " " + message);
 }
 public void elaborateShootRequest(int x, int y, String side) {
   String controllerQuery = null;
   if (side.equals("guest")) {
     controllerQuery = cont.shootAtHostSide(x, y);
   }
   if (side.equals("host")) {
     controllerQuery = cont.shootAtGuestSide(x, y);
   }
   for (ServerService s : services) {
     s.sendMessageToClients(controllerQuery);
   }
   if (controllerQuery.startsWith("water")) waterResponse(controllerQuery);
   if (controllerQuery.startsWith("hit")) hitResponse(controllerQuery);
   if (controllerQuery.startsWith("destroyed")) destroyedResponse(controllerQuery);
   if (controllerQuery.startsWith("allShipsDestroyed")) allShipsDestroyed(controllerQuery);
 }
 public boolean placeShipsOnField(
     String field, String alignment, String shipName, int xStartCoordinate, int yStartCoordinate) {
   if (!gameData.shipAlreadyPlaced(shipName, alignment, xStartCoordinate, yStartCoordinate)) {
     if (!isServer) {
       requestToServer.println(
           "placeShip "
               + field
               + " "
               + alignment
               + " "
               + shipName
               + " "
               + xStartCoordinate
               + " "
               + yStartCoordinate);
       return true;
     }
     if (isServer) {
       boolean controllerQuery =
           cont.addShip(shipName, alignment, field, xStartCoordinate, yStartCoordinate);
       if (controllerQuery) {
         gameData.placeShipsOnField(alignment, shipName, xStartCoordinate, yStartCoordinate);
         for (ServerService s : services) {
           s.sendMessageToClients(
               "placeShip "
                   + field
                   + " "
                   + alignment
                   + " "
                   + shipName
                   + " "
                   + xStartCoordinate
                   + " "
                   + yStartCoordinate);
         }
         return true;
       }
     }
   }
   return false;
 }
 public void elaboratePlaceRequest(
     String field, String alignment, String shipName, int xStartCoordinate, int yStartCoordinate) {
   boolean controllerResponse = false;
   controllerResponse =
       cont.addShip(shipName, alignment, field, xStartCoordinate, yStartCoordinate);
   if (controllerResponse) {
     for (ServerService s : services) {
       s.sendMessageToClients(
           "shipSuccessfullyPlaced "
               + field
               + " "
               + alignment
               + " "
               + shipName
               + " "
               + new Integer(xStartCoordinate).toString()
               + " "
               + new Integer(yStartCoordinate).toString());
     }
   }
 }
 public void sendMessageToAllClients(String message) {
   for (ServerService s : services) s.sendMessageToClients(message);
 }