Example #1
0
        public static DeckDrawingEventArgs Create(List <int> drawnCard)
        {
            DeckDrawingEventArgs result = ReferencePool.Acquire <DeckDrawingEventArgs>();

            result.drawnCards = drawnCard;
            return(result);
        }
Example #2
0
        private void DrawCardsFromDeck(int drawCount)
        {
            while (true)
            {
                var deckSize = deckPile.Count;
                if (deckSize >= drawCount)
                {
                    var prevDeckSize = deckSize;
                    var drawnCards   = new List <int>(drawCount);
                    for (int i = 0; i < drawCount; i++)
                    {
                        var cardId = deckPile[0];
                        deckPile.RemoveAt(0);
                        handPile.Add(cardId);
                        drawnCards.Add(cardId);
                    }

                    // handPresentatation.CreateCardInHand(drawnCards, prevDeckSize);
                    GameEntry.Event.FireNow(this, DeckDrawingEventArgs.Create(drawnCards));
                    GameEntry.Event.FireNow(this, UpdateDeckCountEventArgs.Create(prevDeckSize));
                }
                else
                {
                    deckPile.AddRange(discardPile);
                    discardPile.Clear();
                    GameEntry.Event.FireNow(this, UpdateDiscardCountEventArgs.Create(discardPile.Count));
                    // handPresentatation.UpdateDiscardPileSize(discardPile.Count);
                    if (drawCount > deckPile.Count + discardPile.Count)
                    {
                        drawCount = deckPile.Count + discardPile.Count;
                    }

                    deckPile.Shuffle();
                    continue;
                }

                break;
            }
        }
Example #3
0
        private void OpreateCards(object sender, GameEventArgs e)
        {
            DeckDrawingEventArgs ne = (DeckDrawingEventArgs)e;

            CreateCardInHand(ne.drawnCards);
        }