2022 - No error message is displayed if the user attempts to play two consecutive cards of the same tool type

From TRCCompSci - AQA Computer Science
Revision as of 16:29, 6 December 2021 by Admin (talk | contribs) (Created page with "You will first need to find the PlayCardToSequence method in the BreakThrough Class: <syntaxhighlight lang=c#> private void PlayCardToSequence(int cardChoice) {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You will first need to find the PlayCardToSequence method in the BreakThrough Class:

 private void PlayCardToSequence(int cardChoice)
        {
            if (Sequence.GetNumberOfCards() > 0)
            {
                if (Hand.GetCardDescriptionAt(cardChoice - 1)[0] != Sequence.GetCardDescriptionAt(Sequence.GetNumberOfCards() - 1)[0])
                {
                    Score += MoveCard(Hand, Sequence, Hand.GetCardNumberAt(cardChoice - 1));
                    GetCardFromDeck(cardChoice);
                }
            }
            else
            {
                Score += MoveCard(Hand, Sequence, Hand.GetCardNumberAt(cardChoice - 1));
                GetCardFromDeck(cardChoice);
            }
            if (CheckIfLockChallengeMet())
            {
                Console.WriteLine();
                Console.WriteLine("A challenge on the lock has been met.");
                Console.WriteLine();
                Score += 5;
            }
        }

The second if statement above is what stop you playing a card of the same type as the previous.

What you need to do

  • Add an else condition to the if statement.