Your Name %!s(int64=3) %!d(string=hai) anos
pai
achega
759f3d6044
Modificáronse 2 ficheiros con 33 adicións e 35 borrados
  1. 28 21
      src/com/company/Dealer.java
  2. 5 14
      src/com/company/Player.java

+ 28 - 21
src/com/company/Dealer.java

@@ -43,8 +43,8 @@ public class Dealer {
 
                     card1.onHands = true;
                     card2.onHands = true;
-                    players[i].setCards(Player.CARD_SLOT.FIRST, card1);
-                    players[i].setCards(Player.CARD_SLOT.SECOND, card2);
+                    players[i].setCards(0, card1);
+                    players[i].setCards(1, card2);
                 }
                 currentRateType = RATE_TYPE.FLOP;
             }
@@ -92,40 +92,41 @@ public class Dealer {
 
     // ♦♣♥♠
     public void OpeningCard() {
+        int slot = 2;
         System.out.println("Карты на столе ");
         for (Card card : table) {
             System.out.print(
                     deck.CardName.get(card.getDenomination())
                             + Lear.SYMBOL[card.Lear.ordinal()] + " ");
+
+            for (Player p : players) {
+                p.setCards(slot, card);
+            }
+
+            slot++;
         }
+
         System.out.println("\n\nКарты игроков");
 
         for (Player player : players) {
-            Card[] sharedCards = new Card[7];
-            int i = 0;
-            for (; i < table.length; i++) {
-                sharedCards[i] = table[i];
-            }
-            sharedCards[i++] = player.getCards(Player.CARD_SLOT.FIRST);
-            sharedCards[i] = player.getCards(Player.CARD_SLOT.SECOND);
 
             try {
-                Sorting(sharedCards);
+                Sorting(player.cards);
             } catch (Exception e) {
                 e.printStackTrace();
             }
 
-            PrintCard(sharedCards);
+            PrintCard(player.cards);
 
-            if (!isRoyalFlush(sharedCards, player)) {
-                if (!isStraightFlush(sharedCards, player)) {
-                    if (!isFourOfAKind(sharedCards, player)) {
-                        if (!isFullHouse(sharedCards, player)) {
-                            if (!isFlush(sharedCards, player)) {
-                                if (!isStraight(sharedCards, player)) {
-                                    if (!isThreeOfAKind(sharedCards, player)) {
-                                        if (!isTwoPairs(sharedCards, player)) {
-                                            if (!isOnePair(sharedCards, player)) {
+            if (!isRoyalFlush(player.cards, player)) {
+                if (!isStraightFlush(player.cards, player)) {
+                    if (!isFourOfAKind(player.cards, player)) {
+                        if (!isFullHouse(player.cards, player)) {
+                            if (!isFlush(player.cards, player)) {
+                                if (!isStraight(player.cards, player)) {
+                                    if (!isThreeOfAKind(player.cards, player)) {
+                                        if (!isTwoPairs(player.cards, player)) {
+                                            if (!isOnePair(player.cards, player)) {
 
                                             }
                                         }
@@ -142,9 +143,15 @@ public class Dealer {
 
         for (int k = 0; k < players.length; k++) {
             for (int l = 1; l < players.length; l++) {
+                if (players[k] == players[l]) {
+                    continue;
+                }
+
                 if (players[k].combination.Value == players[l].combination.Value) {
-                    for (Card card : sharedCards) {
+                    for (int x = 0; x < 7; x++) {
+                        if (players[k].cards[x].getDenomination() > players[l].cards[x].getDenomination()) {
 
+                        }
                     }
                 }
             }

+ 5 - 14
src/com/company/Player.java

@@ -6,7 +6,7 @@ package com.company;
  * Игрок
  */
 public class Player {
-    private final Card[] cards = new Card[7];
+    public final Card[] cards = new Card[7];
     private String name;
     public Combination combination;
 
@@ -24,21 +24,12 @@ public class Player {
      * @param slot
      * @param card
      */
-    public void setCards(CARD_SLOT slot, Card card) {
-        cards[slot.ordinal()] = card;
+    public void setCards(int slot, Card card) {
+        cards[slot] = card;
     }
 
-    public Card getCards(CARD_SLOT slot) {
-        return cards[slot.ordinal()];
+    public Card getCards(int slot) {
+        return cards[slot];
     }
 
-    /**
-     * Перечисление карт игрока.
-     * FIRST - первая карта (или 0)
-     * SECOND - вторая карта (или 1)
-     */
-    public enum CARD_SLOT {
-        FIRST,
-        SECOND,
-    }
 }