Fix onclick trigger events per boardElement

develop
Nathan Steel 1 year ago
parent 0c5b52aded
commit 10b02f5f38

@ -927,6 +927,34 @@ canvas.addEventListener('contextmenu', function(event) {
var x = event.pageX - canvasLeft, var x = event.pageX - canvasLeft,
y = event.pageY - canvasTop; 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 // # PLAYER HAND
playerHand.forEach(function(card, index){ playerHand.forEach(function(card, index){
@ -973,12 +1001,25 @@ canvas.addEventListener('click', function(event) {
if(itemKey in size && itemKey in position){ if(itemKey in size && itemKey in position){
// Compare the event XY position to the item // Compare the event XY position to the item
if(clickableCheck(x,y,false,itemKey)){ 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':
// Can attack
// board.startAttack(index);
// Get tapped
cardStatus[itemKey] = 'tapped'; cardStatus[itemKey] = 'tapped';
case 'hand':
// Can be played
//board.playCardToBoard(index);
}
} }
} }
board.drawBoard(); board.drawBoard();
} }

Loading…
Cancel
Save