Help with my Card Game

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:

I'd appreciate any help.  Thanks.

Share this post

Link to post
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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.