public void IsLegal_ReturnsTrueIfPlayeHasCards()
        {
            var cards = new Card[]
            {
                new Card(CardType.Blue, 12, DefaultScore),
                new Card(CardType.Blue, 13, DefaultScore),
                new Card(CardType.Blue, 14, DefaultScore)
            };

            var initialMove = new InitialMove(new Card(CardType.Blue, 12, DefaultScore), new Card(CardType.Blue, 13, DefaultScore), new Card(CardType.Blue, 14, DefaultScore));

            Assert.IsTrue(InitialMoveRule.IsLegal(new Hand(cards), initialMove));
        }
        public void IsLegal_ReturnsFalseIfCardGivenIsNotInPlayersCards()
        {
            var cards = new Card[]
            {
                new Card(CardType.Blue, 12, DefaultScore),
                new Card(CardType.Blue, 13, DefaultScore),
                new Card(CardType.Blue, 14, DefaultScore)
            };

            var initialMove = new InitialMove(new Card(CardType.Red, 12, DefaultScore), new Card(CardType.Red, 13, DefaultScore), new Card(CardType.Red, 14, DefaultScore));

            Assert.False(InitialMoveRule.IsLegal(new Hand(cards), initialMove));
        }
Exemple #3
0
 private InitialMove[] DoInitialMoves(Hand[] playerCards)
 {
     return(playerCards.Select((hand, i) =>
     {
         var initialMove = _players[i].RoundStart(hand.Cards());
         if (!InitialMoveRule.IsLegal(hand, initialMove))
         {
             throw new Exception("Illegal move");
         }
         hand.RemoveCard(initialMove.ToBottle);
         hand.RemoveCard(initialMove.ToLeft);
         hand.RemoveCard(initialMove.ToRight);
         return initialMove;
     }).ToArray());
 }
        public void IsLegal_ReturnsFalseIfCardIsGivenMultipleTimes()
        {
            var cards = new Card[]
            {
                new Card(CardType.Blue, 12, DefaultScore),
                new Card(CardType.Blue, 13, DefaultScore),
                new Card(CardType.Blue, 14, DefaultScore)
            };

            var initialMove = new InitialMove(
                new Card(CardType.Blue, 12, DefaultScore),
                new Card(CardType.Blue, 12, DefaultScore),
                new Card(CardType.Blue, 13, DefaultScore));

            Assert.False(InitialMoveRule.IsLegal(new Hand(cards), initialMove));
        }