From 5b5b0bde86421eac3319b0bf58a3e220e56930b4 Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 10 Oct 2024 15:40:24 +0100 Subject: [PATCH] Add card and shield tapping --- public/board.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/public/board.js b/public/board.js index 209166d..7aadc16 100644 --- a/public/board.js +++ b/public/board.js @@ -470,8 +470,18 @@ class Board{ if(name == 'opponentShield'){ // This should tap the card first, then after all shields // are tapped, THEN attacking destroys them - array.splice(index, 1); - opponentHand.push(array[index]); + if(array[index].tapped){ + // Untap + array[index].tapped = false; + // Add to hand + opponentHand.push(array[index]); + // Remove from shield zone + array.splice(index, 1); + }else{ + array[index].tapped = true; + } + + playerBoard[attackingCard[1]].tapped = true; this.endAttack(); return 1; } @@ -721,7 +731,7 @@ canvas.addEventListener('click', function(event) { if(attackingCard !== null && card == attackingCard[0]){ board.endAttack(); } - if(!specialEvent){ + if(!specialEvent && card.tapped != true){ board.startAttack(index); } board.drawBoard(); @@ -812,5 +822,7 @@ function untap(array){ } function untapAll(){ untap(playerMana); + untap(playerBoard); + untap(opponentShield); }