From 54f136295d4cce3bad799bb5f60df9d4fffced54 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sun, 13 Oct 2024 11:52:08 +0100 Subject: [PATCH] Add grave boardElement, Fix unit/unit makeAttack --- public/board.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/public/board.js b/public/board.js index 3371d3c..c1f8fdb 100644 --- a/public/board.js +++ b/public/board.js @@ -18,7 +18,7 @@ clickableItems['opponentHand'] = []; // Counters to keep track of players, and boardElements, may be changed in future // But once game starts, will be const anyway, so shouldn't need passing let players = 2; // Player, Opponent for now, but will be up to 6 players for 5v1 boss raids? -let elements = ['deck','board','hand','mana','shield']; +let elements = ['deck','board','hand','mana','shield', 'grave']; let elementsSizes = {}; // May need to have the base XY WH of board, hand, etc. stored for loop draw // Array of items, the 'Entity Manager' as such let item = []; @@ -715,17 +715,17 @@ class Board{ // If card on 'board' attacked // Compare attackingCard and defendingCard case 'board': - let atkAttacker = cardData[itemAttacking].attack; - let atkDefender = cardData[itemDefending].attack; + let atkAttacker = cardData[itemAttacking]; + let atkDefender = cardData[itemDefending]; // Does Attacker kill Defender if(atkDefender <= atkAttacker){ - // TODO:Send the item to grave, boardElement = 'grave' + this.sendToGrave(itemDefending); } // Does Defender kill Attacker if(atkAttacker <= atkDefender){ - // TODO:Send the item to grave + this.sendToGrave(itemAttacking); this.endAttackFor(itemAttacking); }else{ // If not, end the attacker cards attack 'phase' @@ -844,6 +844,13 @@ class Board{ //addFromBoardElement(playerFrom, fromPosition, elementFrom, elementTo, toPosition=null, playerTo=null) this.addFromBoardElement(player[itemKey], listPosition[itemKey], boardElement[itemKey], 'hand', null, null); } + + sendToGrave(itemKey){ + console.log('SendToGrave: '+itemKey); + //addFromBoardElement(playerFrom, fromPosition, elementFrom, elementTo, toPosition=null, playerTo=null) + this.addFromBoardElement(player[itemKey], listPosition[itemKey], boardElement[itemKey], 'grave', null, null); + } + tapCard(itemKey){ // Set the cardStatus to tapped cardStatus[itemKey] = 'tapped';