Reference no: EM133370241
Question: Add a PlayGame method to the CardWars class. It should have 3 parameters: List for the cards, List for the high scores, and a string for the name of the high score file.
Here is the game logic to put in PlayGame:
1. Call shuffle passing in the list of cards.
2. Take the shuffled list and split it into 2 equal lists: playerCards and npcCards.
3. Create 3 lists: playerPile, npcPile, unclaimedPile.
4. Loop while the playerCards list is not empty COP2334
a. Print out the first card from playerCards and npcCards (see example below on how to print)
b. Add the first card from playerCards and npcCards to the unclaimed pile.
c. Call Compare and pass the first card from the playerCards and npcCards.
i. NOTE: compare will return -1 if the card1 < card2, 0 if card1 = card2, 1 if card1 > card2
d. If Compare returns -1, add the unclaimed pile to the npcPile. Clear the unclaimed pile. Print NPC wins.
e. If Compare returns 1, add the unclaimed pile to the playerPile. Clear the unclaimed pile. Print player wins.
f. Remove the first card from the playerCards and npcCards.
5. After the loop, check who won. Print the counts from the playerPile and npcPile lists.
a. If the npcPile has more cards, print that the npc won the round.
b. If the npcPile has the same number of cards as the playerPile, print that it was a tie.
c. Else, the playerPile has more cards. Print out that the player won and check if it's a new high score.
i. NOTE: the last score in the high score list is the smallest high score. Therefore, if the playerPile count is greater than the last score in the high score list, the player has a new high score.
ii. If a new high score,
1. Get the user's name using Input.GetString
2. loop from the beginning of the high score list
3. If the score is >= the high score, then
a. insert the high score into the list at that index
b. remove the last score in the list
c. call SaveHighScores (method already created)