diff --git a/public/board.js b/public/board.js index bbd9137..3dcb565 100644 --- a/public/board.js +++ b/public/board.js @@ -1269,6 +1269,7 @@ canvas.addEventListener('contextmenu', function(event) { if(clickableCheck(x,y,itemKey)){ console.log('itemId: '+itemKey); document.getElementById('effectTargetId').value = itemKey; + document.getElementById('triggerTargetId').value = itemKey; // Only want to happen once (for now) // Maybe in future add to hand would trigger another event if there's an effect? diff --git a/public/debug.js b/public/debug.js index 6eed83f..327f37d 100644 --- a/public/debug.js +++ b/public/debug.js @@ -66,3 +66,28 @@ function debugEffectFunction(damageAmount = null, targetId = null, targetId2 = n if(effect == 'equip'){} } + +function debugTrigger(){ + let targetId = document.getElementById("triggerTargetId").value; + if(targetId == ""){ targetId = null; } + + let trigger = document.getElementById("trigger").value; + if(trigger == ""){ trigger = null; } + + let triggerAmount = document.getElementById("triggerAmount").value; + if(triggerAmount == ""){ triggerAmount = null; } + + debugTriggerFunction(targetId, trigger, triggerAmount); +} +function debugTriggerFunction(targetId = null, trigger = null, triggerAmount = null){ + + if(targetId == null){ return false; } + + if(trigger == 'tap'){ + triggerTap(targetId); + } + if(trigger == 'pay'){ + triggerPay(targetId, triggerAmount); + } +} + diff --git a/public/effect.js b/public/effect.js index 60062d0..509d270 100644 --- a/public/effect.js +++ b/public/effect.js @@ -124,3 +124,39 @@ function hurt(hurtDamage, hurtTarget = null, hurtPlayer = null){ } } +// Effect Trigger(s) +// Non-event triggers. i.e. these are activated triggers +// rather than things such as 'On attack', 'When opponent draws' + +// When card has been actively tapped +function triggerTap(card){ + if(!canTriggerTap(card)){ return false; } + + board.tapCard(card); + + console.log('triggerTap'); + return true; + +} +// Check a card can actively be tapped, otherwise don't start trigger +function canTriggerTap(card){ + if(board.isTapped(card)){ + return false; + } + if(boardElement[card] != 'board'){ + return false; + } + + console.log('can triggerTap'); + return true; +} + +// Pay the mana cost(s) to trigger event +function triggerPay(){ + +} +// Check the mana cost(s) can be paid, otherwise don't start trigger +function canTriggerPay(){ + +} + diff --git a/public/index.html b/public/index.html index d0d3f57..fd1bbd7 100644 --- a/public/index.html +++ b/public/index.html @@ -87,6 +87,20 @@ +