Package org.jpacman.framework.model

Examples of org.jpacman.framework.model.Game.movePlayer()


   * @throws FactoryException Can't happen.
   */
  @Test
  public void testC1a_PlayerMovesToEmpty() throws FactoryException {   
    Game g = makePlay("P #");
    g.movePlayer(Direction.RIGHT);
   
    assertEquals("Player moved", tileAt(g, 1, 0), g.getPlayer().getTile());
    assertEquals("No food eaten.", 0, g.getPlayer().getPoints());
    assertEquals(Direction.RIGHT, g.getPlayer().getDirection());
  }
View Full Code Here


   * @throws FactoryException Can't happen.
   */
  @Test
  public void testC2a_PlayerMovesToWall() throws FactoryException {   
    Game g = makePlay("#P.");
    g.movePlayer(Direction.LEFT);
    assertThat("Still at the start",
        tileAt(g, 1, 0), equalTo(g.getPlayer().getTile()));
  }
 
  /**
 
View Full Code Here

  @Test
  public void testC3_PlayerMovesToGhost() throws FactoryException {   
    Game g = makePlay("PG#");
    Player p = g.getPlayer();
   
    g.movePlayer(Direction.RIGHT);
   
    assertFalse("Move kills player", p.isAlive());   
    assertThat(tileAt(g, 1, 0), equalTo(p.getTile()));
  }
 
View Full Code Here

  public void testC5_PlayerMovesToFood() throws FactoryException {   
    Game game = makePlay("P.#");
    Food food = (Food) game.getBoard().spriteAt(1, 0);
    Player player = game.getPlayer();

    game.movePlayer(Direction.RIGHT);
   
    Tile newTile = tileAt(game, 1, 0);
    assertEquals("Food added", food.getPoints(), player.getPoints());
    assertEquals("Player moved", newTile.topSprite(), player);
    assertFalse("Food gone", newTile.containsSprite(food));
View Full Code Here

  public void testObserverAfterPlayerMove() throws FactoryException {
    Observer anObserver = mock(Observer.class);
    Game g = makePlay("P #");
    g.addObserver(anObserver);
   
    g.movePlayer(Direction.RIGHT);
    verify(anObserver).update(any(Observable.class), anyObject());
  }
 
  /**
   * Test that the observers are informed after a ghost move.
View Full Code Here

   * @throws FactoryException Never.
   */
  @Test
  public void testTunneledMove() throws FactoryException {
    Game g = makePlay("P# ");
    g.movePlayer(Direction.LEFT);
   
    Tile newTile = g.getPlayer().getTile();
    assertThat("Player moved", tileAt(g, 2, 0), equalTo(newTile));
  }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.