/** ******************************************* Makes all cards in the pyramid not selected */ public void deselect() { if (selectedRow == -1) return; // nothing to do. Card c = pyrArray[selectedRow][selectedPos]; if (c != null) { c.setSelected(false); } // no longer selected. selectedRow = selectedPos = -1; hasChanged(); }
/** Validate MatchDiscardsAndJustDrawnMove */ public boolean valid(Solitaire theGame) { boolean validation = false; // VALIDATE: Card c1 = null, c2 = null; if (!discards.empty()) c1 = discards.peek(); if (!justDrawn.empty()) c2 = justDrawn.peek(); if ((c1 != null) && (c2 != null)) { if ((c1.getRank() + c2.getRank()) == 13) { validation = true; } } return validation; }
/** Do the MatchDiscardsAndJustDrawnMove. */ public boolean doMove(Solitaire theGame) { // VALIDATE: if (valid(theGame) == false) { return false; } // EXECUTE: discardsCard = discards.get(); drawnCard = justDrawn.get(); // these cards are no longer selected. discardsCard.setSelected(false); drawnCard.setSelected(false); wasDiscardsEmpty = discards.empty(); if (!wasDiscardsEmpty) { justDrawn.add(discards.get()); } theGame.updateScore(+2); return true; }