Package es.mahulo.battleship.model

Examples of es.mahulo.battleship.model.Player


    GameConfig gameConfig = gameConfigDao.find(1L); //TODO DEFINE A TABLE DEFAULT CONFIGURATION
   
    List<Player> players = new ArrayList<Player>();
   
    Player player = new Player();
    player.setUser(user);
    player.setShips(new ArrayList<Ship>());
    player.setShots(new ArrayList<Shot>());
    player.setGame(game);
   
    players.add(player);

    game.setGameConfig(gameConfig);
    game.setStatus(GameStatus.StartUp);
View Full Code Here


    Game game = gameDao.find(gameId);
   
    if (game.getStatus() == GameStatus.StartUp) {
      User user = userDao.findByName(userId);
     
      Player player = new Player();
      player.setUser(user);
      player.setShips(new ArrayList<Ship>());
      player.setShots(new ArrayList<Shot>());
      player.setGame(game);

      List<Player> players = game.getPlayers();
      players.add(player);
     
      game.setStatus(GameStatus.Configuring);
View Full Code Here

  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);
        }
View Full Code Here

    logger.info("shot " + userId + " " + shot);
   
    Game game = gameDao.find(gameId);
    logger.debug("game " + game);
 
    Player player = foundPlayer(game.getPlayers(),userId);
    logger.debug("found " + player);
   
   
    Boolean isHit = false;   
    switch (game.getStatus()) {
View Full Code Here

    return false;
  }

  private Player foundPlayer(List<Player> players,String userId) throws Exception {
    logger.info("found Player " + players + " " + userId);
    Player player = null;
    for (Player aPlayer :players) {
      if (aPlayer.getUser().getName().equals(userId)) {
        player = aPlayer;
        break;
      }
View Full Code Here

    
    Ship ship = new Ship();
    ship.setShipConfig(shipConfigs.get(0));
    ship.setCells(cells);
   
    Player player = new Player();
    player.setShips(new ArrayList<Ship>());
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

    Ship ship = new Ship();
    ship.setId(1L);
    ship.setShipConfig(shipConfigs.get(0));
    ship.setCells(cells);
   
    Player player = new Player();
    player.setShips(new ArrayList<Ship>());
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

   
    List<Ship> playerShips = new ArrayList<Ship>();
    playerShips.add(buildShip(shipConfigs.get(0), cellShip1));
   
    List<Player>  players = new ArrayList<Player>();
    Player player = new Player();
    player.setShips(playerShips);
    players.add(player);

   
    Game game = new Game();
    game.setStatus(GameStatus.Configuring);
View Full Code Here

    Ship ship = new Ship();
    ship.setShipConfig(shipConfigs.get(0));
    ship.setCells(cells);
    ships.add(ship);
   
    Player player = new Player();
    player.setShips(new ArrayList<Ship>());
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

    playerShip.setCells(cells);
   
    List<Ship> ships = new ArrayList<Ship>();
    ships.add(playerShip);
   
    Player player = new Player();
    player.setId(1L);
    player.setShips(ships);
   
   
    cells = new ArrayList<Cell>();
    Cell cell2 = new Cell();
    cell1.setX(10);
View Full Code Here

TOP

Related Classes of es.mahulo.battleship.model.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.