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.

FiveCardDraw.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.Deck;
  9. import com.md87.cardgame.Player;
  10. /**
  11. * Implements a standard (local) Five Card Draw game.
  12. *
  13. * @author chris
  14. */
  15. public class FiveCardDraw extends AbstractGame {
  16. public FiveCardDraw(int numplayers, int bigblind, int ante, int raises) {
  17. super(numplayers, bigblind, ante, raises);
  18. }
  19. @Override
  20. protected void startGame() {
  21. notifyNewGame();
  22. discardCards();
  23. shuffle();
  24. doAntes();
  25. doBlinds();
  26. for (int i = 0; i < 5; i++) {
  27. dealCard(players.get((dealer + 1) % numplayers), false);
  28. }
  29. waitForBets();
  30. if (countPlayers(true, true, false) > 1) {
  31. doDrawRound(players.get((dealer + 1) % numplayers), 0, 5, true);
  32. doBettingRound();
  33. }
  34. if (countPlayers(true, true, false) > 1) {
  35. doShowDown();
  36. } else {
  37. doWinner();
  38. }
  39. for (Player player : players) {
  40. if (player.getCash() <= 0) {
  41. player.setOut();
  42. }
  43. }
  44. notifyEndGame();
  45. doDealerAdvance();
  46. }
  47. @Override
  48. protected boolean canDoBringIns() {
  49. return false;
  50. }
  51. @Override
  52. public int holeCardCount() {
  53. return 5;
  54. }
  55. @Override
  56. public Deck getCommunityCards() {
  57. return new Deck();
  58. }
  59. }