2022 - Add a joker card

From TRCCompSci - AQA Computer Science
Revision as of 14:35, 22 December 2021 by Admin (talk | contribs) (Process Method Of JokerCard)
Jump to: navigation, search

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 a Process method to the JokerCard class:
public override void Process(CardCollection deck, CardCollection discard, CardCollection hand, CardCollection sequence, Lock currentLock, string choice, int cardChoice)
        {
           
        }