From 1c9b390551beb5f85c13f6d16126224b2f24c0ed Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Sun, 9 Oct 2022 23:11:06 +0200 Subject: [PATCH] Added ritual casting --- app/imports/api/engine/actions/doCastSpell.js | 21 +++++-- .../character/characterSheetTabs/StatsTab.vue | 3 +- .../spells/CastSpellWithSlotDialog.vue | 59 ++++++++++++------- .../ui/properties/viewers/ActionViewer.vue | 3 +- 4 files changed, 59 insertions(+), 27 deletions(-) diff --git a/app/imports/api/engine/actions/doCastSpell.js b/app/imports/api/engine/actions/doCastSpell.js index 628e31d7..851ac0c2 100644 --- a/app/imports/api/engine/actions/doCastSpell.js +++ b/app/imports/api/engine/actions/doCastSpell.js @@ -20,6 +20,10 @@ const doAction = new ValidatedMethod({ regEx: SimpleSchema.RegEx.Id, optional: true, }, + ritual: { + type: Boolean, + optional: true, + }, targetIds: { type: Array, defaultValue: [], @@ -41,7 +45,7 @@ const doAction = new ValidatedMethod({ numRequests: 10, timeInterval: 5000, }, - run({ spellId, slotId, targetIds = [], scope = {} }) { + run({ spellId, slotId, ritual, targetIds = [], scope = {} }) { // Get action context let spell = CreatureProperties.findOne(spellId); const creatureId = spell.ancestors[0].id; @@ -64,7 +68,8 @@ const doAction = new ValidatedMethod({ let slotLevel = spell.level || 0; let slot; - if (slotId && !spell.castWithoutSpellSlots) { + // If a spell requires a slot, make sure a slot is spent + if (!spell.castWithoutSpellSlots && !(ritual && spell.ritual)) { slot = CreatureProperties.findOne(slotId); if (!slot) { throw new Meteor.Error('No slot', @@ -101,9 +106,15 @@ const doAction = new ValidatedMethod({ name: `Casting using a level ${slotLevel} spell slot` }); } else if (slotLevel) { - actionContext.addLog({ - name: `Casting at level ${slotLevel}` - }); + if (ritual) { + actionContext.addLog({ + name: `Ritual casting at level ${slotLevel}` + }); + } else { + actionContext.addLog({ + name: `Casting at level ${slotLevel}` + }); + } } actionContext.scope['slotLevel'] = slotLevel; diff --git a/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue b/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue index 1e9e609c..e8122e32 100644 --- a/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue +++ b/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue @@ -515,11 +515,12 @@ export default { data: { creatureId: this.creatureId, }, - callback({ spellId, slotId, advantage } = {}) { + callback({ spellId, slotId, advantage, ritual } = {}) { if (!spellId) return; doCastSpell.call({ spellId, slotId, + ritual, scope: { $attackAdvantage: advantage, }, diff --git a/app/imports/ui/properties/components/spells/CastSpellWithSlotDialog.vue b/app/imports/ui/properties/components/spells/CastSpellWithSlotDialog.vue index cf9cf288..dfdc0160 100644 --- a/app/imports/ui/properties/components/spells/CastSpellWithSlotDialog.vue +++ b/app/imports/ui/properties/components/spells/CastSpellWithSlotDialog.vue @@ -91,6 +91,20 @@ + + + + Cast as ritual + + +