예제 #1
0
        public void MoveCardsWithoutChecking(CardStack stackSrc, int posSrc, CardStack stackDest)
        {
            if (!stackSrc.CanPickupRun(posSrc))
            {
                Console.WriteLine("Asked to move cards that are not in a sequential run - bug?");
            }

            for (int i = posSrc; i < stackSrc.Count; i++)
            {
                Card card = stackSrc.GetCard(i);
                stackDest.Add(card);
            }
            int cardCount = stackSrc.Count - posSrc;

            stackSrc.RemoveRange(posSrc, cardCount);

            if (stackSrc.Count > 0)
            {
                Card revealed = stackSrc.GetCard(posSrc - 1);
                revealed.Reveal();
            }

            MoveCount++;
            Score -= ScorePerMove;
        }
예제 #2
0
 public void FixupStackCardViewRects(CardStack stack)
 {
     for (int c = 0; c < stack.Count; c++)
     {
         Card card = stack.GetCard(c);
         card.View.Rect = GetRectOfCardRunInStack(stack, c, 1);
     }
 }
예제 #3
0
        public void MoveCards(CardStack stackSrc, int posSrc, CardStack stackDest)
        {
            if (posSrc < 0)
            {
                return;
            }

            if (!stackSrc.CanPickupRun(posSrc))
            {
                Console.WriteLine("Asked to move cards that are not in a sequential run - bug?");
            }
            Card sourceCard = stackSrc.GetCard(posSrc);

            if (!CanMoveCardToStack(sourceCard, stackDest))
            {
                Console.WriteLine(@"Asked to move cards to an invalid location - bug?");
            }

            for (int i = posSrc; i < stackSrc.Count; i++)
            {
                Card card = stackSrc.GetCard(i);
                stackDest.Add(card);
            }
            int cardCount = stackSrc.Count - posSrc;

            stackSrc.RemoveRange(posSrc, cardCount);

            bool revealedCard = false;

            if (stackSrc.Count > 0)
            {
                Card revealed = stackSrc.GetCard(posSrc - 1);
                if (!revealed.Visible)
                {
                    revealedCard = true;
                    revealed.Reveal();
                }
            }

            MoveCount++;
            Score -= ScorePerMove;
            _undoStack.AddMoveOfCards(cardCount, stackSrc, stackDest, revealedCard);
        }