Question: Create a classic card game WAR. Consider classes such as Card, Deck, and Player and what fields and methods they might each have. You can

Create a classic card game WAR. Consider classes such as Card, Deck, and Player and what fields and methods they might each have. You can implement the game however youd like (i.e. printing to the console, using alert, or some other way). The completed project should, when ran, do the following: :

::Deal 26 Cards to two Players from a Deck.

:::Iterate through the turns where each Player plays a Card

:::The Player who played the higher card is awarded a point

:::Ties result in zero points for either Player :

::After all cards have been played, display the score.

:::Write Unit Tests using Mocha and Chai for each of the functions you write.

NEED THE CODE TO ANSWER THE PROMPT ASAP. JAVASCRIPT ONLY.

OUTPUTS FROM CODE SHOULD INCLUDE:

-WHO WINS EACH ROUND (ONLY 26 ROUNDS)

-TOTAL PLAYER ONE POINTS AND TOTAL PLAYER 2 POINTS

-WINNER OF THE GAME

***MY CODE KEEPS RETURNING EACH ROUND AS A TIE, AND RETURNS PLAYER 1 AND PLAYER 2 POINTS AS 0***

^ NEED THIS ISSUE SOLVED. NEED RETURN VALUE TO BE CONSISTENT WITH CONDITIONS IMPLEMENTED

MY CURRENT CODE IS BELOW:

Create a classic card game WAR. Consider classes such as Card, Deck,and Player and what fields and methods they might each have. Youcan implement the game however youd like (i.e. printing to the console,

3 Danean s playerzDeck = net Deck I deck.cards. 5 Lice [decknidpoint, deck, nunberid Cards 1/: fyplayer 1 deck and player 2 deck split evenly and randonly console. leg [p layer IDeck!! csnsele. leg [player2beck]; for llet 1 a of 1 e ganeflaundsp 1+1} const playericard = playepideck, cards[1], value; const player2Card = player20eck, cards li1, walue; console, logi "Player 1 wins round $(i+1))i player1pointst+p 8 else if (player1card e player2card? \& coneole, logl Player 2 u1ns round $(1+1}) pleyeraboints+i 7 console. lagi' 'Rocnd $[i+1} is a tie'li; J console, hogl 'Player 1 poants i s\{player1pointsk' y ' concale. lagl' Player 2 Peints: \$\{playerzPoints) '): 1 else 2f fplayer1points e playerzPoints if console. loge"player 2 wins the gave!")! 7 else f console. logt"The gane is a tie!"l: - Deck fcards: Afray(26)y - Decn feards: Array(26)) Ahund 1 is a tie Round 2 is 8 tie Round 3 is a tie Anund 4 is a tie Round 5 is a tie Round 6 is a tie Rhound 8 is a t ie Anund 9 is a the Round 18 is tie Round 11 is a tie Round 12 is a tie Round 13 is s tie Round 14 is a tie Round 15 is a tie

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!