Package vrampal.connectfour.core

Examples of vrampal.connectfour.core.Player


    verify(session).setAttribute(eq(SESSION_GAME_KEY), anyObject());
  }

  @Test
  public void testPageBeginPlayingGame() {
    Player currentPlayer = mock(Player.class);
    when(currentPlayer.getName()).thenReturn("Test current player");
    when(game.getCurrentPlayer()).thenReturn(currentPlayer);
    when(game.getStatus()).thenReturn(GameStatus.ONGOING);
    when(req.getParameter(ConnectFourServlet.PARAM_PLAY_KEY)).thenReturn("1342");

    servlet.handleRequest(req);
View Full Code Here


    verify(req).setAttribute(ATTR_SUB_MESSAGE_KEY, "");
  }

  @Test
  public void testPageBeginVictory() {
    Player player = mock(Player.class);
    when(player.getName()).thenReturn("Test winner");
    when(game.getWinner()).thenReturn(player);
    when(game.getStatus()).thenReturn(GameStatus.FINISHED);

    servlet.handleRequest(req);
View Full Code Here

    }
  }

  @Override
  public Player getCurrentPlayer() {
    Player currentPlayer = null;
    if (status == GameStatus.ONGOING) {
      int currentPlayerIndex = turnNumber % players.size();
      currentPlayer = players.get(currentPlayerIndex);
    }
    return currentPlayer;
View Full Code Here

      String message = "dropDisc operation is not allowed in status: " + status;
      log.error(message);
      throw new ConnectFourException(message);
    }

    Player currentPlayer = getCurrentPlayer();
    int rowIdx = board.dropDisc(currentPlayer, colIdx);
    turnNumber++;

    if (LOG_STATS.isInfoEnabled()) {
      LOG_STATS.info(id + ',' + currentPlayer.getName() + ',' + colIdx +',' + rowIdx + ',' + status);
    }

    return rowIdx;
  }
View Full Code Here

    assertEquals(rowIdx, lastRawIdx);
  }

  @Then("cell $colIdx,$rowIdx is empty")
  public void thenCellEmpty(int colIdx, int rowIdx) {
    Player player = board.getCell(colIdx, rowIdx);
    assertSame(board.getEmptyPlayer(), player);
  }
View Full Code Here

    assertSame(board.getEmptyPlayer(), player);
  }

  @Then("cell $colIdx,$rowIdx is playerA")
  public void thenCellPlayerA(int colIdx, int rowIdx) {
    Player player = board.getCell(colIdx, rowIdx);
    assertSame(playerA, player);
  }
View Full Code Here

    assertSame(playerA, player);
  }

  @Then("cell $colIdx,$rowIdx is playerB")
  public void thenCellPlayerB(int colIdx, int rowIdx) {
    Player player = board.getCell(colIdx, rowIdx);
    assertSame(playerB, player);
  }
View Full Code Here

    assertTrue(string.contains(game.getId()));
  }

  @Test
  public void testBeginGetCurrentPlayer() {
    Player player0 = game.getCurrentPlayer();
    assertNull(player0);

    game.begin();

    assertEquals(GameStatus.ONGOING, game.getStatus());

    Player player1 = game.getCurrentPlayer();
    assertNotNull(player1);

    game.drawGame();

    Player player2 = game.getCurrentPlayer();
    assertNull(player2);
  }
View Full Code Here

  @Test
  public void testDropAndPlayerAlternance() {
    game.begin();

    Player player1 = game.getCurrentPlayer();
    assertNotNull(player1);

    game.dropDisc(4);

    Player player2 = game.getCurrentPlayer();
    assertNotNull(player2);
    assertNotSame(player1, player2);
  }
View Full Code Here

    assertNull(game.getWinner());
  }

  @Test
  public void testVistory() {
    Player winner = createPlayer();

    game.begin();
    game.victory(winner);

    assertEquals(GameStatus.FINISHED, game.getStatus());
View Full Code Here

TOP

Related Classes of vrampal.connectfour.core.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.