Jump to content

Help with my Card Game


Clips3
 Share

Recommended Posts

Hello all,

I've been working diligently on my card game and have encountered two issues.

This first issue stems around selecting a card in the player's hand.  When I start the game, the code works as intended (I can select any card in my hand by clicking it.  This then moves the card up 20 pixels to signify that it has been selected, then I can click one of the play areas which moves the card to the appropriate area).  After the move is completed, the computer places a card in the area, and then it is the player's turn again.  Once it's my turn, my code doesn't work anymore.  I can only move my last card in my hand.

Secondly, whenever the computer tries to play a card in the second area an error is thrown.  I'm not sure why it does this because it plays in the other three areas fine (exact same code).  I've been wracking my brain for 48 hours and could use some help.  

 

Here is a link to my repo: https://github.com/smcintosh03/Poker-War

I'd appreciate any help.  Thanks.

Link to comment
Share on other sites

Your major problem with the whole program is that you are not using for loops with arrays. You are hard coding variables and checking them with redundant code. Your specific problem with the first issue is that you are checking for hand[5] in several places because you have hard coded that check instead of using a for loop. You are splicing the hand array with hand.splice(0, 1); so that isn't working as intended because the size of hand has changed.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...