From c273b66bc3c929e4eaede3a2182139449af4a033 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 8 Oct 2024 16:25:57 +0100 Subject: [PATCH] Add opponentdrawCard from shield on destroy --- public/board.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/public/board.js b/public/board.js index f18bc21..4d69c74 100644 --- a/public/board.js +++ b/public/board.js @@ -423,11 +423,24 @@ class Board{ this.drawBoard(); } // Do the attack - makeAttack(index, array = null){ - if(array == null){ array = opponentBoard; } + makeAttack(index, array = null, name = null){ + if(array == null){ array = opponentBoard; name = 'opponentBoard' } + console.log(name); // If card attacked // Compare attackingCard and defendingCard + let defendingCard = array[index]; + + // If hitting shield, don't calc combat damage + 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]); + this.endAttack(); + return 1; + } + if(defendingCard.atk <= attackingCard[0].atk){ array.splice(index, 1); // Need to push to grave, etc. here in future too @@ -661,7 +674,7 @@ canvas.addEventListener('click', function(event) { if(clickableCheck(x,y,clickable)){ // Check if card if getting attacked if(attackingCard !== null){ - board.makeAttack(index, opponentShield); + board.makeAttack(index, opponentShield, 'opponentShield'); } board.drawBoard(); }