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

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(JokerCard SubClass)
(Getting Dealt A RetrieveCard)
Line 30: Line 30:
 
* in your new AddJokerCardsToDeck, make sure you only create 2 (the original will create 5).
 
* in your new AddJokerCardsToDeck, make sure you only create 2 (the original will create 5).
 
* Add the code to create 2 JokerCards, and add them to the deck before they are shuffled.
 
* Add the code to create 2 JokerCards, and add them to the deck before they are shuffled.
==Getting Dealt A RetrieveCard==
+
==Getting Dealt A JokerCard==
 
* Find the GetCardFromDeck method, look at the 'if (Deck.GetCardDescriptionAt(0) == "Dif")'.
 
* 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) == "Jok"){}'
 
* You need to add before or after this entire if statement 'if (Deck.GetCardDescriptionAt(0) == "Jok"){}'

Revision as of 14:33, 22 December 2021

Task

Create a new card child class for a Joker card.

If a player draws a Joker card they are able to decide what type of card they want it to be, and will also be able to choose the kit it belongs to.

There should be two Joker 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

JokerCard SubClass

  • Create a subclass of Card called JokerCard (look at ToolCard & copy the whole class).
  • I have adapted the two constructor methods so they are now like this:
        public JokerCard() : base()
        {
            ToolType = "Jok";
            Kit = "";
        }

        public void Init(string t, string k)
        {
            ToolType = t;
            Kit = k;
            SetScore();
        }

Create & Add JokerCards

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

Getting Dealt A JokerCard

  • 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) == "Jok"){}'
  • Add the code to the new if statement that will run the process method of the JokerCard, ie:
                if (Deck.GetCardDescriptionAt(0) == "Jok")
                {
                    Card CurrentCard = Deck.RemoveCard(Deck.GetCardNumberAt(0));
                    Hand.AddCard(CurrentCard);
                    CurrentCard.Process(Deck, Discard, Hand, Sequence, CurrentLock, "", cardChoice);
                }

Process Method Of JokerCard

  • Now add the code to the Process method of the RetrieveCard class: