public Card(int land, int id, int z) { m_z = z; p_parentCard = null; p_childCard = null; p_ownerDeck = null; // Black or red card? if (land == (int)Card.CardLandEnum.EClubs || land == (int)Card.CardLandEnum.ESpade) m_isBlack = true; }
Card p_parentCard; // Upper / parent card #endregion Fields #region Constructors public Card(CardLandEnum land, int id, int z, ContentManager theContentManager) { m_z = z; p_parentCard = null; p_childCard = null; p_ownerDeck = null; // Black or red card? if (land == Card.CardLandEnum.EClubs || land == Card.CardLandEnum.ESpade) m_isBlack = true; this.LoadCard(land, id, theContentManager); }
/// <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; }