コード例 #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());
 }
コード例 #2
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testCheckAdjacentPieces.
  *
  * @throws HantoException
  */
 @Test(expected = HantoException.class)
 public void testCheckAdjacentPieces() throws HantoException {
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 1));
   assertTrue(beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 2)) == MoveResult.OK);
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(3, 3));
 }
コード例 #3
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method findPieceTest.
  *
  * @throws HantoException
  */
 @Test
 public void findPieceTest() throws HantoException {
   assertTrue(beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 0)) == MoveResult.OK);
   assertTrue(beta.getPieceAt(new Coordinate(0, 0)).getColor().equals(HantoPlayerColor.BLUE));
   assertTrue(beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 1)) == MoveResult.OK);
   assertTrue(beta.getPieceAt(new Coordinate(0, 1)).getColor().equals(HantoPlayerColor.RED));
 }
コード例 #4
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testBoard2.
  *
  * @throws HantoException
  */
 @Test
 public void testBoard2() throws HantoException {
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(1, -1));
   assertTrue(beta.getPrintableBoard().contains("0,0 BLUE Butterfly\n"));
   assertTrue(beta.getPrintableBoard().contains("1,-1 RED Butterfly\n"));
 }
コード例 #5
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());
 }
コード例 #6
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testButterflyPlacedByFourthMove.
  *
  * @throws HantoException
  */
 @Test(expected = HantoException.class)
 public void testButterflyPlacedByFourthMove() throws HantoException {
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 2));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 3));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 4));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 5));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 6));
 }
コード例 #7
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testGameRedWins.
  *
  * @throws HantoException
  */
 @Test
 public void testGameRedWins() throws HantoException {
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, -1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(-1, 1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(1, -1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(1, 0));
   assertTrue(
       beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(-1, 0)) == MoveResult.RED_WINS);
 }
コード例 #8
0
  @Test
  public void testRedStarts() throws HantoException {
    HantoGame game2 =
        HantoGameFactory.getInstance().makeHantoGame(HantoGameID.BETA_HANTO, HantoPlayerColor.RED);
    MoveResult result =
        game2.makeMove(HantoPieceType.SPARROW, null, new ConcreteHantoCoordinate(0, 0));
    assertEquals(MoveResult.OK, result);

    result = game2.makeMove(HantoPieceType.SPARROW, null, new ConcreteHantoCoordinate(1, 0));
    assertEquals(MoveResult.OK, result);
  }
コード例 #9
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method butterflyIsPlacedByFourthMoveOfPlayer2.
  *
  * @throws HantoException
  */
 @Test
 public void butterflyIsPlacedByFourthMoveOfPlayer2() throws HantoException {
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 2));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 3));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 4));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 5));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 6));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 7));
 }
コード例 #10
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));
 }
コード例 #11
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());
 }
コード例 #12
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));
 }
コード例 #13
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)));
  }
コード例 #14
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));
 }
コード例 #15
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testFullGameToDraw.
  *
  * @throws HantoException
  */
 @Test
 public void testFullGameToDraw() throws HantoException {
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 1));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 2));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 3));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 4));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 5));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 6));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 7));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 8));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 9));
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 10));
   assertTrue(
       beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 11)) == MoveResult.DRAW);
 }
コード例 #16
0
 @Test
 public void createDeltaHantoGame() throws HantoException {
   HantoGame game = HantoGameFactory.getInstance().makeHantoGame(HantoGameID.DELTA_HANTO);
   game.makeMove(HantoPieceType.BUTTERFLY, null, coord(0, 0));
 }
コード例 #17
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testMoveOntoAnotherPiece.
  *
  * @throws HantoException
  */
 @Test(expected = HantoException.class)
 public void testMoveOntoAnotherPiece() throws HantoException {
   assertTrue(beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 0)) == MoveResult.OK);
   assertTrue(beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 1)) == MoveResult.OK);
   beta.makeMove(HantoPieceType.SPARROW, null, new Coordinate(0, 0));
 }
コード例 #18
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));
 }
コード例 #19
0
ファイル: BetaGameTest.java プロジェクト: janouna/Hanto
 /**
  * Method testThatPlayerCannotPlaceMultipleButterflies.
  *
  * @throws HantoException
  */
 @Test(expected = HantoException.class)
 public void testThatPlayerCannotPlaceMultipleButterflies() throws HantoException {
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 0));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 1));
   beta.makeMove(HantoPieceType.BUTTERFLY, null, new Coordinate(0, 2));
 }
コード例 #20
0
 @Test(expected = HantoException.class)
 public void attemptToUsePieceNotInGame()
     throws HantoException, HantoPrematureResignationException {
   game.makeMove(CRANE, null, makeCoordinate(0, 0));
 }