Ejemplo n.º 1
0
		public override bool AddCard( Card c )
		{
			// If we're dealing 3 cards, we shift
			// the cards to the right so that each
			// deal will be shown:
			return base.AddCard( c );
		}
Ejemplo n.º 2
0
		protected bool CanAddCard( Card c )
		{
			// The behaviour is different if there are no cards
			// yet in our pile:
			if ( this.Count == 0 )
			{
				// In this case we accept any suit,
				// and the first card (Ace) in that suit:
				return ( c.Rank == 1 );
			}
			else
			{
				// Already some cards in our pile, we therefore only 
				// accept cards of the same suit and where the first
				// card in the collection of cards to be added has
				// one higher rank than the topmost card in our pile:
				if ( c.Suit == m_cards[ 0 ].Suit 
					&& c.Rank == m_cards[ m_cards.Count - 1 ].Rank + 1 )
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// TODO: document
		/// </summary>
		/// <param name="c"></param>
		/// <returns></returns>
		public override bool AddCard( Card c )
		{
			if ( this.CanAddCard( c ) )
			{
				base.InternalAddCard( c );
				return true;
			}

			return false;
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Constructor. Creates all the cards and stores them. Cards are initially
		/// created face down. Accepts an (optional) ImageManager.
		/// </summary>
		public Deck( ImageManager imgMgr )
		{
			// Create a default image manager if none is provided:
			if ( imgMgr == null )
			{
				imgMgr = new ImageManager( );
			}
			m_imgMgr = imgMgr;

			// Create all 52 cards:
			Suit[] arrSuits = { Suit.Hearts, Suit.Spades, Suit.Diamonds, Suit.Clubs };
			foreach ( Suit s in arrSuits )
			{
				for ( int i = 1; i <= 13; i++ )
				{
					Card c = new Card( s, i, false, this );

					m_cards.Add( c );
				}
			}
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Returns true if the color of the current card is the opposite
		/// color of the other card. Red and black are considered opposite
		/// colors in this regard.
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public bool IsOppositeColor( Card other )
		{
			return ( this.IsBlack( ) && other.IsRed( ) )
				|| ( this.IsRed( ) && other.IsBlack( ) );
		}
Ejemplo n.º 6
0
		/// <summary>
		/// We don't support adding cards back:
		/// </summary>
		/// <param name="c"></param>
		/// <returns></returns>
		public override bool AddCard( Card c )
		{
			return false;
		}
Ejemplo n.º 7
0
		public void SetAt( int index, Card c )
		{
			base.m_cards[ index ] = c;
		}