public void addShip(Long gameId, String userId, List<Ship> ships) throws Exception {
logger.info("Add Ship " + userId + " " + ships);
Game game = gameDao.find(gameId);
Player player = foundPlayer(game.getPlayers(),userId);
logger.info("Player found " + player);
if ( game.getStatus() == GameStatus.Configuring ) {
if (configService.isComplete(game.getGameConfig(),player) ) {
logger.info("Configuration complete, not possible to add more ships.");
throw new Exception("Configuration complete, not possible to add more ships.");
}
for (Ship ship : ships) {
configService.isValid (game, player,ship);
player.getShips().add(ship);
ship.setPlayer(player);
for (Cell cell : ship.getCells()) {
cell.setHit(false);
cell.setShip(ship);
}