diff --git a/public/board.js b/public/board.js index 4e5a2b2..a7c4a10 100644 --- a/public/board.js +++ b/public/board.js @@ -688,7 +688,10 @@ class Board{ let mana = items[item]; - if(this.isTapped(mana) || this.isSelected(mana)){ + // Deselect the mana at the start to ensure it's not doopid + this.deselectCard(mana); + + if(this.isTapped(mana)){ continue; } @@ -737,20 +740,21 @@ class Board{ let mana = items[item]; + if(itemCostRemaining <= 0){ + break; + } + if(this.isTapped(mana) || this.isSelected(mana)){ continue; } - if(itemCostRemaining > 0){ - manaToTap.push(mana); - itemCostRemaining--; - } + manaToTap.push(mana); } } - if(itemCostRemaining > 0){ - return false; // Didn't find another mana to tap so cost not satiated + if(cardData[itemToPayCost].cost - manaToTap.length > 0){ + return 'itemCostRemaining: '+itemCostRemaining; // Didn't find another mana to tap so cost not satiated } // If the mana to tap has been satitated then tap the mana selected