Ejemplo n.º 1
0
        public void Should_Not_Push_An_3_In_An_Empty_Pile()
        {
            IPile pile = new FoundationPile();

            var card3 = new Card(3, CardType.Spade);

            Assert.False(pile.Push(card3));
        }
Ejemplo n.º 2
0
    public object Clone()
    {
        FoundationPile clonePile = new FoundationPile(this.suit);

        clonePile.cards = new Stack <Card>(this.cards.Select(c => c.Clone()).Cast <Card>().Reverse());

        return(clonePile);
    }
Ejemplo n.º 3
0
        public void Should_Push_An_Ace_In_An_Empty_Pile()
        {
            IPile pile = new FoundationPile();

            var card = new Card(1, CardType.Spade);

            Assert.True(pile.Push(card));
        }
Ejemplo n.º 4
0
        public void Should_Not_Pop_If_Target_Is_Stock()
        {
            IPile pile = new FoundationPile();

            var cardACE = new Card(1, CardType.Spade);

            pile.Push(cardACE);

            IPile target = new StockPile();

            Assert.False(pile.PopRefactor(target));
        }
Ejemplo n.º 5
0
        public void Should_Push_An_3_In_An_Pile_Witn_2()
        {
            IPile pile = new FoundationPile();

            var cardACE = new Card(1, CardType.Spade);
            var card2   = new Card(2, CardType.Spade);
            var card3   = new Card(3, CardType.Spade);

            pile.Push(cardACE);
            pile.Push(card2);
            Assert.True(pile.Push(card3));
        }
Ejemplo n.º 6
0
    public GameState()
    {
        this.stockPile = new Stack <Card>();
        this.wastePile = new Stack <Card>();

        Suit[] suits = new Suit[] { Suit.Hearts, Suit.Diamonds, Suit.Clubs, Suit.Spades };
        foundationPiles = new FoundationPile[suits.Length];
        for (int i = 0; i < suits.Length; i++)
        {
            FoundationPile pile = new FoundationPile(suits[i]);
            foundationPiles[i] = pile;
        }
    }
Ejemplo n.º 7
0
        public void Should_Pop_If_Target_Is_Not_Stock()
        {
            IPile pile = new FoundationPile();

            var cardACE = new Card(1, CardType.Spade);

            pile.Push(cardACE);

            Mock <IPile> mockPile = new Mock <IPile>();

            IPile target = new TableauPile();

            Assert.True(pile.PopRefactor(target));
        }
Ejemplo n.º 8
0
 public bool IsLegal_FoundationMove(Card selectedCard, FoundationPile pile)
 {
     if (selectedCard.suit == pile.suit)
     {
         if (pile.cards.Count == 0)
         {
             return(selectedCard.value == 1);
         }
         if (selectedCard.value == (pile.cards.Peek().value + 1))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
    public int GetCardColumn(Card card)
    {
        for (int i = 0; i < tableu.Length; i++)
        {
            CardColumn tableuColumn = tableu[i];
            if (tableuColumn.faceDownCards.Contains(card) || tableuColumn.faceUpCards.Contains(card))
            {
                return(i);
            }
        }
        for (int i = 0; i < foundationPiles.Length; i++)
        {
            FoundationPile foundationPile = foundationPiles[i];
            if (foundationPile.cards.Contains(card))
            {
                return(i);
            }
        }

        return(-1);
    }
Ejemplo n.º 10
0
 public void Setup()
 {
     _pile = new FoundationPile();
 }
 public void Setup()
 {
     this.foundationPile = new FoundationPile(CardSuit.Clubs);
 }