package fivecardstud;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Hand {
    Card cardTemp;
    String handName;
    List<Card> cards;
    List<Card> cardsTemp;
    List<String> suits;
    List<Integer> values;
    boolean skipIter;
    int player;
    int rank;
    int valueTemp;
    
    public Hand() {
        cards = new ArrayList<>();
        cardsTemp = new ArrayList<>();
        suits = new ArrayList<>();
        values = new ArrayList<>();
    }
    
    public void deal(){
        List<Card> hand;
        hand = new ArrayList();

        for (Card card: FiveCardStud.deck.cards){
             // check to see if card is already dealt
            if(FiveCardStud.deck.usedCardIndex.contains(card)){
                continue;
            // if card is unused, use it, add to used list, iterate all
            } else {
                FiveCardStud.deck.usedCardIndex.add(card);
                hand.add(card);
            }
            if (hand.size() >= Status.handSize) break;
        }
        sortCards(hand);
    }
    
    void sortCards(List<Card> hand){
        List<Card> tempHand;
        List<Card> usedCards;
        tempHand = new ArrayList();
        usedCards = new ArrayList();
        for (Card card: hand) {
            tempHand.add(card);
        }

        // create array of suits and array of values for comparrisons in ranking
        for (Card card: hand) {
            suits.add(card.suit);
            values.add(card.value);
        }
        Collections.sort(suits);
        Collections.sort(values);

        // sort cards by value
        //////// NEED TO REDO ////////
        
        cards = cardsTemp;
        for (Card card: cards) System.out.println(card.value);
    }
    
    void show(){
        for (Card card: cards) {
            System.out.println(card.rank + " " + card.suit);
        }
    }
    
    Card getHighCard(){
        Card highCard;
        highCard = cards.get(0);
        for (Card card: cards) {
            if (card.value > highCard.value) highCard = card;
        }
        return highCard;
    }
 
    List checkFlush(){
        String suitTemp;
        suitTemp = suits.get(0);
        cardsTemp.add(cards.get(0));
        skipIter = true;
        int i = 0;
        for (String suit: suits) {
            // skip first iteration
            if (skipIter == true) {
                skipIter = false;
                continue;
            }
            i++;
            if (suitTemp.equals(suit)) {
                suitTemp = suit;
                cardsTemp.add(cards.get(i));
            }
        }
        return cardsTemp;
    }
    
    boolean checkStrait(){
        skipIter = true;
        valueTemp = values.get(0);
        for (int value: values) {
            // skip first iteration
            if (skipIter == true) {
                skipIter = false;
                continue;
            }
            valueTemp+=1;
            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(){

        return this.rank;
    }
}

@@ -192,23 +192,27 @@
 ist%3C
-Card
+String
 %3E cards
-Temp
+BySuit
 ;%0A  
@@ -222,47 +222,55 @@
 ist%3C
-String%3E suits;%0A    List%3CInteger%3E values
+Integer%3E cardsByValue;%0A    List%3CCard%3E cardsTemp
 ;%0A  
@@ -445,21 +445,27 @@
         
-s
+cardsByS
 uit
-s
  = new A
@@ -486,22 +486,28 @@
         
-v
+cardsByV
 alue
-s
  = new A
@@ -1082,707 +1082,134 @@
     
-sortCards(hand);%0A    %7D%0A    %0A    void sortCards(List%3CCard%3E hand)%7B%0A        List%3CCard%3E tempHand;%0A        List%3CCard%3E usedCards;%0A        tempHand = new ArrayList();%0A        usedCards = new ArrayList();%0A        for (Card card: hand) %7B%0A            tempHand.add(card);%0A        %7D%0A%0A        // create array of suits and array of values for comparrisons in ranking%0A        for (Card card: hand) %7B%0A            suits.add(card.suit);%0A            values.add(card.value);%0A        %7D%0A        Collections.sort(suits);%0A        Collections.sort(values);%0A%0A        // sort cards by value%0A        //////// NEED TO REDO ////////%0A        %0A        cards = cardsTemp;%0A        for (Card card: cards) System.out.println(card.value
+Collections.sort(hand, new ValueComparator());%0A        for (Card card: hand) System.out.println(card.rank + %22 of %22 + card.suit
 );%0A 
@@ -1635,21 +1635,27 @@
 tTemp = 
-s
+cardsByS
 uit
-s
 .get(0);
@@ -1766,13 +1766,19 @@
 it: 
-s
+cardsByS
 uit
-s
 ) %7B%0A
@@ -2192,22 +2192,28 @@
 eTemp = 
-v
+cardsByV
 alue
-s
 .get(0);
@@ -2241,14 +2241,20 @@
 ue: 
-v
+cardsByV
 alue
-s
 ) %7B%0A

implement suit and rank Card comparators