I’ve got art appearing on the screen!
But as standard, adding new features creates new issues:
1. I’m using .cloneNode to create cloned imgs which is fine, but the original IMG (which starts blank) also displays a card so there is always a duplicate first card.
2. Adds the imgs but it doesn’t remove them on refresh. Which is fine because I can just create a rule to refresh the div back to default right? You’d think but no… I’ve tried numerous things (.innerHTML(“”), replace with(showHand)) nothing works other than refreshing the page. Which I could utilize as but of the round Start function but that seems cheap.
But progress is made nevertheless
Side note: still yet to sit down and start learning games design but:
a) I’m still involved with my Star Wars Legion miniatures
b) I’ve taken 2 week’s off for NaNoWriMo
c) I’m hoping to set up my laptop upstairs when new setup is in place so I’m hoping that having a dedicated space other then the cluttered dining table or sofa will help me focus
The two issues from Progress Update #8 are sorted.
I removed the Clone method of adding items and simply created new img elements. This simplified the code and enabled me to change it to better read the functions.
I was able to clear the empty img out which I replaced with an empty span, which didn’t inherit the img src and therefore did not display as a duplicate card. I was also able to target this separately remove the imgs and start fresh.
But I have a new issue (go figure!):
1. press start multiple times now works; each time only 2 cards are displayed. But when you click Hit to add a new card to the playersHand, the same script runs and more images are created. Which is fine… but it runs several times and runs on already displayed images. There clicking hit gives the player 3 of each of their 3 cards… which isn’t ideal.
Solution: I need to amend the current cardShow function to run a check to see if an images with the id already exists, if so do nothing, if not, create the card. But its not as straight forward as looping through an array as I’m now in need of looping through a DOM element. I’ll need to research this next time.
Today I did a bit of work and learnt how to loop through DOM elements. I’ve started making a function to remove duplicates but got caught up in work and other things