/** @return true if it played off other phases */ private boolean playOffPhases() { Player current; ArrayList<Card> potentialCards = cardsThatCanBeLaidDown(); ArrayList<Card> cardsToBeLaidDown = new ArrayList<Card>(); for (int x = 0; x < getHand().getNumberOfCards(); x++) { // get the cards that need to be added to the phases for (Card c : potentialCards) { if (c.getColor() == Color.BLACK) { if (c.getValue() == getHand().getCard(x).getValue()) cardsToBeLaidDown.add(getHand().getCard(x)); } else if (c.getColor() == getHand().getCard(x).getColor()) { cardsToBeLaidDown.add(getHand().getCard(x)); } } } for (int player = 0; player < game.getNumberOfPlayers(); player++) { // add them to the phases current = game.getPlayer(player); if (current.hasLaidDownPhase()) { for (int group = 0; group < current.getNumberOfPhaseGroups(); group++) { for (Card c : cardsToBeLaidDown) { if (bestChoice(BEST_CHOICE_AT_FIFTY) && current.getPhaseGroup(group).addCard(c)) { playOffPhases(); return true; } } } } } return false; }
/** * @return true if it is recommended to pick up a card, or false if it is recommended to draw a * card */ private boolean drawOrPickUp() { Card cardOnTopOfPile = game.getRound().getTopOfDiscardStack(); if (hasLaidDownPhase() && difficulty > 30 && bestChoice( BEST_CHOICE_AT_FIFTY)) { // pick up cards that can be played off laid down PhaseGroups for (Card c : cardsThatCanBeLaidDown()) { if (c.getColor() == cardOnTopOfPile.getColor()) { return true; } else if (c.getValue() == cardOnTopOfPile.getValue()) { return true; } } } if (difficulty > 30 && addedPointValue(cardOnTopOfPile) < currentPointValue()) { // if the card improves the score of the player's hand if (difficulty < 70) // don't continue checking if an easy player return true; group = new Groups(this, getHand(), cardOnTopOfPile); if (group.cardInCompleteGroup( cardOnTopOfPile)) // if the card would be put in a complete group return true; } return false; // if any of the tests fail, draw from the deck }