Beispiel #1
0
        public void Have_turn_equals_to_starting_numbers_count(
            string startingNumbers,
            int expectedTurn,
            int expectedNumberSpoken)
        {
            // Given
            var memoryGame    = new MemoryGame(startingNumbers);
            var expectedState = new MemoryGameState(expectedTurn, expectedNumberSpoken);

            // When
            var actualState = memoryGame.State;

            // Then
            Assert.Equal(expectedState, actualState);
        }
Beispiel #2
0
        public void Determine_the_number_spoken_at_specific_turn(
            string startingNumbers,
            int expectedTurn,
            int expectedSpokenNumber)
        {
            // Given
            var memoryGame    = new MemoryGame(startingNumbers);
            var expectedState = new MemoryGameState(expectedTurn, expectedSpokenNumber);

            // When
            memoryGame.PlayUpToTurn(expectedTurn);
            var actualState = memoryGame.State;

            // Then
            Assert.Equal(expectedState, actualState);
        }
Beispiel #3
0
        public void Said_zero_when_meet_first_number_spoken(
            string startingNumbers,
            int expectedTurn,
            int expectedNumberSpoken)
        {
            // Given
            var memoryGame    = new MemoryGame(startingNumbers);
            var expectedState = new MemoryGameState(expectedTurn, expectedNumberSpoken);

            // When
            memoryGame.Play();
            var actualState = memoryGame.State;

            // Then
            Assert.Equal(expectedState, actualState);
        }
Beispiel #4
0
        public void Play_until_specific_turn(
            string startingNumbers,
            int expectedTurn,
            int expectedNumberSpoken)
        {
            // Given
            var memoryGame    = new MemoryGame(startingNumbers);
            var expectedState = new MemoryGameState(expectedTurn, expectedNumberSpoken);

            // When
            memoryGame.PlayUpToTurn(expectedTurn);
            var actualState = memoryGame.State;

            // Then
            Assert.Equal(expectedState, actualState);
        }
Beispiel #5
0
        public int Calculate(MemoryGameState state, string gameMode, GameRules rules, IList <CardData> cards, int playerScore)
        {
            if (cards == null)
            {
                throw new ArgumentNullException();
            }

            int score;
            int firstTry = cards.Count(card => !card.WasFlipped);

            if (state == MemoryGameState.PairFound || state == MemoryGameState.CorrectAnswer)
            {
                switch (firstTry)
                {
                case 2:
                    score = rules.LucyPoints;
                    break;

                case 1:
                    score = rules.ConcludePoints;
                    break;

                default:
                    score = rules.PairFoundPoints;
                    break;
                }
            }
            else
            {
                score = (2 - firstTry) * rules.MissPoints;
            }

            foreach (var card in cards)
            {
                card.WasFlipped = true;
            }

            return(score);
        }
        public int Calculate(MemoryGameState state, string gameMode, GameRules rules, IList<CardData> cards, int playerScore)
        {
            if (cards == null)
            {
                throw new ArgumentNullException();
            }

            int score;
            int firstTry = cards.Count(card => !card.WasFlipped);

            if (state == MemoryGameState.PairFound || state == MemoryGameState.CorrectAnswer)
            {
                switch (firstTry)
                {
                    case 2:
                        score = rules.LucyPoints;
                        break;

                    case 1:
                        score = rules.ConcludePoints;
                        break;

                    default:
                        score = rules.PairFoundPoints;
                        break;
                }
            }
            else
            {
                score = (2 - firstTry) * rules.MissPoints;
            }

            foreach (var card in cards)
            {
                card.WasFlipped = true;
            }

            return score;
        }