Ejemplo n.º 1
0
 @Test
 public void placeACrab() throws HantoException, HantoPrematureResignationException {
   assertEquals(OK, game.makeMove(CRAB, null, makeCoordinate(0, 0)));
   final HantoPiece hp = game.getPieceAt(makeCoordinate(0, 0));
   assertEquals(BLUE, hp.getColor());
   assertEquals(CRAB, hp.getType());
 }
Ejemplo n.º 2
0
 @Test
 public void bluePlacesButterflyFirst() throws HantoException, HantoPrematureResignationException {
   final MoveResult mr = game.makeMove(BUTTERFLY, null, makeCoordinate(0, 0));
   assertEquals(OK, mr);
   final HantoPiece piece = game.getPieceAt(makeCoordinate(0, 0));
   assertEquals(BLUE, piece.getColor());
   assertEquals(BUTTERFLY, piece.getType());
 }
Ejemplo n.º 3
0
 @Test(expected = HantoException.class)
 public void attemptToMoveAfterGameIsOver()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1),
         plPair(BLUE, SPARROW, -1, 1), plPair(RED, SPARROW, 0, -1),
         plPair(RED, CRAB, 1, 1)
       };
   testGame.initializeBoard(board);
   testGame.setPlayerMoving(RED);
   game.makeMove(CRAB, makeCoordinate(1, 1), makeCoordinate(1, 0)); // RED wins
   game.makeMove(SPARROW, makeCoordinate(-1, 1), makeCoordinate(-1, 2));
 }
Ejemplo n.º 4
0
 @Test
 public void sparrowFliesMoreThanOneSpace()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1),
         plPair(BLUE, SPARROW, -1, 1), plPair(RED, SPARROW, 0, -1),
         plPair(RED, SPARROW, 1, 1)
       };
   testGame.initializeBoard(board);
   testGame.setTurnNumber(4);
   assertEquals(OK, game.makeMove(SPARROW, makeCoordinate(-1, 0), makeCoordinate(2, 1)));
   final HantoPiece hp = game.getPieceAt(makeCoordinate(2, 1));
   assertEquals(BLUE, hp.getColor());
   assertEquals(SPARROW, hp.getType());
 }
Ejemplo n.º 5
0
 @Test(expected = HantoException.class)
 public void sparrowFliesToInvalidLocation()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1)
       };
   testGame.initializeBoard(board);
   testGame.setTurnNumber(3);
   game.makeMove(SPARROW, makeCoordinate(-1, 0), makeCoordinate(0, 3));
 }
Ejemplo n.º 6
0
  @Test
  public void moveByFlying() throws HantoException, HantoPrematureResignationException {

    final PieceLocationPair[] board =
        new PieceLocationPair[] {
          plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
          plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1),
          plPair(BLUE, SPARROW, -1, 1), plPair(RED, SPARROW, 0, -1),
          plPair(RED, SPARROW, -2, 1)
        };
    testGame.initializeBoard(board);
    testGame.setPlayerMoving(RED);
    testGame.setTurnNumber(4);
    assertEquals(RED_WINS, game.makeMove(SPARROW, makeCoordinate(-2, 1), makeCoordinate(1, 0)));
  }
Ejemplo n.º 7
0
 @Test(expected = HantoException.class)
 public void crabWalksAndCreatesDisconnectedConfiguration()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, CRAB, 1, 0),
         plPair(BLUE, SPARROW, -2, 0), plPair(RED, SPARROW, 2, 0),
         plPair(BLUE, SPARROW, -3, 0)
       };
   testGame.initializeBoard(board);
   testGame.setTurnNumber(4);
   testGame.setPlayerMoving(RED);
   game.makeMove(CRAB, makeCoordinate(1, 0), makeCoordinate(1, -1));
 }
Ejemplo n.º 8
0
 @Test(expected = HantoPrematureResignationException.class)
 public void blueResignsImmediately() throws HantoException, HantoPrematureResignationException {
   // use the factory for coverage
   game = HantoGameFactory.getInstance().makeHantoGame(HantoGameID.DELTA_HANTO);
   assertEquals(RED_WINS, game.makeMove(null, null, null));
 }
Ejemplo n.º 9
0
 @Test(expected = HantoException.class)
 public void attemptToUsePieceNotInGame()
     throws HantoException, HantoPrematureResignationException {
   game.makeMove(CRANE, null, makeCoordinate(0, 0));
 }