/*
 * Created on Nov 22, 2004
 *
 * Utilizes Java Power Tools (JPT)
 * http://www.ccs.neu.edu/jpt/
 * 
 */

/**
 *Authored by Brandon Schory
 *
 *With help, inspiration, and code from Richard Rasala
 *
 */

import java.awt.*;

public class Deck {

    //Deck Variable Declarations
	static Image[] Images;
	String[] names;
	Card[] deck;
	
	/** Constructs a standard 52 card deck*/
	public Deck() {
		
	    //Deck Variable Definitions
	    /** Gets the images of the cards*/
	    Images = images.getImages();
	    /** String array of possible names for any card*/ 
	    names = new String[] {"One of", "Two of", "Three of", "Four of", "Five of",
		        "Six of", "Seven of", "Eight of", "Nine of", "Ten of", "Jack of", "Queen of", "King of", "Ace of"};
		deck = new Card[52];
		
		/** Generates deck*/
		for(int i = 0; i < 13; i++){
		    	deck[i] = new Card(names[i].concat(" Diamonds"), value(i), Deck.Images[i]);
		    	deck[i+13] = new Card(names[i].concat(" Hearts"), value(i), Deck.Images[i + 13]);
		    	deck[i+26] = new Card(names[i].concat(" Spades"), value(i), Deck.Images[i + 26]);
		    	deck[i+39] = new Card(names[i].concat(" Clubs"), value(i), Images[i + 39]); 
		}
	}
	
	/** Determines the value of the card */
	public int value(int i){
	    if(i < 9){return i+2;}
	    else if(9 <= i && i < 12){return 10;}
	    else{return 11;}
	}

	/** Created a shuffled array of integers, which will be used to draw 
	  * random, unrepeated cards from the deck.	 
	  */
	public static int[] shuffle() {
    		int[] gamedeck = ProbStatTools.integerSequence(52);
    		gamedeck = ProbStatTools.randomPermutation(gamedeck);
    		return gamedeck;
    }
}

