Removind card from stock - Situation C

Game development with Board Game Arena Studio
Post Reply
User avatar
locerol
Posts: 19
Joined: 15 August 2015, 10:20

Removind card from stock - Situation C

Post by locerol »

Hello fellow developers!

In the game I am developing, I am trying to move a card located in a stock component to a non-stock component, the player panel. Clearly, it exactly fits into situation C in the stock help page.

The information about situation C in that page says:

When you move a card from a stock item to something that is not a stock item:

-Insert the card as a classic HTML template (dojo.place / this.format_block).
-Place it on the Stock item with this.placeOnObject, using the Stock item HTML id (see above).
-Slide it to its new position with this.slideToObject.
-Remove the card from the Stock item with removeFromStockById.


If every card in the stock will eventually have to move to another player's panel (it's a draft process), does that mean I cannot use addToStockWithId for any card? Because that is mainly the reason for using the stock, to simplify the adding and removing cards from the collection of cards.

Another question I have is regarding the dojo.place instruction:

dojo.place(node, refNode, pos);

what is supossed to be the refNode parent of the card? The stock? Or just any random element in the page?

Thank you a lot in advance!!
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Removind card from stock - Situation C

Post by Victoria_La »

dojo.place is generic dojo API that can place any object on any object, refNode is parent node, can get it by id like $(node_id), node can be any dojo object of html string like "<div>..."
This code is to do fancy animation, without animation you just use stFrom.removeFromStockById(idCard);

With animation will be something along these lines (did not debug it could be lots of typos)

Code: Select all

cardTemp = dojo.clone($(cardId'));
dojo.attr(cardTemp, "id", "card-temp-" + cardId);
dojo.place(cardTemp,$(cardId));
anim = this.slideToObject(cardTemp, toObject);// don't remember API of that exactly
// this code below may need to wait for animation to finish
dojo.connect( anim, 'onEnd', this, function(node) {
  stFrom.removeFromStockById(cardId);// not sure  html id same as stock id
  dojo.attr(cardTemp, "id", cardId); // this if you want to preserve id
}
anim.play();
User avatar
locerol
Posts: 19
Joined: 15 August 2015, 10:20

Re: Removind card from stock - Situation C

Post by locerol »

Thank you for comments, Victoria_La.

It seems I did not understand the help page regarding moving elements from stocks - situation C. It was kind of puzzling that I did have to insert into the stock the card I wanted to remove, in order to make the animation. But that is exactly what must be done, at some point there are two copies of the same card, one placed with this.stockName.addToStockWithId and the second one placed with the dojo.place instruction just to make the animation possible.

Once I understood this it works fine.

Thank you!
Post Reply

Return to “Developers”