public Deck generateDeck()
{
Deck result = new Deck ();
/**
* Generate the deck here
* TODO:
* X - Random implementation first.
* - Sorted implementation based on weights.
* - ???
* - PROFIT!
*/
/**
* Doing it randomly is kinky.
* We keep picking cards until the amount of cards in the drawPile
* is that of the numberOfCards in preferences.
*
* In the future, this code will need to be refactored elsewhere
* depending on the user's preferences in sorting.
*/
/*
* This function does several things: first, it computes the sum of all the binder weights.
* Second, it randomly selects a binder based on its weight.
* Third, it randomly selects a card in the randomly selected binder.
* FINALLY, it adds the randomly chosen card into the deck for play.
* Some time later down the road, this function may need to be refactored, but for now, it appears to be working.
*
* TODO: The random weighting system seems to be off. The last deck is ignored.
* Please fix regarding that.
*/
int sum = 0;
/*
* Apply the
*/
for (int i = 0; i < loadedBinders.Count; i++)
sum += loadedBinders[i].weight;
if (sum < 0)
Debug.Log ("Cannot have a weight below 0! You suck. Nothing happens.");
else {
while (result.cardsLeft() < deckPreferences.numberOfCards) {
int randomCard = Random.Range (0, sum+1);
int i = 0;
while (randomCard > loadedBinders[i].weight) {
randomCard -= loadedBinders [i].weight;
i++;
}
Card newCard = loadedBinders [i].getCard (-1);
if (!(result.cardMatch (newCard)))
result.addCard (newCard);
}
result.shuffleDeck ();
}
return result;
}