diff --git a/ADnD 2E Revised/2ESheet.html b/ADnD 2E Revised/2ESheet.html index 1c32ff0ce7..35c012e3a8 100644 --- a/ADnD 2E Revised/2ESheet.html +++ b/ADnD 2E Revised/2ESheet.html @@ -18003,6 +18003,11 @@ Weapons + + The Complete Thief's Handbook + Proficiencies + + The Complete Wizard's Handbook Spells @@ -18020,7 +18025,7 @@
- +
@@ -33045,7 +33050,7 @@ const INFO = 'info'; const WARNING = 'warning'; const ERROR = 'error'; -const BOOK_FIELDS = ['book-phb', 'book-tcfhb', 'book-tcwhb']; +const BOOK_FIELDS = ['book-phb', 'book-tcfhb', 'book-tcthb', 'book-tcwhb']; on('clicked:hide-toast', function(eventInfo) { setAttrs({ @@ -33070,8 +33075,11 @@ function showToast(type, title, message) { }); } -function isBookInactive(books, obj) { - return !Object.values(books).includes(obj['book']); +function bookInactiveShowToast(books, obj) { + let bookInactive = !Object.values(books).includes(obj['book']); + if (bookInactive) + showToast(ERROR, 'Missing Book', `The book *${obj['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`); + return bookInactive; } const squareBracketsRegex = /18\[([0-9]{1,3})]/; // Ie. 18[65] @@ -33578,10 +33586,8 @@ function setupAutoFillSpellInfo(section, spellsTable, levelFunc) { return; getAttrs(BOOK_FIELDS, function(books) { - if (isBookInactive(books, spell)) { - showToast(ERROR, 'Missing Book', `The book *${spell['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`); + if (bookInactiveShowToast(books, spell)) return; - } let spellInfo = { [`repeating_spells-${section}_spell-cast-time`] : spell['cast-time'], @@ -34024,10 +34030,8 @@ function setWeaponWithBonus(weaponName, setWeaponFunc, isMonster) { getAttrs(BOOK_FIELDS, function(books) { let baseWeapon = weapons[weaponName]; if (baseWeapon) { - if (isBookInactive(books, baseWeapon)) { - showToast(ERROR, 'Missing Book', `The book *${baseWeapon['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`) + if (bookInactiveShowToast(books, baseWeapon)) return; - } setWeaponFunc({ ...baseWeapon, @@ -34045,10 +34049,8 @@ function setWeaponWithBonus(weaponName, setWeaponFunc, isMonster) { if (!baseWeapon) return; - if (isBookInactive(books, baseWeapon)) { - showToast(ERROR, 'Missing Book', `The book *${baseWeapon['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`) + if (bookInactiveShowToast(books, baseWeapon)) return; - } let bonusString = match[1]; let bonus = parseInt(bonusString) @@ -34292,10 +34294,15 @@ on('change:repeating_profs:profname', function (eventInfo) { if (nonweaponProficiency === undefined) return; - setAttrs({ - 'repeating_profs_profslots' : nonweaponProficiency['slots'], - 'repeating_profs_profstatnum': nonweaponProficiency['abilityScore'], - 'repeating_profs_profmod' : nonweaponProficiency['modifier'], + getAttrs(BOOK_FIELDS, function (books) { + if (bookInactiveShowToast(books, nonweaponProficiency)) + return; + + setAttrs({ + 'repeating_profs_profslots' : nonweaponProficiency['slots'], + 'repeating_profs_profstatnum': nonweaponProficiency['abilityScore'], + 'repeating_profs_profmod' : nonweaponProficiency['modifier'], + }); }); }); diff --git a/ADnD 2E Revised/html/2ESheet-base.html b/ADnD 2E Revised/html/2ESheet-base.html index e7b000c7e1..c986909738 100644 --- a/ADnD 2E Revised/html/2ESheet-base.html +++ b/ADnD 2E Revised/html/2ESheet-base.html @@ -12609,6 +12609,11 @@ Weapons + + The Complete Thief's Handbook + Proficiencies + + The Complete Wizard's Handbook Spells @@ -12626,7 +12631,7 @@

- +
diff --git a/ADnD 2E Revised/javascript/sheetWorkers.js b/ADnD 2E Revised/javascript/sheetWorkers.js index 2d7d227329..0050ef5434 100644 --- a/ADnD 2E Revised/javascript/sheetWorkers.js +++ b/ADnD 2E Revised/javascript/sheetWorkers.js @@ -7,7 +7,7 @@ const INFO = 'info'; const WARNING = 'warning'; const ERROR = 'error'; -const BOOK_FIELDS = ['book-phb', 'book-tcfhb', 'book-tcwhb']; +const BOOK_FIELDS = ['book-phb', 'book-tcfhb', 'book-tcthb', 'book-tcwhb']; on('clicked:hide-toast', function(eventInfo) { setAttrs({ @@ -32,8 +32,11 @@ function showToast(type, title, message) { }); } -function isBookInactive(books, obj) { - return !Object.values(books).includes(obj['book']); +function bookInactiveShowToast(books, obj) { + let bookInactive = !Object.values(books).includes(obj['book']); + if (bookInactive) + showToast(ERROR, 'Missing Book', `The book *${obj['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`); + return bookInactive; } const squareBracketsRegex = /18\[([0-9]{1,3})]/; // Ie. 18[65] @@ -540,10 +543,8 @@ function setupAutoFillSpellInfo(section, spellsTable, levelFunc) { return; getAttrs(BOOK_FIELDS, function(books) { - if (isBookInactive(books, spell)) { - showToast(ERROR, 'Missing Book', `The book *${spell['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`); + if (bookInactiveShowToast(books, spell)) return; - } let spellInfo = { [`repeating_spells-${section}_spell-cast-time`] : spell['cast-time'], @@ -986,10 +987,8 @@ function setWeaponWithBonus(weaponName, setWeaponFunc, isMonster) { getAttrs(BOOK_FIELDS, function(books) { let baseWeapon = weapons[weaponName]; if (baseWeapon) { - if (isBookInactive(books, baseWeapon)) { - showToast(ERROR, 'Missing Book', `The book *${baseWeapon['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`) + if (bookInactiveShowToast(books, baseWeapon)) return; - } setWeaponFunc({ ...baseWeapon, @@ -1007,10 +1006,8 @@ function setWeaponWithBonus(weaponName, setWeaponFunc, isMonster) { if (!baseWeapon) return; - if (isBookInactive(books, baseWeapon)) { - showToast(ERROR, 'Missing Book', `The book *${baseWeapon['book']}* is currently not active on your sheet.\nGo to the *Sheet Settings* and activate the book (if your DM allows for its usage)`) + if (bookInactiveShowToast(books, baseWeapon)) return; - } let bonusString = match[1]; let bonus = parseInt(bonusString) @@ -1254,10 +1251,15 @@ on('change:repeating_profs:profname', function (eventInfo) { if (nonweaponProficiency === undefined) return; - setAttrs({ - 'repeating_profs_profslots' : nonweaponProficiency['slots'], - 'repeating_profs_profstatnum': nonweaponProficiency['abilityScore'], - 'repeating_profs_profmod' : nonweaponProficiency['modifier'], + getAttrs(BOOK_FIELDS, function (books) { + if (bookInactiveShowToast(books, nonweaponProficiency)) + return; + + setAttrs({ + 'repeating_profs_profslots' : nonweaponProficiency['slots'], + 'repeating_profs_profstatnum': nonweaponProficiency['abilityScore'], + 'repeating_profs_profmod' : nonweaponProficiency['modifier'], + }); }); }); diff --git a/ADnD 2E Revised/sheet.json b/ADnD 2E Revised/sheet.json index 6c4d966bf6..673616ee88 100644 --- a/ADnD 2E Revised/sheet.json +++ b/ADnD 2E Revised/sheet.json @@ -19,7 +19,15 @@ "type": "checkbox", "value": "The Complete Fighter's Handbook", "checked": false, - "description": "Allows weapons from The Complete Fighter's Handbook to autofill" + "description": "Includes Weapons" + }, + { + "attribute": "book-tcthb", + "displayname": "The Complete Thief's Handbook", + "type": "checkbox", + "value": "The Complete Thief's Handbook", + "checked": false, + "description": "Includes Proficiencies" }, { "attribute": "book-tcwhb", @@ -27,7 +35,7 @@ "type": "checkbox", "value": "The Complete Wizard's Handbook", "checked": false, - "description": "Allows spells from The Complete Wizard's Handbook to autofill" + "description": "Includes Spells" }, { "displayname": " "