|
@@ -116,6 +116,8 @@ public class Dealer {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
+ player.Calc();
|
|
|
+
|
|
|
PrintCard(player.cards);
|
|
|
|
|
|
if (!isRoyalFlush(player.cards, player)) {
|
|
@@ -127,7 +129,8 @@ public class Dealer {
|
|
|
if (!isThreeOfAKind(player.cards, player)) {
|
|
|
if (!isTwoPairs(player.cards, player)) {
|
|
|
if (!isOnePair(player.cards, player)) {
|
|
|
-
|
|
|
+ player.combination.Value = player.cards[0].getDenomination();
|
|
|
+ player.combination.CurrentCombination = Combination.LIST.HIGH_CARD;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -141,23 +144,43 @@ public class Dealer {
|
|
|
System.out.println(player.getName() + " " + player.combination.Value);
|
|
|
}
|
|
|
|
|
|
- for (int k = 0; k < players.length; k++) {
|
|
|
- for (int l = 1; l < players.length; l++) {
|
|
|
- if (players[k] == players[l]) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ Sorting(players);
|
|
|
|
|
|
- if (players[k].combination.Value == players[l].combination.Value) {
|
|
|
- for (int x = 0; x < 7; x++) {
|
|
|
- if (players[k].cards[x].getDenomination() > players[l].cards[x].getDenomination()) {
|
|
|
+ Player pWin;
|
|
|
|
|
|
- }
|
|
|
+ int count = 0;
|
|
|
+ if (players[0].combination.Value == players[1].combination.Value) {
|
|
|
+ int value = players[0].combination.Value;
|
|
|
+ count++;
|
|
|
+ for (int q = 2; q < players.length - 1; q++) {
|
|
|
+ if (players[q].combination.Value == players[q + 1].combination.Value) {
|
|
|
+ if (value == players[q].combination.Value) {
|
|
|
+ count++;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+
|
|
|
+ Player[] winPlayers = new Player[count + 1];
|
|
|
+ for (int wp = 0; wp <= count; wp++) {
|
|
|
+ winPlayers[wp] = players[wp];
|
|
|
+ }
|
|
|
+
|
|
|
+ SortingBySum(winPlayers);
|
|
|
+
|
|
|
+ pWin = winPlayers[0];
|
|
|
+ } else {
|
|
|
+ pWin = players[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("Игрок " + pWin.getName() + " выйграл");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public void PrintCard(Card[] cards) {
|
|
|
for (Card card : cards) {
|
|
|
System.out.print(
|
|
@@ -188,6 +211,30 @@ public class Dealer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void Sorting(Player[] players) {
|
|
|
+ for (int i = 0; i < players.length; i++) {
|
|
|
+ for (int j = 0; j < players.length - 1; j++) {
|
|
|
+ if (players[j].combination.Value < players[j + 1].combination.Value) {
|
|
|
+ Player temp = players[j];
|
|
|
+ players[j] = players[j + 1];
|
|
|
+ players[j + 1] = temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SortingBySum(Player[] players) {
|
|
|
+ for (int i = 0; i < players.length; i++) {
|
|
|
+ for (int j = 0; j < players.length - 1; j++) {
|
|
|
+ if (players[j].SumDenomination < players[j + 1].SumDenomination) {
|
|
|
+ Player temp = players[j];
|
|
|
+ players[j] = players[j + 1];
|
|
|
+ players[j + 1] = temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* Проверяет есть ли в переданном массиве комбинация Стрит
|
|
|
*
|
|
@@ -224,7 +271,8 @@ public class Dealer {
|
|
|
|
|
|
|
|
|
* Стрит-флеш
|
|
|
- * @param cards массив карт игрока и на столе отсортированных по номиналу
|
|
|
+ *
|
|
|
+ * @param cards массив карт игрока и на столе отсортированных по номиналу
|
|
|
* @param player экземпляр игрока
|
|
|
*/
|
|
|
public boolean isStraightFlush(Card[] cards, Player player) {
|
|
@@ -261,7 +309,8 @@ public class Dealer {
|
|
|
|
|
|
|
|
|
* Каре (четыре одного вида)
|
|
|
- * @param cards массив карт игрока и на столе отсортированных по номиналу
|
|
|
+ *
|
|
|
+ * @param cards массив карт игрока и на столе отсортированных по номиналу
|
|
|
* @param player экземпляр игрока
|
|
|
*/
|
|
|
public boolean isFourOfAKind(Card[] cards, Player player) {
|
|
@@ -347,9 +396,7 @@ public class Dealer {
|
|
|
}
|
|
|
|
|
|
|
|
|
- *
|
|
|
* !!! ДОРАБОТАТЬ !!!
|
|
|
- *
|
|
|
*/
|
|
|
public boolean isFlush(Card[] cards, Player player) {
|
|
|
int CountHearts = 0;
|