From f9919bde0ede691a1ba158f5114a8a86977c9bab Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 25 Oct 2024 20:55:30 +0100 Subject: [PATCH] Add console debug for cardEffect --- public/board.js | 1 + public/debug.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ public/effect.js | 16 +++++++++++++ 3 files changed, 77 insertions(+) diff --git a/public/board.js b/public/board.js index d3da392..89ad5ab 100644 --- a/public/board.js +++ b/public/board.js @@ -1285,6 +1285,7 @@ canvas.addEventListener('contextmenu', function(event) { console.log('itemId: '+itemKey); document.getElementById('effectTargetId').value = itemKey; document.getElementById('triggerTargetId').value = itemKey; + debugGetCardEffects(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 98a97ca..bbc76b7 100644 --- a/public/debug.js +++ b/public/debug.js @@ -91,3 +91,63 @@ function debugTriggerFunction(targetId = null, trigger = null, triggerAmount = n } } +// Builds console log for card effect (inc. +// all triggers, etc) +function debugGetCardEffects(itemKey){ + + let effectData = cardEffect[itemKey]; + console.log(effectData); + if(effectData === undefined){ return false; } + + effectData.forEach((effect, effectIndex) => { + + console.log('--- Effect '+ effectIndex +' ---'); + console.log(effect['description']); + + // Loop the triggers + for (const [key, value] of Object.entries(effect['trigger'])) { + + console.log('--- Trigger ---'); + let effectTrigger = effect['trigger'][key]; + console.log(triggerTypes[effectTrigger['triggerTypeId']]); + + console.log('--- Trigger Amount ---'); + console.log(effectTrigger['amount']); + + // Loop targets for said trigger + effectTrigger['target'].forEach((effectTriggerTarget) => { + console.log('--- Trigger Target ---'); + console.log(effectTriggerTarget.classId); + console.log(effectTriggerTarget.colourId); + console.log(effectTriggerTarget.passiveId); + console.log(effectTriggerTarget.typeId); + }); + } + + // Loop the effects + for (const [key, value] of Object.entries(effect['step'])) { + // amoutn, basicEffectId, stepOrder, target (also itemfromstep) + console.log(effect['step'][key]); + + console.log('--- Effect Step ---'); + let effectStep = effect['step'][key]; + console.log(basicEffects[effectStep['basicEffectId']]); + + console.log('--- Effect Step Amount ---'); + console.log(effectStep['amount']); + + // Loop targets for effectStep + effectStep['target'].forEach((effectStepTarget) => { + console.log('--- Effect Step Target ---'); + console.log(effectStepTarget.classId); + console.log(effectStepTarget.colourId); + console.log(effectStepTarget.passiveId); + console.log(effectStepTarget.typeId); + console.log(effectStepTarget.itemFromStep); + }); + + } + + }); + +} diff --git a/public/effect.js b/public/effect.js index f10c2c6..5140ddc 100644 --- a/public/effect.js +++ b/public/effect.js @@ -4,6 +4,22 @@ let reach = {}; let equipped = {}; // Entity x has [a,b,c] equipped to it +// Trigger types +const triggerTypes = { + 1: 'Tap', + 2: 'Pay', +}; +// Basic effects +// TODO: Pull display name/description from DB? +const basicEffects = { + 1: 'Equip', + 2: 'Heal', + 3: 'Hurt', + 4: 'Recruit', + 5: 'Give Flight', +}; + + // Actives to add passives function giveFlight(card){ flight[card] = true;