Added ritual casting

This commit is contained in:
Stefan Zermatten
2022-10-09 23:11:06 +02:00
parent 21a487635d
commit 1c9b390551
4 changed files with 59 additions and 27 deletions

View File

@@ -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;