public void tryFlip(int player) { if (player == playerTurn && !isFacecardPickup()) { // flipping GamePanel.playNoiseFlip(); stackPot.addToTop(playerCards.get(player).removeTopCard()); log.finer(getPlayerName(player) + " flipped the " + Card.toString(stackPot.getTopCard())); if (Card.isFaceCard(stackPot.getTopCard())) { topFacecardOwner = player; topFacecardMaxSize = Card.getRank(stackPot.getTopCard()); switch (topFacecardMaxSize) { case Card.ACE: topFacecardMaxSize = stackPot.size() + 4; break; case Card.KING: topFacecardMaxSize = stackPot.size() + 3; break; case Card.QUEEN: topFacecardMaxSize = stackPot.size() + 2; break; case Card.JACK: topFacecardMaxSize = stackPot.size() + 1; break; default: throw new RuntimeException( "This should never happen. A face card was not an ace, king, queen, or jack."); } turnIncrement(); } else if (topFacecardOwner == -1) { // if no facecards have been played this hand turnIncrement(); } if (playerCards.get(player).isEmpty()) { log.fine(getPlayerName(player) + " is eliminated because they flipped their last card"); eliminatePlayer(player); } if (isSlap()) { AI.registerEvent(AI.TYPESLAP); } else { AI.registerEvent(AI.TYPEFLIP); } } else { // flipping out of turn if (playerCards.get(player).isEmpty()) { // flipping out of turn but have no cards log.finer( getPlayerName(player) + " tried to flip a card even though they have no cards..."); } else { // flipping out of turn so burning log.fine(getPlayerName(player) + " tried to flip a card illegally and had to burn a card"); burn(player); } } }
public void burn(int player) { CardStack playerCardStack = playerCards.get(player); if (playerCardStack.size() == 0) { JOptionPane.showMessageDialog( gamePanel, "A player with zero cards has to burn. This part of the game has not yet been coded, so they're being let off with no penalty.", "ERROR", JOptionPane.ERROR_MESSAGE); log.warning("Player with zero cards has to burn"); return; } else { stackBurn.addToTop(playerCardStack.removeTopCard()); if (playerCardStack.size() == 0 && playerTurn == player) { turnIncrement(); // if it's player's turn and they just burned their last card, it is now // the // next player's turn. AI.registerEvent(AI.TYPENOTHING); // so that if the next player is an AI, they will know its // their turn. eliminatePlayer(player); } } GamePanel.playNoiseBurn(); gamePanel.addRenderable(new RenderableImageKinetic(this, RenderableImageKinetic.BURN, player)); }