Exemple #1
0
  /**
   * Deals new cards to all players.
   *
   * @return boolean
   */
  public boolean dealNewCards() {
    boolean enough = checkEnoughCardsInDeck(getDeckAmountCards());

    if (enough == true) {
      player.newCards(takeFourCards());
      for (Player computer : computersPlayer) {
        computer.newCards(takeFourCards());
      }
    }
    return enough;
  }
Exemple #2
0
  /**
   * PlayerHuman sends card he want to lay on table, and computers lays cards automatically.
   *
   * @param card
   */
  public void layCards(Card card) {
    player.cardOnTable(card);
    if (table.getNumberOfCards() == 0) {
      cp.addOnePoint(0);
    }

    for (int i = 0; i < computersTable.size(); i++) {
      computersTable.get(i).cardOnTable();
      if (table.getNumberOfCards() == 0) {
        // Player has index 0
        cp.addOnePoint(i + 1);
      }
    }
  }
Exemple #3
0
  /**
   * Counts every players card scores and return false if game has ended.
   *
   * @return boolean
   */
  public boolean newRound() {
    table.removeCardsFromTable();
    cp.valueCards(0, player.getPointsCard());
    for (int i = 0; i < computersPlayer.size(); i++) {
      cp.valueCards(i + 1, computersPlayer.get(i).getPointsCard());
    }
    cp.roundEnd();
    boolean gameEnded = cp.gameEnded();

    if (gameEnded == false) {
      deck.newRound();
      dealNewCards();
    }

    if (gameEnded == false) {
      return true;
    } else {
      return false;
    }
  }
Exemple #4
0
 /**
  * Returns HumanPlayer hand
  *
  * @return ArrayList<Card>
  */
 public ArrayList<Card> showPlayerHand() {
   return player.showHand();
 }