How to use the card.dropped function in card

To help you get started, we’ve selected a few card examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yomguithereal / mtgnode / assets / js / src / playground / playground.area.js View on Github external
this.bindOnCards = function(name, fn) {
      this.$game.on(name, this.cards, fn);
    }

    // Generic Receptors
    //-------------------

    // Linked model updated
    this.triggers.events[this.updatedEvent] = function(d, e) {
      var cards = d.get(_this.side + '-' + _this.name);
      utilities.optcall(_this, _this.onUpdate, cards);
    };

    // Card dropped in area
    this.triggers.events['card.dropped'] = function(d, e) {
      if (!_this.drop ||
          (_this.name !== e.data.from && _this.name !== e.data.to)) {
        return;
    }

      var $card = _this.selectCard(e.data.id || e.data.card.id);

      // Applying new classes to dropped elements
      $card.removeClass('in-' + e.data.from);
      $card.addClass('in-' + e.data.to);

      // Executing drop callbacks
      if (e.data.type === 'same')
        utilities.optcall(_this, _this.drop.onSameArea, $card);
      else
        if (_this.name === e.data.from)