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()); } } }