package a6_2; import cards.*; import static cards.Card.*; import static cards.Card.Constant.*; public class Player1 { static Card [] blatt = new Card [7]; static Card [] hand = new Card[7]; static Card [] hand2 = new Card[7]; static Card[][] array = new Card [4][13]; static Card[][] cleanarray = new Card[4][13]; static int indx1,indx2,indx3,indx4,indx5; Player1( Card [] blatt) // Konstruktor { Player1.blatt = blatt; get7Cards(); } Player1() { this(blatt); } public static Card[] get7Cards() // 7 Karten erhalten { Deck stapel = new Deck(); for ( indx1=0; indx1 < blatt.length; indx1++) { blatt[indx1] = stapel.deal(); } sort7CardsInArray (blatt); return blatt; } public static Card [][] sort7CardsInArray (Card [] blatt) // 7 Karten in das Array sortieren { for ( indx1 = 0; indx1 < blatt.length; indx1++) { array[blatt[indx1].getSuit().ordinal()][blatt[indx1].getRank().ordinal()] = blatt[indx1]; } ausgaberaster(array); straightFLush( array); return array; } public static void ausgaberaster ( Card[][] array) // Ausgaberaster { for ( int zeile =0; zeile= 0; indx2--) { if ( array[indx1][indx2] != null) { hand[indx3] = array[indx1][indx2]; indx3++; if ( indx3 == 5) { if (hand[0] == array[indx1][12] && hand [4] == array[indx1][8]) { System.out.println("Royaler Flush"); break; } else { System.out.println("Straight Flush"); break; } } if ( indx3 == 4) { if ( array[indx1][12] != null) { if ( hand[3] == array[indx1][0]) { hand[indx3] = array[indx1][12]; System.out.println("Straight Flush, mit ASS"); break; } } } } else { hand = new Card[7]; indx3 = 0; } } } vierling (array); } public static void vierling (Card [][] array) { indx3 = 0; indx4 = 0; for ( indx1 = 12; indx1 >= 0; indx1--) { for ( indx2 = 0; indx2 < array.length; indx2++) { if ( array[indx2][indx1] != null) { hand[indx3] = array[indx2][indx1]; indx3++; } else indx4++; } if ( indx3 == 4) { System.out.println("Vierling"); break; } indx3 = 0; hand = new Card[7]; } fullHouse(array); } public static void fullHouse ( Card[][] array) { hand = getPairsOfCards(array,3); hand[3] = null; hand[4] = null; hand[5] = null; blatt = hand; for ( indx1 = 0; indx1 < array.length; indx1 ++) { for ( indx2 = 12; indx2 >= 0; indx2--) { cleanarray[indx1][indx2] = array[indx1][indx2]; } } if ( hand [2] != null) cleanarray = cleanTheArray(cleanarray,hand); hand2= getPairsOfCards(cleanarray,2); if ( blatt[2] != null) { if ( hand2[1] != null) { blatt[3] = hand2[0]; blatt[4] = hand2[1]; System.out.println("Fullhouse"); } } else flush(array); } public static void flush ( Card [][] array) { indx3 = 0; for ( indx1 = 0; indx1 < array.length; indx1 ++) { for ( indx2 = 12; indx2 >= 0; indx2--) { if ( array[indx1][indx2] != null) { hand[indx3] = array[indx1][indx2]; indx3++; if ( indx3 == 5) { System.out.println("Flush"); } } } hand = new Card [7]; indx3 = 0; } straight(array); } public static void straight ( Card[][] array) { indx3 = 0; indx4 = 0; for ( indx1 = 12; indx1 >= 0; indx1 --) { indx4 = 0; for ( indx2 = 0; indx2 < array.length; indx2++) { if ( array[indx2][indx1] != null) { blatt[indx3] = array[indx2][indx1]; indx3++; if ( indx3 == 5)System.out.println("straight"); if ( indx3 == 4) { if ( blatt[3] == array[indx2][0]) { if ( array[0][12] != null) { blatt[4] = array[indx2][12]; System.out.println("straight"); } if ( array[1][12] != null) { blatt[4] = array[indx2][12]; System.out.println("straight"); } if ( array[2][12] != null) { blatt[4] = array[indx2][12]; System.out.println("straight"); } if ( array[3][12] != null) { blatt[4] = array[indx2][12]; System.out.println("straight"); } } } break; } else { indx4++; if ( indx4 == 4) { blatt = new Card [7]; indx3 = 0; } } } } drilling (array); } public static void drilling (Card [][] array) { System.out.println("Drillinaadvvg"); hand = getPairsOfCards(array,3); hand[3] = null; hand[4] = null; hand[5] = null; if ( hand[2] != null) { System.out.println("Drilling"); } else onetwoPairs(array); } public static void onetwoPairs (Card [][] array) { hand = getPairsOfCards(array,2); blatt = hand; for ( indx1 = 12; indx1 >= 0; indx1--) { for ( indx2 = 0; indx2 <= 3; indx2 ++) { cleanarray[indx2][indx1] = array[indx2][indx1]; } } cleanarray = cleanTheArray(cleanarray,hand); hand2 = getPairsOfCards(cleanarray,2); if (blatt[1] != null) { if (hand2[1] != null) { blatt[2] = hand2[0]; blatt[3] = hand[1]; System.out.println("Two Pairs"); } else { System.out.println("One Pair"); } } else highestCard(array); } public static void highestCard(Card[][] array) { indx3 = 0; for ( indx1 = 12; indx1 >= 0; indx1--) { for ( indx2 = 0; indx2 <= 3; indx2 ++) { if ( array[indx2][indx1] != null) { hand[indx3] = array[indx2][indx1]; indx3++; } if (indx3 == 5) { System.out.println("Highest Card"); break; } } if (indx3 == 5)break; } } public static Card[] getPairsOfCards ( Card [][]array, int anzahlOfPairs) { indx3 = 0; for ( indx1 = 12; indx1 >= 0; indx1--) { for ( indx2 = 0; indx2 <= 3; indx2 ++) { if ( array[indx2][indx1] != null) { hand[indx3] = array[indx2][indx1]; indx3++; if ( indx3 == anzahlOfPairs)break; } } if ( indx3 == anzahlOfPairs)break; hand = new Card [7]; indx3 = 0; } // System.out.println( hand[0]); // System.out.println( hand[1]); // System.out.println( hand[2]); return hand; } public static Card[][] cleanTheArray ( Card[][] array, Card[] hand) { for ( indx1 = 12; indx1 >= 0; indx1--) { for ( indx2 = 0; indx2 <= 3; indx2 ++) { for ( indx3 = 0; indx3 < hand.length; indx3++) { if ( array[indx2][indx1] == hand[indx3]) { array[indx2][indx1] = null; } } } } // ausgaberaster(array); return array; } // public static void print5Cards(String zugabe, Card[] hand) // { // System.out.print(zugabe+ ": "); // // for ( indx1 = 0; indx1