Skip to content
Open
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
2 changes: 1 addition & 1 deletion input-expressions
Submodule input-expressions updated 1 files
+3 −3 handler.js
6 changes: 2 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"id": "monsterblock",
"title": "Monster Blocks",
"description": "An NPC sheet designed to emulate standard 5e monster stat blocks as faithfully as possible.",
"author": "zeel",
"authors": [
{
"name": "zeel",
Expand All @@ -11,7 +10,7 @@
"discord": "zeel#4200"
}
],
"version": "3.5.1",
"version": "3.6.0",
"compatibility": {
"minimum": "10",
"verified": "12"
Expand All @@ -21,7 +20,7 @@
{
"id": "dnd5e",
"compatibility": {
"verified": "4.1.2"
"verified": "4.3.6"
}
}
],
Expand Down Expand Up @@ -66,7 +65,6 @@
"download": "https://github.com/zeel01/MonsterBlocks/releases/latest/download/monsterblock.zip",
"readme": "https://github.com/zeel01/MonsterBlocks/blob/master/readme.md",
"bugs": "https://github.com/zeel01/MonsterBlocks/issues",
"allowBugReporter": true,
"changelog": "https://github.com/zeel01/MonsterBlocks/releases",
"media": [
{
Expand Down
12 changes: 7 additions & 5 deletions scripts/dnd5e/CastingPreper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default class CastingPreper extends ItemPreper {
*/
static isInnateSpellcasting(item) {
const name = item.name.toLowerCase().replace(/\s+/g, "") ?? "";
if (getTranslationArray("MOBLOKS5E.SpellcastingLocators").some(loc => name.includes(loc)) && item.system.activities?.some(a => a.type === "cast")) return true;

return getTranslationArray("MOBLOKS5E.InnateCastingLocators").some(loc => name.includes(loc));
}
/**
Expand Down Expand Up @@ -332,7 +334,7 @@ export default class CastingPreper extends ItemPreper {
* @memberof CastingPreper
*/
get casterLevel() {
return this.sheet.actor.system.details?.spellLevel ?? 0;
return this.sheet.actor.system.attributes?.spell?.level ?? this.sheet.actor.system.details?.spellLevel ?? 0;
}

/**
Expand Down Expand Up @@ -452,7 +454,7 @@ export default class CastingPreper extends ItemPreper {
*/
get casterStatsText() {
return game.i18n.format("MOBLOKS5E.CastingStats", {
savedc: this.sheet.actor.system?.attributes?.spelldc,
savedc: this.sheet.actor.system?.attributes?.spell?.dc ?? this.sheet.actor.system?.attributes?.spelldc,
bonus: `${this.tohit > -1 ? "+" : ""}${this.tohit}`
})
}
Expand Down Expand Up @@ -557,10 +559,10 @@ export default class CastingPreper extends ItemPreper {

if (spelllevel !== undefined) {
let spell = spelllevel.spells.find((s) =>
s.system.ability &&
s.system.ability != main
s.system.abilityMod &&
s.system.abilityMod != main
);
castingability = spell?.data?.ability ?? main;
castingability = spell?.system?.ability ?? main;
}

return [
Expand Down
12 changes: 8 additions & 4 deletions scripts/dnd5e/InnateSpellbookPrep.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export default class InnateSpellbookPrep {
* @return {object} The completed innate spellbook
* @memberof InnateSpellbookPrep
*/
prepare() { // We need to completely re-organize the spellbook for an innate spellcaster
for (let level of this.spellbook) { // Spellbook is seperated into sections based on level, though all the innate spells are lumped together, we still want to check all the sections.
if (level.prop !== "innate") continue; // We don't care about sections that aren't marked as innate though
prepare() { // We need to completely re-organize the spellbook for an innate spellcaster
for (let level of this.spellbook) { // Spellbook is seperated into sections based on level, though all the innate spells are lumped together, we still want to check all the sections.
if (!["innate", "atwill"].includes(level.prop) && !level.spells.some(s => s.getFlag("dnd5e", "cachedFor"))) continue; // We don't care about sections that aren't marked as innate though
this.prepareSpellLevel(level);
}

Expand Down Expand Up @@ -69,7 +69,11 @@ export default class InnateSpellbookPrep {
*/
sortSpell(spell) {
// Max uses is what we are going to end up sorting the spellbook by.
this.getPage(spell.system.uses.max).spells.push(spell);
let uses = spell.system.uses.max;
if (spell.getFlag("dnd5e", "cachedFor")) {
uses = fromUuidSync(spell.getFlag("dnd5e", "cachedFor"), {relative: this.sheet.object}).uses.max;
}
this.getPage(uses).spells.push(spell);
}

/**
Expand Down
12 changes: 8 additions & 4 deletions scripts/dnd5e/MonsterBlock5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export default class MonsterBlock5e extends dnd5e.applications.actor.ActorSheet5

for (let fk of Object.keys(data.features)) {
for (let item of data.features[fk].items) {
const value = await TextEditor.enrichHTML(item.system.description.value, { secrets: (data.owner && !data.flags["hidden-secrets"])});
const value = await TextEditor.enrichHTML(item.system.description.value, { relativeTo: item, secrets: (data.owner && !data.flags["hidden-secrets"])});
item.enrichedValue = value;
item.rechargeValue = isDndV4OrNewer() ? item.system.uses.recovery.find(r => r.period === "recharge")?.formula : item.system.recharge?.value;
item.activationCost = isDndV4OrNewer() ? item.system.activities.find(a => a.activation.value)?.activation.value : item.system.activation?.cost;
item.rechargeValue = isDndV4OrNewer() ? item.system.uses?.recovery.find(r => r.period === "recharge")?.formula : item.system.recharge?.value;
item.activationCost = isDndV4OrNewer() ? item.system.activities?.find(a => a.activation.value)?.activation.value : item.system.activation?.cost;
}
}

Expand Down Expand Up @@ -130,6 +130,7 @@ export default class MonsterBlock5e extends dnd5e.applications.actor.ActorSheet5
data.themes = this.themes;

data.sourceStringId = game.i18n.has("DND5E.Source") ? "DND5E.Source" : "DND5E.SOURCE.FIELDS.source.label";
data.legActTitleId = game.i18n.has("DND5E.LegAct") ? "DND5E.LegAct" : "DND5E.NPC.SECTIONS.LegendaryActions";

this.templateData = data;
return data;
Expand Down Expand Up @@ -604,7 +605,10 @@ export default class MonsterBlock5e extends dnd5e.applications.actor.ActorSheet5
}
prepAbilities(data) {
Object.entries(data.abilities)?.forEach(
([id, ability]) => ability.abbr = game.i18n.localize("MOBLOKS5E.Abbr" + id)
([id, ability]) => {
ability.abbr = game.i18n.localize("MOBLOKS5E.Abbr" + id);
ability.saveValue = ability.save.value ?? ability.save;
}
)
}
/**
Expand Down
6 changes: 6 additions & 0 deletions templates/dnd5e/parts/header/attributes/damage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
{{trait.physical}}
</span>
{{~/if~}}
{{~#if trait.custom}}
<span>
{{localize "MOBLOKS5E.SemiColon"}}
{{trait.custom}}
</span>
{{~/if~}}
</span>
</li>
{{/if}}
4 changes: 2 additions & 2 deletions templates/dnd5e/parts/header/attributes/saves.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<li class="saving-throw {{#if ability.proficient}}proficient{{/if}}" data-ability="{{id}}"
title="{{ability.label}}">
<span class="ability-title">{{ability.label}}</span>
<span>{{numberFormat ability.save decimals=0 sign=true}}</span>{{~" "~}}
<span>{{numberFormat ability.saveValue decimals=0 sign=true}}</span>{{~" "~}}
</li>
{{/each}}
</ul>
Expand All @@ -17,7 +17,7 @@
{{#if (or ability.proficient @root.flags.show-not-prof)}}
<li class="saving-throw {{#if ability.proficient}}proficient{{/if}}" data-ability="{{id}}" title="{{ability.label}}">
<span class="ability-title">{{ability.abbr}}</span>
<span>{{numberFormat ability.save decimals=0 sign=true}}</span>{{~" "~}}
<span>{{numberFormat ability.saveValue decimals=0 sign=true}}</span>{{~" "~}}
</li>
{{/if}}
{{/each}}
Expand Down
2 changes: 1 addition & 1 deletion templates/dnd5e/parts/main/legendaryActs.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#> "modules/monsterblock/templates/dnd5e/collapsibleSection.hbs"
title="DND5E.LegAct"
title=legActTitleId
section="legendary"
resource-key="system.resources.legact"}}
<p class="legendary-description">
Expand Down