diff --git a/ADnD 2E Revised/2ESheet.html b/ADnD 2E Revised/2ESheet.html
index fa13478c6e..ecb7cba3f2 100644
--- a/ADnD 2E Revised/2ESheet.html
+++ b/ADnD 2E Revised/2ESheet.html
@@ -16,6 +16,7 @@
Added Sphere extensions from The Complete Book of Necromancers
Added fields to keep track of Psionic Primary and Secondary Disciplines
Added help text for Psionic Disciplines
+
Added fields to track temporary attack, damage, and speed buffs
Added buttons do deal critical damage, to the standard weapons. This follows the first description of the Dungeon Master Guide
Added target size to output text when rolling damage (Small/Medium or Large)
Added styling for the sheet settings table
@@ -45045,7 +45046,7 @@ function isSpellAvailable(spellName, spell, availableSpheres, elementalSpheres,
let spheres = getSpellSpheres(spellName, spell, optionalSpheres);
let primarySpellSpheres = spheres.match(noElementalRegex) || [];
- let isAvailable = primarySpellSpheres.some((sphere) => availableSpheres.has(sphere));
+ let isAvailable = primarySpellSpheres.some(sphere => availableSpheres.has(sphere));
if (isAvailable)
return true;
diff --git a/ADnD 2E Revised/html/changelog.html b/ADnD 2E Revised/html/changelog.html
index 93915c0a83..af99793e3f 100644
--- a/ADnD 2E Revised/html/changelog.html
+++ b/ADnD 2E Revised/html/changelog.html
@@ -11,6 +11,7 @@
Added Sphere extensions from The Complete Book of Necromancers
Added fields to keep track of Psionic Primary and Secondary Disciplines
Added help text for Psionic Disciplines
+
Added fields to track temporary attack, damage, and speed buffs
Added buttons do deal critical damage, to the standard weapons. This follows the first description of the Dungeon Master Guide
Added target size to output text when rolling damage (Small/Medium or Large)
Added styling for the sheet settings table
diff --git a/ADnD 2E Revised/html/tabs/sheet-settings.html b/ADnD 2E Revised/html/tabs/sheet-settings.html
index 940f8eb882..17c01ce9de 100644
--- a/ADnD 2E Revised/html/tabs/sheet-settings.html
+++ b/ADnD 2E Revised/html/tabs/sheet-settings.html
@@ -128,13 +128,13 @@
The Complete Druid's Handbook
Animal & Plant Sphere Expansions
-
+
Page. 86
The Complete Book of Necromancers
Necromantic Sphere Expansion
-
+
Page 77 + 126
diff --git a/ADnD 2E Revised/javascript/sheetWorkers.js b/ADnD 2E Revised/javascript/sheetWorkers.js
index 675b655d05..98a8549725 100644
--- a/ADnD 2E Revised/javascript/sheetWorkers.js
+++ b/ADnD 2E Revised/javascript/sheetWorkers.js
@@ -15,6 +15,13 @@ const SCHOOL_FIELDS = ['school-spells&magic'];
const SPHERE_FIELDS = ['sphere-druids', 'sphere-necromancers', 'sphere-spells&magic'];
//#region Helper function
+function capitalizeFirst(s) {
+ if (typeof s !== 'string')
+ return '';
+
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
+}
+
const conditionalLog = function (bool, msg) {
if (b)
console.log(msg);
@@ -26,6 +33,17 @@ const extractQueryResult = async function(query){//Sends a message to query the
return queryRoll.results.query.expression.replace(/^.+?response=|\]$/g,'');
};
+const extractRoll = async function(rollExpression) {
+ let queryRoll = await startRoll(`!{{roll=[[${rollExpression}]]}}`);
+ finishRoll(queryRoll.rollId);
+ return queryRoll.results.roll;
+};
+
+const extractRollResult = async function(rollExpression) {
+ let roll = await extractRoll(rollExpression);
+ return roll.result;
+};
+
const isRollValid = function (rollExpression, field) {
let expression = rollExpression.trim();
if (!expression)
@@ -62,17 +80,6 @@ const isRollValid = function (rollExpression, field) {
return true;
}
-const extractRoll = async function(rollExpression) {
- let queryRoll = await startRoll(`!{{roll=[[${rollExpression}]]}}`);
- finishRoll(queryRoll.rollId);
- return queryRoll.results.roll;
-};
-
-const extractRollResult = async function(rollExpression) {
- let roll = await extractRoll(rollExpression);
- return roll.result;
-};
-
const calculateFormula = async function(formulaField, calculatedField, silent = false) {
getAttrs([formulaField], async function (values) {
let rollExpression = values[formulaField];
@@ -106,8 +113,14 @@ const showToast = function(type, title, message) {
setAttrs(getToastObject(type, title, message));
}
+const getActiveSettings = function (settingFields, values) {
+ return settingFields.map(bField => values[bField])
+ .filter(Boolean)
+ .filter(book => book !== '0')
+}
+
const isBookInactive = function (books, obj) {
- let activeBooks = BOOK_FIELDS.map(bField => books[bField]);
+ let activeBooks = getActiveSettings(BOOK_FIELDS, books);
return !activeBooks.includes(obj['book']);
}
@@ -711,12 +724,6 @@ const PRIEST_SPHERES = [
const primarySphereRegex = new RegExp(PRIEST_SPHERES.join('|'), 'gi');
const noElementalRegex = new RegExp(PRIEST_SPHERES.filter(s => s !== ELEMENTAL).join('|'), 'gi');
const elementalRegex = /Earth|Air|Fire|Water/gi
-function capitalizeFirst(s) {
- if (typeof s !== 'string')
- return '';
-
- return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
-}
function parseSpheres(spheresStrings, regex) {
let spheres = new Set();
@@ -728,25 +735,34 @@ function parseSpheres(spheresStrings, regex) {
return spheres;
}
-function isSpellAvailable(spellName, spell, availableSpheres, elementalSpheres, activeBooks) {
- if (isBookInactive(activeBooks, spell))
+const getSpellSpheres = function (spellName, spell, sphereRules) {
+ let sphere = spell['sphere'];
+ sphereRules.forEach(rule => sphere += spell[rule] || '');
+ return sphere;
+}
+
+function isSpellAvailable(spellName, spell, availableSpheres, elementalSpheres, activeBooks, optionalSpheres) {
+ if (!activeBooks.includes(spell['book']))
return false;
- let primarySpellSpheres = spell['sphere'].match(noElementalRegex) || [];
- let isAvailable = primarySpellSpheres.some((sphere) => availableSpheres.has(sphere));
+ let spheres = getSpellSpheres(spellName, spell, optionalSpheres);
+
+ let primarySpellSpheres = spheres.match(noElementalRegex) || [];
+ let isAvailable = primarySpellSpheres.some(sphere => availableSpheres.has(sphere));
if (isAvailable)
return true;
if (!availableSpheres.has(ELEMENTAL))
return false;
- if (!spell['sphere'].includes(ELEMENTAL))
+ if (!spheres.includes(ELEMENTAL))
return false;
- if (spell['sphere'].includes(`${ELEMENTAL} (`))
- return spell['sphere'].match(elementalRegex).some((element) => elementalSpheres.has(element))
+ if (spheres.includes(`${ELEMENTAL} (`))
+ return spheres.match(elementalRegex).some((element) => elementalSpheres.has(element))
// The player and the spell has the elemental sphere (without any sub elements)
+ // Currently only 'Commune With Nature' in the revised Player's Handbook (1995) has this property
return true;
}
@@ -762,7 +778,7 @@ function setupAddPriestSpell(postfix) {
sphereFields.push("sphere-minor");
TAS.repeating(section)
- .attrs([...sphereFields, ...BOOK_FIELDS])
+ .attrs([...sphereFields, ...BOOK_FIELDS, ...SPHERE_FIELDS])
.fields(field)
.reduce(function(knownSpells, row){
knownSpells.add(row.S[field]);
@@ -776,9 +792,14 @@ function setupAddPriestSpell(postfix) {
return;
}
+ let activeBooks = getActiveSettings(BOOK_FIELDS, attrSet);
+ let optionalSpheres = getActiveSettings(SPHERE_FIELDS, attrSet);
+ console.log(activeBooks);
+ console.log(optionalSpheres);
+
let spellsToAdd = [];
for (const [spellName, spell] of Object.entries(priestSpells[postfix])) {
- let isAvailable = isSpellAvailable(spellName, spell, primarySpheres, elementalSpheres, attrSet);
+ let isAvailable = isSpellAvailable(spellName, spell, primarySpheres, elementalSpheres, activeBooks, optionalSpheres);
if (isAvailable) {
spellsToAdd.push({name: spellName, book: spell['book']});
}