/// <summary> /// Prepare the round /// will /// 1. Create a deck of playcards based on the number of decks per round /// 2. shuffle the cards /// 3. deal each player the cards per round /// 4. finally add the top most to the discard pile /// </summary> /// <param name="round"></param> public void Initialize(Object round) { // set the current round this.currentRound = (Rounds)round; // create a deck of cards based on the round // by casting the current round to integer gives us the // place value so we can calculate how many decks of cards to have this.playCards = new DeckCards( this.numberOfDecks[(int)this.currentRound]); // shuffle the deck this.playCards.Shuffle(); // deal X cards to each player // where X is the place value on cards per round for (var index = 0; index < this.cardPerRoundPerPlayer[(int)this.currentRound]; index++) { for (var playerIndex = 0; playerIndex < this.playerList.Count; playerIndex++) { // get the next card of the deck and assing to each player // TODO: think of a way to change the start player // on a 2nd tought, shouldn't matter much this.playersCards[playerIndex].AddCard( this.playCards.GetNext()); } } // add the next card to the discard this.discardPile.Push(this.playCards.GetNext()); }
/// <summary> /// Sample program for test (for now) /// </summary> /// <param name="args"></param> static void Main(string[] args) { // Create a deck of cards (52) DeckCards myDeck = new DeckCards(1); // create a discard deck :) DeckCards discardDeck = new DeckCards(); // shuffle the initial deck myDeck.Shuffle(); Card nextCard = null; int counter = 1; do { // get the topmost card and add to the discard deck nextCard = myDeck.GetNext(); if (nextCard != null) { discardDeck.AddCard(nextCard); // display Console.WriteLine("{0}, Card: Value: {1}, Suite: {2}", counter++, nextCard.Value, nextCard.Suit); } } while (nextCard != null); Console.WriteLine("done"); // shuffle the discard deck discardDeck.Shuffle(); do { nextCard = discardDeck.GetNext(); if (nextCard != null) { // display Console.WriteLine("{0}, Card: Value: {1}, Suite: {2}", counter++, nextCard.Value, nextCard.Suit); } } while (nextCard != null); Console.WriteLine("done"); // test the Interface and enumerator ICardDeck foo = discardDeck; Console.WriteLine("done"); foreach (Card card in foo) { Console.WriteLine(" Card: Value: {0}, Suite: {1}", card.Value, card.Suit); } }