@Test
 public void placeACrab() throws HantoException {
   assertEquals(OK, testGame.makeMove(CRAB, null, makeCoordinate(0, 0)));
   final HantoPiece hp = testGame.getPieceAt(makeCoordinate(0, 0));
   assertEquals(BLUE, hp.getColor());
   assertEquals(CRAB, hp.getType());
 }
  @Test
  public void getPieceAtTest() throws HantoException {
    testGame.makeMove(HantoPieceType.BUTTERFLY, null, new ConcreteHantoCoordinate(0, 0));
    HantoPiece testPiece = testGame.getPieceAt(new ConcreteHantoCoordinate(0, 0));

    assertEquals(HantoPlayerColor.BLUE, testPiece.getColor());
    assertEquals(HantoPieceType.BUTTERFLY, testPiece.getType());
  }
 @Test
 public void bluePlacesButterflyFirst() throws HantoException {
   final MoveResult mr = testGame.makeMove(BUTTERFLY, null, makeCoordinate(0, 0));
   assertEquals(OK, mr);
   final HantoPiece piece = testGame.getPieceAt(makeCoordinate(0, 0));
   assertEquals(BLUE, piece.getColor());
   assertEquals(BUTTERFLY, piece.getType());
 }
 @Test
 public void moveButterfly() throws HantoException {
   testGame.makeMove(BUTTERFLY, null, makeCoordinate(0, 0));
   testGame.makeMove(BUTTERFLY, null, makeCoordinate(0, 1));
   assertEquals(OK, testGame.makeMove(BUTTERFLY, makeCoordinate(0, 0), makeCoordinate(1, 0)));
   final HantoPiece piece = testGame.getPieceAt(makeCoordinate(1, 0));
   assertEquals(BLUE, piece.getColor());
   assertEquals(BUTTERFLY, piece.getType());
   assertNull(testGame.getPieceAt(makeCoordinate(0, 0)));
 }
 @Test
 public void blueMovesSparrow() throws HantoException {
   testGame.makeMove(BUTTERFLY, null, makeCoordinate(0, 0));
   testGame.makeMove(BUTTERFLY, null, makeCoordinate(0, 1));
   testGame.makeMove(SPARROW, null, makeCoordinate(0, -1));
   testGame.makeMove(SPARROW, null, makeCoordinate(0, 2));
   final MoveResult mr = testGame.makeMove(SPARROW, makeCoordinate(0, -1), makeCoordinate(-1, 0));
   assertEquals(OK, mr);
   final HantoPiece piece = testGame.getPieceAt(makeCoordinate(-1, 0));
   assertEquals(BLUE, piece.getColor());
   assertEquals(SPARROW, piece.getType());
 }
예제 #6
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());
 }
 @Test
 public void blueMovesSparrowUsingTestGame() throws HantoException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0),
         plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, 0, -1),
         plPair(RED, SPARROW, 0, 2)
       };
   testGame.initializeBoard(board);
   testGame.setPlayerMoving(BLUE);
   testGame.setTurnNumber(3);
   final MoveResult mr = testGame.makeMove(SPARROW, makeCoordinate(0, -1), makeCoordinate(-1, 0));
   assertEquals(OK, mr);
   final HantoPiece piece = testGame.getPieceAt(makeCoordinate(-1, 0));
   assertEquals(BLUE, piece.getColor());
   assertEquals(SPARROW, piece.getType());
 }