diff --git a/public/board.js b/public/board.js index ed5d5dc..f36de0b 100644 --- a/public/board.js +++ b/public/board.js @@ -927,6 +927,34 @@ canvas.addEventListener('contextmenu', function(event) { var x = event.pageX - canvasLeft, y = event.pageY - canvasTop; + for(let itemKey = 0; itemKey < item.length; itemKey++){ + + if(elements[itemKey] == 'deck'){ + continue; + } + + // Check the item has a size and position + if(itemKey in size && itemKey in position){ + // Compare the event XY position to the item + if(clickableCheck(x,y,false,itemKey)){ + // Only want to happen once (for now) + // Maybe in future add to hand would trigger another event if there's an effect? + + // Check the location of element + switch(boardElement[itemKey]){ + // Check item location, and trigger events based on it + case 'board': + // Untap + cardStatus[itemKey] = null; + case 'hand': + // Can be played as mana (right click for now) + } + } + } + + board.drawBoard(); + } + // # PLAYER HAND playerHand.forEach(function(card, index){ @@ -973,12 +1001,25 @@ canvas.addEventListener('click', function(event) { if(itemKey in size && itemKey in position){ // Compare the event XY position to the item if(clickableCheck(x,y,false,itemKey)){ - cardStatus[itemKey] = 'tapped'; + // Only want to happen once (for now) + // Maybe in future add to hand would trigger another event if there's an effect? + + // Check the location of element + switch(boardElement[itemKey]){ + // Check item location, and trigger events based on it + case 'board': + // Can attack + // board.startAttack(index); + // Get tapped + cardStatus[itemKey] = 'tapped'; + case 'hand': + // Can be played + //board.playCardToBoard(index); + } } } board.drawBoard(); - }