sei-ec-remote / project-1-issues

Open new issues here
1 stars 2 forks source link

Having trouble reading 'face' card class property #219

Closed Jlarranaga closed 9 months ago

Jlarranaga commented 9 months ago

What's the problem you're trying to solve?

Randomly, I get errors saying it can't read the card class property 'face' and it only happens after playing several rounds. It's not just one spot it comes up random where it says it can't read the property 'face' but reads it fine in other areas of the code.

Post any code you think might be relevant (one fenced block per file)

image image

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

image

What is your best guess as to the source of the problem?

Find out where face comes from and go from there

What things have you already tried to solve the problem?

using console.log to debug and Google Chrome debugger and thats how I found its popping up randomly

Paste a link to your repository here

https://github.com/Jlarranaga/Project1-WAR

timmshinbone commented 9 months ago

The error says it can't tell what the cCard is, are there any times where that property is being cleared out or the .face is being removed?

Jlarranaga commented 9 months ago

I do change the variable. Let me take a look and see what I can find. Thank you!

timmshinbone commented 9 months ago

OK, find out where it's being changed, and then think about where you need to add it back before looking for it again

Jlarranaga commented 9 months ago

So i found i keep getting undefined pushed into my array after a war game. I looked all over and changed code and thought I fixed it. It keeps coming up after gameplay for a while. I even commented out a section of code and changed how the game plays where I thought the issue was coming from but it didnt work

image

Jlarranaga commented 9 months ago

So right now both decks have 29 cards out of a 52 card deck. Somewhere, I am adding more cards in...

Jlarranaga commented 9 months ago

Whats better? for loop? or for each loop?

to go through an array items and move those array items from one to another.

timmshinbone commented 9 months ago

I'd recommend trying forEach to start, unless you can't get that to work that way.

Jlarranaga commented 9 months ago

is this for loop working right?

Jlarranaga commented 9 months ago

for(i=0; i<=1; i++){ //TODO chaned to 2 and commented out. Will this solve issue? NO pWarCards.push(pCards[i]) pCards.splice(i,1) cWarCards.push(cCards[i]) cCards.splice(i,1) }

Jlarranaga commented 9 months ago

I want to add 2 items to this array and remove 2 items from another. right?