package fivecardstud;

public class Hand {
    Card[] cards;
    int player;
    int rank;
    Card highCard;
    
    public Hand(Card[] dealt, int player){
        this.cards = deal(Status.handSize, Status.numPlayers);
        this.player = player;
    }
    
    public static Card[] deal(int toDeal, int players){
        Card[] hand;
        hand = new Card[toDeal];

        // check to see if card is already dealt
        int i = 0, j = 0;
        while (j<toDeal){
            // if card already used...iterate
            if(Deck.usedCardIndex.contains(i)){
                i++;
            // if card is unused, use it, add to used list, iterate all
            } else {
                Deck.usedCardIndex.add(i);
                hand[j] = FiveCardStud.deck.deck[i];
                i+=players;
                j++;
            }
        }
        return hand;
    }
    
    // rank hands from 0 being the worst and up to the best
    public int evaluate(){
        this.highCard = this.cards[0];
        String[] suits;
        int[] values;
        
        suits = new String[Status.handSize];
        values = new int[Status.handSize];
        
        // create array of suits and array of values for comparrisons in ranking
        for (int i=0; i<Status.handSize; i++){
            suits[i] = this.cards[i].suit;
            values[i] = this.cards[i].value;
        }
        
        // find high card in cards
        for (Card card: this.cards) {
            if (card.value > this.highCard.value) this.highCard = card;
        }
        
        return this.rank;
    }
}

@@ -54,16 +54,97 @@
  cards;%0A
+    Card highCard;%0A    String handName;%0A    String%5B%5D suits;%0A    String suitTemp;%0A
     int 
@@ -165,38 +165,42 @@
 t rank;%0A    
-Card highCard;
+int%5B%5D values;%0A%0A%0A%0A%0A
 %0A    %0A    pu
@@ -325,24 +325,122 @@
 r = player;%0A
+        this.suits = new String%5BStatus.handSize%5D;%0A        this.values = new int%5BStatus.handSize%5D;%0A
     %7D%0A    %0A 
@@ -1067,124 +1067,246 @@
     
-// rank hands from 0 being the worst and up to the best%0A    public int evaluate()%7B%0A        this.highCard = this.card
+private boolean getHighCard()%7B%0A        for (Card card: this.cards) %7B%0A            if (card.value %3E this.highCard.value) this.highCard = card;%0A        %7D%0A        return false;%0A    %7D%0A %0A    private boolean checkFlush()%7B%0A        suitTemp = suit
 s%5B0%5D
@@ -1319,45 +1319,75 @@
     
+for (
 String
-%5B%5D suits;%0A        int%5B%5D values;
+ suit: suits) %7B%0A            if (suitTemp.equals(suit)) %7B
 %0A   
@@ -1383,33 +1383,32 @@
 uit)) %7B%0A        
-%0A
         suits = 
@@ -1407,92 +1407,214 @@
 suit
-s = new String%5BStatus.handSize%5D
+Temp = suit;%0A            %7D else %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true
 ;%0A    
+%7D%0A
     
-values = new int%5BStatus.handSize%5D;%0A        
+%0A    // rank hands from 0 being the worst and up to the best%0A    public int evaluate()%7B
 %0A   
@@ -1840,181 +1840,8 @@
   %7D%0A
-        %0A        // find high card in cards%0A        for (Card card: this.cards) %7B%0A            if (card.value %3E this.highCard.value) this.highCard = card;%0A        %7D%0A        %0A
     

check flush and get high card are set out as functions now