2022 - Add a retrieve card

From TRCCompSci - AQA Computer Science
Jump to: navigation, search


Create a new card child class for a Retrieve card.

If a player draws a retrieve card they are able to retrieve one card from the discard pile and return it to their hand.

There should be two retrieve cards in the deck. These should be added like the difficulty cards, and should be added after the user draws their hand.

What you need to do

RetrieveCard SubClass

  • Create a subclass of Card called RetrieveCard (look at DifficultyCard & copy the whole class).
  • Make sure you rename the constructor methods to RetrieveCard as well & change the CardType to 'Ret'.
  • Keep the Process method, but remove all of the code within the curly brackets.

Create & Add RetrieveCards

  • Look at how DifficultyCards are added to the deck (find the SetupGame & AddDifficultyCardsToDeck methods).
  • Copy the method AddDifficultyCardsToDeck, rename it to AddRetrieveCardsToDeck.
  • in your new AddRetrieveCardsToDeck, make sure you only create 2 (the original will create 5).
  • Add the code to create 2 RetrieveCards, and add them to the deck before they are shuffled.

Getting Dealt A RetrieveCard

  • Find the GetCardFromDeck method, look at the 'if (Deck.GetCardDescriptionAt(0) == "Dif")'.
  • You need to add before or after this entire if statement 'if (Deck.GetCardDescriptionAt(0) == "ret"){}'
  • Add the code to the new if statement that will run the process method of the RetrieveCard, ie:
                if (Deck.GetCardDescriptionAt(0) == "Ret")
                    Card CurrentCard = Deck.RemoveCard(Deck.GetCardNumberAt(0));
                    CurrentCard.Process(Deck, Discard, Hand, Sequence, CurrentLock, "", cardChoice);

Process Method Of RetrieveCard

  • Now add the code to the Process method of the RetrieveCard class:
    • for loop to iterate twice only
    • code to display the current sequence (sequence.GetCardDisplay())
    • Code to ask for the card number to retrieve
    • Retrieve the card selected, and add the RetrieveCard itself to the discard collection, the code below is an example of this:
                Card CardToMove = sequence.RemoveCard(sequence.GetCardNumberAt(0));