Exemplo n.º 1
0
        /// <summary>
        /// Solitaire game logic -check
        /// </summary>
        /// <param name="c"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        private bool isAcceptedMove(Card c, Deck to)
        {
            // Accept card moves only to type 1 and 2 decks
            if (to.Type() != Deck.DeckType.EUserDeck && to.Type() != Deck.DeckType.ETargetDeck)
            {
                return(false);
            }

            if (to.CardCount() > 0)
            {
                // Moving top of card
                Card toOnCard = to.GetLast();

                // Moving cards between card decks
                if (toOnCard.OwnerDeck.Type() == Deck.DeckType.EUserDeck)
                {
                    // Card decks must differ
                    if (c.OwnerDeck == toOnCard.OwnerDeck)
                    {
                        return(false);
                    }
                    // Card can be top of one step greater card and different color
                    // Card can not be same color
                    if (c.CardLand() == toOnCard.CardLand() || toOnCard.CardId() != c.CardId() + 1 || c.IsBlack() == toOnCard.IsBlack())
                    {
                        return(false);
                    }
                }
                else if (toOnCard.OwnerDeck.Type() == Deck.DeckType.ETargetDeck)
                {
                    // Cards must be in ascending order and same suite in 2 target deck
                    if (toOnCard.CardId() + 1 != c.CardId() || toOnCard.CardLand() != c.CardLand())
                    {
                        return(false);
                    }
                }
            }
            else
            {
                // Moving top of empty deck

                // If there is no cards in the deck, then the first one must be King card in source decks 1
                if (to.CardCount() == 0 && c.CardId() != 13 && to.Type() == Deck.DeckType.EUserDeck)
                {
                    return(false);
                }

                // Ace card must be the first card in foundation
                if (to.Type() == Deck.DeckType.ETargetDeck && to.CardCount() == 0 && c.CardId() != 1)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add Deck list into SolitaireDataList for tombstoning
 /// </summary>
 /// <param name="fromDeckList"></param>
 public void AddDeckData(List <Deck> fromDeckList)
 {
     for (int i = 0; i < fromDeckList.Count(); i++)
     {
         Deck deck = fromDeckList[i];
         for (int j = 0; j < deck.CardCount(); j++)
         {
             Card          card = deck.GetCard(j);
             SolitaireData data = new SolitaireData();
             data.AddCardData(card, deck.InternalDeckId());
             m_list.Add(data);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Solitaire game logic -check
        /// </summary>
        /// <param name="c"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        private bool isAcceptedMove(Card c, Deck to)
        {
            // Accept card moves only to type 1 and 2 decks
            if (to.Type() != Deck.DeckType.EUserDeck && to.Type() != Deck.DeckType.ETargetDeck)
                return false;

            if (to.CardCount() > 0)
            {
                // Moving top of card
                Card toOnCard = to.GetLast();

                // Moving cards between card decks
                if (toOnCard.OwnerDeck.Type() == Deck.DeckType.EUserDeck)
                {
                    // Card decks must differ
                    if (c.OwnerDeck == toOnCard.OwnerDeck)
                        return false;
                    // Card can be top of one step greater card and different color
                    // Card can not be same color
                    if (c.CardLand() == toOnCard.CardLand() || toOnCard.CardId() != c.CardId() + 1 || c.IsBlack() == toOnCard.IsBlack())
                        return false;
                }
                else if (toOnCard.OwnerDeck.Type() == Deck.DeckType.ETargetDeck)
                {
                    // Cards must be in ascending order and same suite in 2 target deck
                    if (toOnCard.CardId() + 1 != c.CardId() || toOnCard.CardLand() != c.CardLand())
                        return false;
                }
            }
            else
            {
                // Moving top of empty deck

                // If there is no cards in the deck, then the first one must be King card in source decks 1
                if (to.CardCount() == 0 && c.CardId() != 13 && to.Type() == Deck.DeckType.EUserDeck)
                    return false;

                // Ace card must be the first card in foundation
                if (to.Type() == Deck.DeckType.ETargetDeck && to.CardCount() == 0 && c.CardId() != 1)
                    return false;

            }
            return true;
        }