/** * Deals a new card onto the board. Removes the card it adds from the pack. Prints all the cards * on the board */ private void dealCard() { ; char aChar = 0; char bChar = 0; toggleLock = true; // Makes it so you can no longer change if the log is on or off if (cardsInDeck > 0) { // Only deals a card if there is a card to deal String card = pack.getFirtCard(); // Gets the card on top of the deck cardStrings.add(card); // Adds this card to the arraylist that the frame prints from. for (String c : cardStrings) { // For all the cards on the table aChar = c.charAt(0); bChar = c.charAt(1); StringBuilder sb = new StringBuilder(3); sb.append(aChar).append(bChar).append(" "); if (printBoard) { System.out.print(sb); // Prints the current board to the command line } } frame.cardDisplay(cardStrings); // Prints the cards to the frame System.out.println(""); Pile pile = new Pile(aChar, bChar); // Creates a new pile of the newly laid card piles.addPile(pile); // Adds it to the arrayList of current piles on board cardsInDeck--; saveLog(); // Calls the function to save the new move to the log } else { printFrame(); drawCard = false; // Tells the AI that he cannot draw a card System.out.println("No more cards in deck!"); } }
/** Prints the current state of the board */ private void printFrame() { char aChar = 0; char bChar = 0; for (String c : cardStrings) { // For all the cards on the table aChar = c.charAt(0); bChar = c.charAt(1); StringBuilder sb = new StringBuilder(3); sb.append(aChar).append(bChar).append(" "); // Create a string of form "value""suit" if (printBoard) { // If the user hasn't disabled command line updates System.out.print(sb); // Print the card } } frame.cardDisplay(cardStrings); // Prints the card to the frame System.out.println(""); }