Package vrampal.connectfour.core

Examples of vrampal.connectfour.core.Player


          monitor.onError(game, e);
        }
      }
    }

    Player winner = game.getWinner();
    if (winner != null) {
      for (GameMonitor monitor : monitors) {
        monitor.onVictory(game, winner);
      }
    } else {
View Full Code Here


      }
    }
  }

  private void playOneTurn() {
    Player currentPlayer = game.getCurrentPlayer();
    String curPlayerName = currentPlayer.getName();

    int colIdx;
    if ("Yellow".equals(curPlayerName)) {
      colIdx = yellowItf.selectPlayColumn(game);
    } else if ("Red".equals(curPlayerName)) {
View Full Code Here

    }

    // Build main message
    String mainMessage = "";
    if (game.getStatus() == GameStatus.ONGOING) {
      Player player = game.getCurrentPlayer();
      mainMessage = "Now playing: " + player.getName();
    } else if (game.getStatus() == GameStatus.FINISHED) {
      Player winner = game.getWinner();
      if (winner != null) {
        mainMessage = winner.getName() + " won the game.";
      } else {
        mainMessage = "It's a draw game.";
      }
    }
View Full Code Here

  @Override
  public Player getCell(int colIdx, int rowIdx) {
    checkColIdx(colIdx);
    checkRowIdx(rowIdx);
    Player player = getCellFast(colIdx, rowIdx);
    if (player == null) {
      player = EMPTY_PLAYER;
    }
    return player;
  }
View Full Code Here

    for (int i = 0; i < NB_TOTAL_GAME; i++) {
      GameRunner gameRunner = new GameRunner(playerItf, playerItf);
      gameRunner.run();

      Game game = gameRunner.getGame();
      Player winner = game.getWinner();
      analyeWinner(winner);
    }
    long endTime = System.currentTimeMillis();

    if (log.isInfoEnabled()) {
View Full Code Here

    return rowIdx;
  }

  private void checkForGameEnd(int colIdx, int rowIdx) {
    Player player = getCellFast(colIdx, rowIdx);

    // Does the latest drop creates an horizontal line ?
    if (getHorizontalLength(colIdx, rowIdx) >= LENGTH_TO_WIN) {
      endGameListener.victory(player);
      // Does the latest drop creates a vertical line ?
View Full Code Here

  /**
   * Returns the length of the horizontal line from a given point.
   */
  private int getHorizontalLength(int colIdx, int rowIdx) {
    Player player = getCellFast(colIdx, rowIdx);

    int columnLeft = colIdx;
    while ((columnLeft > 0) && (getCellFast(columnLeft - 1, rowIdx) == player)) {
      columnLeft--;
    }
View Full Code Here

  /**
   * Returns the length of the vertical line from a given point.
   */
  private int getVerticalLength(int colIdx, int rowIdx) {
    Player player = getCellFast(colIdx, rowIdx);

    int rowDown = rowIdx;
    while ((rowDown > 0) && (getCellFast(colIdx, rowDown - 1) == player)) {
      rowDown--;
    }
View Full Code Here

  /**
   * Returns the length of a diagonal line from a given point.
   */
  private int getDiagonalLength1(int colIdx, int rowIdx) {
    Player player = getCellFast(colIdx, rowIdx);

    int columnLeft = colIdx;
    int rowDown = rowIdx;
    while ((columnLeft > 0) && (rowDown > 0) && (getCellFast(columnLeft - 1, rowDown - 1) == player)) {
      columnLeft--;
View Full Code Here

  /**
   * Returns the length of another diagonal line from a given point.
   */
  private int getDiagonalLength2(int colIdx, int rowIdx) {
    Player player = getCellFast(colIdx, rowIdx);

    int columnLeft = colIdx;
    int rowUp = rowIdx;
    while ((columnLeft > 0) && (rowUp < (getHeight() - 1)) && (getCellFast(columnLeft - 1, rowUp + 1) == player)) {
      columnLeft--;
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.