Difference between revisions of "2022 - Add a retrieve card"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Task)
(What you need to do)
Line 7: Line 7:
  
 
=What you need to do=
 
=What you need to do=
* Create a subclass of Card called RetrieveCard (look at DifficultyCard)
+
* Create a subclass of Card called RetrieveCard (look at DifficultyCard & copy the whole class).
* Look at how DifficultyCards are added to the deck (find the SetupGame & AddDifficultyCardsToDeck methods)
+
* Make sure you rename the constructor methods to RetrieveCard as well & change the CardType to 'Ret'.
* Add the code to create 2 RetrieveCards, and add them to the deck before they are shuffled
+
* Keep the Process method, but remove all of the code within the curly brackets.
* Find the GetCardFromDeck method, look at the 'if (Deck.GetCardDescriptionAt(0) == "Dif")'
+
* Look at how DifficultyCards are added to the deck (find the SetupGame & AddDifficultyCardsToDeck methods).
* Add the code to GetCardFromDeck that will process a RetrieveCard
+
* 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.
 +
* 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.
 +
* 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.

Revision as of 12:03, 18 November 2021

Task

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

  • 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.
  • 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.
  • 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.
  • 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.