package fivecardstud;

public class Hand {
    Card[] cards;
    Card highCard;
    String handName;
    String[] suits;
    String suitTemp;
    int player;
    int rank;
    int valueTemp;
    int[] values;





    
    public Hand(Card[] dealt, int player){
        this.cards = deal(Status.handSize, Status.numPlayers);
        this.player = player;
        this.suits = new String[Status.handSize];
        this.values = new int[Status.handSize];
    }
    
    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;
    }
    
    private boolean getHighCard(){
        for (Card card: this.cards) {
            if (card.value > this.highCard.value) this.highCard = card;
        }
        return false;
    }
 
    private boolean checkFlush(){
        suitTemp = suits[0];
        for (String suit: suits) {
            if (suitTemp.equals(suit)) {
                suitTemp = suit;
            } else {
                return false;
            }
        }
        return true;
    }
    
    private boolean checkStrait(){
        valueTemp = values[0];
        for (int value: values) {
            if (valueTemp == value) {
                valueTemp = value;
            } else {
                return false;
            }
        }
        return true;
    }
    
    // rank hands from 0 being the worst and up to the best
    public int evaluate(){
        // 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;
        }
        return this.rank;
    }
}

@@ -14,16 +14,41 @@
 ardstud;
+%0Aimport java.util.Arrays;
 %0A%0Apublic
@@ -227,21 +227,16 @@
 values;%0A
-%0A%0A%0A%0A%0A
     %0A   
@@ -462,24 +462,302 @@
 .handSize%5D;%0A
+        %0A        // create array of suits and array of values for comparrisons in ranking%0A        for (int i=0; i%3CStatus.handSize; i++)%7B%0A            this.suits%5Bi%5D = this.cards%5Bi%5D.suit;%0A            this.values%5Bi%5D = this.cards%5Bi%5D.value;%0A        %7D%0A        Arrays.sort(this.suits);%0A
     %7D%0A    %0A 
@@ -1610,24 +1610,29 @@
  suitTemp = 
+this.
 suits%5B0%5D;%0A  
@@ -1655,16 +1655,21 @@
 g suit: 
+this.
 suits) %7B
@@ -1901,24 +1901,29 @@
 valueTemp = 
+this.
 values%5B0%5D;%0A 
@@ -1945,16 +1945,21 @@
  value: 
+this.
 values) 
@@ -2231,233 +2231,8 @@
 ()%7B%0A
-        // create array of suits and array of values for comparrisons in ranking%0A        for (int i=0; i%3CStatus.handSize; i++)%7B%0A            suits%5Bi%5D = this.cards%5Bi%5D.suit;%0A            values%5Bi%5D = this.cards%5Bi%5D.value;%0A        %7D
 %0A   

move suits and values to hand constructor