/// <summary> /// Create SolitaireData from Card /// </summary> /// <param name="card"></param> /// <param name="internalDeckId"></param> public void AddCardData(Card card, int internalDeckId) { m_land = (int)card.CardLand(); m_id = card.CardId(); m_isBlack = card.IsBlack(); m_isTurned = card.IsTurned(); m_internalDeckId = internalDeckId; m_z = card.m_z; }
/// <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; }
/// <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); }