Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@
"enable": "Show biography",
"disable": "Hide biography"
},

"Spellcasting": {
"preparedSpellcasting": "Spellcasting",
"pactSpellcasting": "Spellcasting",
"innateSpellcasting": "Innate Spellcasting",
"psionicSpellcasting": "Spellcasting (Psionics)",
"Cantrip": "Cantrip",
"CantripPl": "Cantrips",
"AtWill": "at will",
"preparedCasterText":
"The {{name}} is {{#if (or (eq level 8) (eq level 18))}}an{{else}}a{{/if}} {{{nth}}}-level spellcaster. Its spellcasting ability is {{{ability}}} (spell save DC {{dc}}, {{tohit}} to hit with spell attacks). The {{name}} {{#if hasAtWill}}can cast {{{spells}}} at will and {{/if}}has the following spells prepared:",
"pactCasterText":
"The {{name}} is {{#if (or (eq level 8) (eq level 18))}}an{{else}}a{{/if}} {{{nth}}}-level spellcaster. Its spellcasting ability is {{{ability}}} (spell save DC {{dc}}, {{tohit}} to hit with spell attacks). It regains its expended spell slots when it finishes a short or long rest. It knows the following warlock spells:",
"innateCasterText":
"The {{name}} spellcasting ability is {{{ability}}} (spell save DC {{dc}}). It can innately cast the following spells, requiring no material components:",
"fullCasterText":
"The {{name}} is {{#if (or (eq level 8) (eq level 18))}}an{{else}}a{{/if}} {{{nth}}}-level spellcaster. Its spellcasting ability is {{{ability}}} (spell save DC {{dc}}, {{tohit}} to hit with spell attacks). The {{name}} {{#if hasAtWill}}can cast {{{spells}}} at will and {{/if}}has the following spells prepared:",
"spellcastingActionText":
"The {{name}} casts one of the following spells, using {{{ability}}} as the spellcasting ability (spell save DC {{dc}}):"
},

"MonsterBlocks": "Monster Blocks",

