Exemplo n.º 1
0
  private List<CardMove> movesFromWorkingStacksRevealsCard(GameModelView pModel) {
    ArrayList<CardMove> moves = new ArrayList<CardMove>();
    for (StackIndex index : StackIndex.values()) {
      CardView[] stack = pModel.getStack(index);
      for (int i = 0; i < stack.length; i++) {
        if (stack[i].isVisible() && i > 0 && !stack[i - 1].isVisible()) {
          for (StackIndex index2 : StackIndex.values()) {
            if (pModel.isLegalMove(stack[i].getCard(), index2)) {
              moves.add(new CardMove(stack[i].getCard(), index2));
            }
          }
        } else if (stack[i].isVisible() && i == 0) {
          for (StackIndex index2 : StackIndex.values()) {
            // we don't want to just move a card around
            if (pModel.isLegalMove(stack[i].getCard(), index2)
                && pModel.getStack(index2).length > 0) {
              moves.add(new CardMove(stack[i].getCard(), index2));
            }
          }
        }
      }
    }

    return moves;
  }
Exemplo n.º 2
0
 private List<CardMove> movesFromDiscardPileToWorkingStacks(GameModelView pModel) {
   ArrayList<CardMove> moves = new ArrayList<CardMove>();
   if (!pModel.isEmptyDiscardPile()) {
     for (StackIndex index : StackIndex.values()) {
       if (pModel.isLegalMove(pModel.peekDiscardPile(), index)) {
         moves.add(new CardMove(pModel.peekDiscardPile(), index));
       }
     }
   }
   return moves;
 }
Exemplo n.º 3
0
 private List<CardMove> movesFromWorkingStacksToSuitStacks(GameModelView pModel) {
   ArrayList<CardMove> moves = new ArrayList<CardMove>();
   for (StackIndex index : StackIndex.values()) {
     CardView[] stack = pModel.getStack(index);
     if (stack.length > 0) {
       Card card = stack[stack.length - 1].getCard();
       for (SuitStackIndex index2 : SuitStackIndex.values()) {
         if (pModel.isLegalMove(card, index2)) {
           moves.add(new CardMove(card, index2));
           if (pModel.isEmptySuitStack(index2)) {
             break; // we take the first possible blank space
           }
         }
       }
     }
   }
   return moves;
 }