smithers.cards
Interface BuildingRule

All Known Implementing Classes:
AbstractBuildingRule, BuildingDownByAlternatingColours, BuildingUpBySuits

public interface BuildingRule

Implentations of this interface specify rules for building on the stack. Such constructs are common in solitaire games, where various rules apply to moving cards around the tableau, foundations, and so on.


Method Summary
 boolean canAddCard(CardStack stack, Card add)
          Determines whether the specified card can be added to the top of the stack.
 int canAddCards(CardStack stack, CardStack add)
          Determines whether cards can be moved from one stack to another.
 

Method Detail

canAddCard

boolean canAddCard(CardStack stack,
                   Card add)
Determines whether the specified card can be added to the top of the stack.

Parameters:
stack - the stack to add the card to
add - the card to add
Returns:
true iff the card can be added

canAddCards

int canAddCards(CardStack stack,
                CardStack add)
Determines whether cards can be moved from one stack to another. This method should return the smallest non-zero number of cards which can be moved (usually this will be the only number of cards which can be moved), or 0 if no cards can be moved. Note this method makes no checks according to whether the required cards can all legally be moved from the source stack, as this stack may be operating under different rules.

Parameters:
stack - the stack to move cards to
add - the stack to move cards from
Returns:
the number of cards which can be moved