|
|
|
|
@ -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();
|
|
|
|
|
}
|
|
|
|
|
|