Expand Down
11 changes: 9 additions & 2 deletions monsterblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ Hooks.once("ready", () => {
// This is how the box sizing is corrected to fit the statblock
// eslint-disable-next-line no-unused-vars
Hooks.on("renderMonsterBlock5e", (monsterblock, html, data) => { // When the sheet is rendered
if (debug.INFO) console.log("Monster Block | Rendering sheet");
if (debug.DEBUG) console.debug(`Monster Block |`, monsterblock, html, data);
const label = "Monster Block | Rendering sheet";
if (debug.DEBUG) {
console.group(label);
console.log("Sheet: ", monsterblock);
console.log("HTML: ", html);
console.log("Template Data:", data);
console.groupEnd(label);
}
else if (debug.INFO) console.log(label);

if (html.parent().hasClass("grid-cell-content")) return;

Expand Down
2 changes: 1 addition & 1 deletion scripts/dnd5e/CastingPreper.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class CastingPreper extends ItemPreper {
* @override
* @memberof CastingPreper
*/
prepare() {
prepare() {
this.data.castingType = this.constructor.isSpellcasting(this.item) ?
(this.constructor.isPactMagic(this.item) ? this.cts.pact : this.cts.standard) : this.cts.innate;

Expand Down
43 changes: 36 additions & 7 deletions scripts/dnd5e/ItemPrep.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import ActionPreper from "./ActionPreper.js";
import ItemPreper from "./ItemPreper.js";
import InnateSpellbookPrep from "./InnateSpellbookPrep.js"

import SpellBook from "./SpellBook.js";
import { debug } from "../utilities.js";

/**
* @typedef {import{"../../../../systems/dnd5e/module/item/sheet.js"}.Item5e} Item5e
*/
Expand Down Expand Up @@ -38,11 +41,13 @@ export default class ItemPrep {

/** @type {Object.<string, Feature>} A set of item classifications by type */
features = {
spells: { prep: ItemPreper, filter: item => item.type === "spell", items: [], dataset: {type: "feat"} },
legResist: { prep: ItemPreper, filter: MonsterBlock5e.isLegendaryResistance, items: [], dataset: {type: "feat"} },
legendary: { prep: ActionPreper, filter: MonsterBlock5e.isLegendaryAction, items: [], dataset: {type: "feat"} },
lair: { prep: ActionPreper, filter: MonsterBlock5e.isLairAction, items: [], dataset: {type: "feat"} },
multiattack: { prep: ActionPreper, filter: MonsterBlock5e.isMultiAttack, items: [], dataset: {type: "feat"} },
casting: { prep: CastingPreper, filter: CastingPreper.isCasting.bind(CastingPreper), items: [], dataset: {type: "feat"} },
//casting: { prep: CastingPreper, filter: CastingPreper.isCasting.bind(CastingPreper), items: [], dataset: {type: "feat"} },
casting: { prep: ItemPreper, filter: CastingPreper.isCasting.bind(CastingPreper), items: [], dataset: {type: "feat"} },
reaction: { prep: ActionPreper, filter: MonsterBlock5e.isReaction, items: [], dataset: {type: "feat"} },
bonusActions: { prep: ActionPreper, filter: MonsterBlock5e.isBonusAction, items: [], dataset: {type: "feat"} },
attacks: { prep: AttackPreper, filter: item => item.type === "weapon", items: [], dataset: {type: "weapon"} },
Expand All @@ -57,20 +62,44 @@ export default class ItemPrep {
* @memberof ItemPrep
*/
prepareItems() {
const [other, spells] = this.data.items.partition(item => item.type === "spell");
this.organizeSpellbooks(spells);
this.organizeFeatures(other);
this.organizeFeatures(this.data.items);

if (this.data.features.spells.items.length)
this.organizeSpellbooks(this.data.features.spells.items);
}

/**
* Prepares and organizes the regular and innate spellbooks
* Prepares and organizes the spellbooks
*
* @param {array} spells - All the spell items
* @memberof ItemPrep
*/
organizeSpellbooks(spells) {
this.data.spellbook = this.sheet._prepareSpellbook(this.data, spells);
this.data.innateSpellbook = new InnateSpellbookPrep(this.data.spellbook, this.sheet).prepare();
const spellbook = new SpellBook(this.sheet, spells, null, "full");

const spellbooks = {
"full": spellbook,
"prepared": spellbook.getPrepared(),
"innate": spellbook.getInnate(),
"pact": spellbook.getPact(),
}

Object.values(spellbooks).forEach(book => {
if (!book.hasPages) book.show = false;
});
spellbooks.full.show = false;

this.data.spellbooks = spellbooks;

if (debug.DEBUG) {
const label = "Monster Blocks | Spellbook";
console.group(label);
console.log("Full: ", this.data.spellbooks.full);
console.log("Prepared:", this.data.spellbooks.prepared);
console.log("Innate ", this.data.spellbooks.innate);
console.log("Pact ", this.data.spellbooks.pact);
console.groupEnd(label);
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions scripts/dnd5e/MonsterBlock5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { debug, ContentEditableAdapter, getTranslationArray } from "../utilities
import { inputExpression } from "../../input-expressions/handler.js";
import ItemPrep from "./ItemPrep.js";
import Flags from "./Flags5e.js";
import StatGetter from "./StatGetter.js";

/* global QuickInsert:readonly */

Expand All @@ -22,6 +23,7 @@ export default class MonsterBlock5e extends ActorSheet5eNPC {
this.position.default = true;

this.flagManager = new Flags(this);
this.statGetter = new StatGetter(this, this.actor);

//this.flagManager.prep().then((p) => {
this.options.classes.push(this.themes[this.currentTheme].class);
Expand Down Expand Up @@ -1253,6 +1255,11 @@ export default class MonsterBlock5e extends ActorSheet5eNPC {
"modules/monsterblock/templates/dnd5e/parts/main/legendaryActs.hbs",
"modules/monsterblock/templates/dnd5e/parts/main/lairActs.hbs",

"modules/monsterblock/templates/dnd5e/parts/spellcasting/spellcasting-redux.hbs",
"modules/monsterblock/templates/dnd5e/parts/spellcasting/spellbook.hbs",
"modules/monsterblock/templates/dnd5e/parts/spellcasting/spellbook-page.hbs",
"modules/monsterblock/templates/dnd5e/parts/spellcasting/spell-list.hbs",

"modules/monsterblock/templates/dnd5e/parts/menuItem.hbs",
"modules/monsterblock/templates/dnd5e/parts/resource.hbs",
"modules/monsterblock/templates/dnd5e/parts/featureBlock.hbs",
Expand Down
Loading