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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.