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.

Game.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.interfaces;
  8. import com.md87.cardgame.Deck;
  9. import com.md87.cardgame.Player;
  10. import java.util.List;
  11. /**
  12. * Defines a standard interface for games.
  13. *
  14. * @author Chris
  15. */
  16. public interface Game {
  17. /**
  18. * Starts a new tournament.
  19. */
  20. void startTournament();
  21. /**
  22. * Returns the current total size of the pot.
  23. *
  24. * @return The size of the pot
  25. */
  26. int getCurrentPot();
  27. /**
  28. * Returns the number of hole cards generally used by this game.
  29. *
  30. * @return The usual number of hole cards
  31. */
  32. int holeCardCount();
  33. /**
  34. * Returns the player who currently holds the dealer token.
  35. *
  36. * @return The current dealer
  37. */
  38. Player getDealer();
  39. /**
  40. * Returns the (visible) community cards.
  41. *
  42. * @return The community cards
  43. */
  44. Deck getCommunityCards();
  45. /**
  46. * Retrieves the size of the big blind for this game.
  47. *
  48. * @return The size of the big blind
  49. */
  50. int getBigBlind();
  51. /**
  52. * Retrieves the size of the maximum bet that has been placed.
  53. *
  54. * @return The maximum bet
  55. */
  56. int getMaxBet();
  57. /**
  58. * Retrieves a list of players that are part of this game.
  59. *
  60. * @return A list of players participating in the game
  61. */
  62. List<Player> getPlayers();
  63. /**
  64. * Adds a new player to this game.
  65. *
  66. * @param name The name of the player that's being added
  67. * @param cash The amount of cash the player has
  68. * @param controller The controller for the player
  69. */
  70. void addPlayer(String name, int cash, PlayerController controller);
  71. /**
  72. * Adds a new player to this game.
  73. *
  74. * @param player The player to be added
  75. */
  76. void addPlayer(Player player);
  77. /**
  78. * Retrieves the total number of players in this game.
  79. *
  80. * @return The number of players in this game
  81. */
  82. int getNumPlayers();
  83. /**
  84. * Retrieves the best possible deck made up of the community cards and
  85. * some of the specified hole cards, if applicable.
  86. *
  87. * @param cards The hole cards to be used
  88. * @return The best possible deck made up of the hole and community cards
  89. */
  90. Deck getBestDeck(final Deck cards);
  91. /**
  92. * Determines if this game has an active, local, human player.
  93. *
  94. * @return True if the game has an active, local, human player.
  95. */
  96. boolean hasActiveHuman();
  97. /**
  98. * Retrieves a hand for the specified deck.
  99. *
  100. * @param deck The deck to be used for the hand
  101. * @return A hand containing the cards in the specified deck
  102. */
  103. Hand getHand(final Deck deck);
  104. /**
  105. * Retrieve the text to display for the specified player's hand(s).
  106. *
  107. * @param player The player whose text should be determined
  108. * @return A textual description of the player's hand(s).
  109. */
  110. String getHandText(final Player player);
  111. /**
  112. * Registers a new game observer for this game.
  113. *
  114. * @param observer The game observer to be registered
  115. */
  116. void registerObserver(GameObserver observer);
  117. /**
  118. * Unregisters a game observer for this game.
  119. *
  120. * @param observer The game observer to be unregistered
  121. */
  122. void unregisterObserver(GameObserver observer);
  123. }