Hi again !
I've made little progress :
I've updated States and now each player can play a card alternatively.
There are some notifications sent.
but I need F5 to make the opponent cards appear.
I suppose notifications in client calls playCardOnTable in order to make appear other players cards on tableCards Stock.
Code: Select all
playCardOnTable : function(player_id, color, value, card_id) {
// player_id => direction
if (player_id != this.player_id) {
// Some opponent played a card
// Move card from player panel
console.log(player.id +" otherhand_item_ "+card_id);
this.tableCards.addToStockWithId( this.getCardUniqueId(color, value), 'tablecards_item_'+card_id )
}
else {
// You played a card. If it exists in your hand, move card from there and remove
// corresponding item
if ($('mycards_item_' + card_id)) {
this.tableCards.addToStockWithId( this.getCardUniqueId(color, value), 'tablecards_item_'+card_id, 'mycards_item_' + card_id )
this.playerHand.removeFromStockById(card_id);
}
}
By now, I think I have to write something in the case player_id != this.player_id.
I want to move the card from the active playerHand Stock to tableCards Stock
I don't know what to put as last arg in this.tableCards.addToStockWithId, which be 'from'
I suppose I also have to removeFromStockById(card_id) from the active playerHand Stock.
Or am I totally wrong about Stock components ?