|
@@ -0,0 +1,62 @@
|
|
|
+package com.company;
|
|
|
+
|
|
|
+import java.util.Random;
|
|
|
+
|
|
|
+public class Dealler {
|
|
|
+ private Deck deck = new Deck();
|
|
|
+ private Player []players;
|
|
|
+ private Card []table = new Card[5];
|
|
|
+ private GAME_STAGE stage = GAME_STAGE.PREFLOP;
|
|
|
+ private Random random = new Random(System.currentTimeMillis());
|
|
|
+
|
|
|
+ public Dealler(String []playerNames) throws Exception {
|
|
|
+ if (playerNames.length < 2 || playerNames.length > 10) {
|
|
|
+ throw new Exception("Некорректное количество игроков");
|
|
|
+ }
|
|
|
+ players = new Player[playerNames.length];
|
|
|
+
|
|
|
+ for (int i = 0; i < playerNames.length; i++) {
|
|
|
+ players[i] = new Player(playerNames[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void HandOut() {
|
|
|
+ switch (stage) {
|
|
|
+ case PREFLOP: {
|
|
|
+ boolean isLeftCardOnHand = false;
|
|
|
+ for (int i = 0; i < players.length; i++) {
|
|
|
+ Card currentCard = deck.Cards[random.nextInt(deck.CARD_COUNT)];
|
|
|
+ if (!isLeftCardOnHand) {
|
|
|
+ if (currentCard.isOnHand()) {
|
|
|
+ i--;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ isLeftCardOnHand = true;
|
|
|
+ players[i].setLeft(currentCard);
|
|
|
+ currentCard.setOnHand(true);
|
|
|
+ }
|
|
|
+ currentCard = deck.Cards[random.nextInt(deck.CARD_COUNT)];
|
|
|
+ if (currentCard.isOnHand()) {
|
|
|
+ i--;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ players[i].setRight(currentCard);
|
|
|
+ currentCard.setOnHand(true);
|
|
|
+ }
|
|
|
+ } break;
|
|
|
+ case FLOP: {
|
|
|
+
|
|
|
+ } break;
|
|
|
+ case TURN: {
|
|
|
+
|
|
|
+ } break;
|
|
|
+ case RIVER: {
|
|
|
+
|
|
|
+ } break;
|
|
|
+ case OPENING: {
|
|
|
+
|
|
|
+ } break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|