Stock control, how to modify individual item

Game development with Board Game Arena Studio
Post Reply
User avatar
quietmint
Posts: 299
Joined: 31 July 2017, 00:28

Stock control, how to modify individual item

Post by quietmint »

My game has a small deck of cards. I am using the Stock control to manage each player's hand of 2 cards. During the game, cards in hand are spent/used up, but they still remain in that player's hand. I want to change the appearance of the spent cards. I want to keep them in the same Stock as the unused cards so I can continue to overlap them.

How can I add a CSS class to an individual card in Stock? I see how onItemCreate lets me do this at card creation time, but what about later during the course of the game? Given a card's specific ID, how do I get the corresponding HTML element to manipulate it?
Attachments
Screen Shot 2017-08-14 at 3.34.30 PM.png
Screen Shot 2017-08-14 at 3.34.30 PM.png (153.33 KiB) Viewed 2778 times
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Stock control, how to modify individual item

Post by Victoria_La »

Are you using addToStockWithId? You can see what it generates to see if you hook it to it by that id, there is hook onItemCreate
from which you can get the node id
User avatar
quietmint
Posts: 299
Joined: 31 July 2017, 00:28

Re: Stock control, how to modify individual item

Post by quietmint »

I know onItemCreate was hoping for a more elegant solution. I want to modify the card at runtime, not at creation.

But actually, I take back what I said earlier. Even onItemCreate doesn't give me the card ID, it only gives the ID of the DOM element. Am I just to assume that DOM element "tableau_2305331_item_4" is for card ID = 4?
User avatar
Morgalad
Posts: 110
Joined: 17 January 2017, 20:46
Contact:

Re: Stock control, how to modify individual item

Post by Morgalad »

you NEED to remember which element goes with each id!!!

The game logic is based in the fact that a player can press F5 at any moment!
Cheers...
Morgalad

Developer of: Incan Gold , Takara Island , Taluva and Veggie Garden
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: Stock control, how to modify individual item

Post by Een »

Stock method getItemDivId( id ) might be what you are looking for.
User avatar
quietmint
Posts: 299
Joined: 31 July 2017, 00:28

Re: Stock control, how to modify individual item

Post by quietmint »

Een wrote:Stock method getItemDivId( id ) might be what you are looking for.
Thanks, that's exactly it!
Post Reply

Return to “Developers”