[SOLVED] Straightest way to move a card from Stock component to Zone component
Posted: 13 May 2016, 18:41
Hi everybody!
I'm faced with a basic problem. I have a stock component to represents the cards in player's hand and a Zone component to represent player's board, which is managed by a custom pattern. For the moment, to simplify my problem, the cards have the same layout in both hand and board (visible verso).
I want to pick a card from player hand (Stock) which id is known and place it smoothly on the board (Zone). Here's what I do, according to what is said at the end of the doc http://en.doc.boardgamearena.com/Stock -> Tips when adding/removing items to/from Stock components -> Situation C:
This code does not work
. The node seems not to be cloned properly. I read that JS template could be useful but I don't know how to associate a card coming from a stock with such template
.
Any luck?
I'm faced with a basic problem. I have a stock component to represents the cards in player's hand and a Zone component to represent player's board, which is managed by a custom pattern. For the moment, to simplify my problem, the cards have the same layout in both hand and board (visible verso).
I want to pick a card from player hand (Stock) which id is known and place it smoothly on the board (Zone). Here's what I do, according to what is said at the end of the doc http://en.doc.boardgamearena.com/Stock -> Tips when adding/removing items to/from Stock components -> Situation C:
Code: Select all
var HTML_id = 'hand_' + player_id + '_item_' + id; // 'hand_' + player_id is the HTML div which hosts the myStock; id is the id of the card defined when it has been added to myStock
var node = dojo.clone($(HTML_id)); // Clone the card and get a mobile node
this.placeOnObject(node, HTML_id); // Place this node on the Stock, above the original card
this.slideToObject(node, 'board_' + player_id); // 'board_' + player_id is the HTML div which hosts myZone slide the node from stock to Zone
myStock[player_id].removeFromStockById(notif.args.id); // Delete the card from the stock
myZone.placeInZone( node , 1 ); // Integrate the node with weight = 1 in myZone
Any luck?