Java poker implementation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CrazyPineapple.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) Chris 'MD87' Smith, 2007. All rights reserved.
  3. *
  4. * This code may not be redistributed without prior permission from the
  5. * aforementioned copyright holder(s).
  6. */
  7. package com.md87.cardgame.games;
  8. import com.md87.cardgame.Player;
  9. /**
  10. * Implements a standard local game of Crazy Pineapple.
  11. *
  12. * @author chris
  13. */
  14. public class CrazyPineapple extends Pineapple {
  15. public CrazyPineapple(int numplayers, int bigblind, int ante, int raises) {
  16. super(numplayers, bigblind, ante, raises);
  17. }
  18. @Override
  19. protected void dealPlayerCards() {
  20. dealCard(players.get((dealer + 1) % numplayers), false);
  21. dealCard(players.get((dealer + 1) % numplayers), false);
  22. dealCard(players.get((dealer + 1) % numplayers), false);
  23. }
  24. @Override
  25. protected void startGame() {
  26. notifyNewGame();
  27. discardCards();
  28. shuffle();
  29. community.clear();
  30. doAntes();
  31. doBlinds();
  32. doneFlop = false;
  33. doneTurn = false;
  34. doneRiver = false;
  35. dealPlayerCards();
  36. for (int i = 0; i < 5; i++) {
  37. community.add(deck.deal());
  38. }
  39. waitForBets();
  40. if (countPlayers(true, true, false) > 1) {
  41. doneFlop = true;
  42. doDrawRound(players.get((dealer + 1) % numplayers), 1, 1, false);
  43. doBettingRound();
  44. }
  45. if (countPlayers(true, true, false) > 1) {
  46. doneTurn = true;
  47. doBettingRound();
  48. }
  49. if (countPlayers(true, true, false) > 1) {
  50. doneRiver = true;
  51. doBettingRound();
  52. }
  53. if (countPlayers(true, true, false) > 1) {
  54. doShowDown();
  55. } else {
  56. doWinner();
  57. }
  58. for (Player player : players) {
  59. if (player.getCash() <= 0) {
  60. player.setOut();
  61. }
  62. }
  63. notifyEndGame();
  64. doDealerAdvance();
  65. }
  66. }