- Updated changelog
- Added fields for temporary attack buffs
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<li>Added Sphere extensions from The Complete Book of Necromancers</li>
|
||||
<li>Added fields to keep track of Psionic Primary and Secondary Disciplines</li>
|
||||
<li>Added help text for Psionic Disciplines</li>
|
||||
<li>Added fields to track temporary attack, damage, and speed buffs</li>
|
||||
<li>Added buttons do deal critical damage, to the standard weapons. This follows the first description of the Dungeon Master Guide</li>
|
||||
<li>Added target size to output text when rolling damage (Small/Medium or Large)</li>
|
||||
<li>Added styling for the sheet settings table</li>
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<li>Added Sphere extensions from The Complete Book of Necromancers</li>
|
||||
<li>Added fields to keep track of Psionic Primary and Secondary Disciplines</li>
|
||||
<li>Added help text for Psionic Disciplines</li>
|
||||
<li>Added fields to track temporary attack, damage, and speed buffs</li>
|
||||
<li>Added buttons do deal critical damage, to the standard weapons. This follows the first description of the Dungeon Master Guide</li>
|
||||
<li>Added target size to output text when rolling damage (Small/Medium or Large)</li>
|
||||
<li>Added styling for the sheet settings table</li>
|
||||
|
||||
@@ -128,13 +128,13 @@
|
||||
<tr>
|
||||
<td>The Complete Druid's Handbook</td>
|
||||
<td>Animal & Plant Sphere Expansions</td>
|
||||
<td><label><input type='checkbox' name='attr_sphere-druids' title="@{sphere-druids}" value="Animal & Plant expansion"/><span></span></label></td>
|
||||
<td><label><input type='checkbox' name='attr_sphere-druids' title="@{sphere-druids}" value="sphere-druids"/><span></span></label></td>
|
||||
<td>Page. 86</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>The Complete Book of Necromancers</td>
|
||||
<td>Necromantic Sphere Expansion</td>
|
||||
<td><label><input type='checkbox' name='attr_sphere-necromancers' title="@{sphere-necromancers}" value="Necromantic expansion"/><span></span></label></td>
|
||||
<td><label><input type='checkbox' name='attr_sphere-necromancers' title="@{sphere-necromancers}" value="sphere-necromancers"/><span></span></label></td>
|
||||
<td>Page 77 + 126</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -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']});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user