Skip to content

Commit

Permalink
spell sheet bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jessev14 committed Nov 21, 2024
1 parent 8b3fb92 commit c27f48c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/dnd5e-character-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Hooks.once('init', async () => {
]);

libWrapper.register(moduleID, 'game.dnd5e.applications.actor.ActorSheet5eCharacter2.prototype._onChangeSheetMode', toggleSheetMode, 'WRAPPER');
libWrapper.register(moduleID, 'CONFIG.Item.documentClass.prototype.prepareData', prepareItem, 'WRAPPER');
});

Hooks.once('setup', async () => {
Expand Down Expand Up @@ -390,6 +391,8 @@ Hooks.on('preUpdateItem', async (item, diff, options, userID) => {
}

if (isSpellPrep) {
if (item.characterMonitor?.prepared === diff.system.preparation.prepared) return;

templateData.prepared = diff.system.preparation.prepared;
const content = await renderTemplate(`modules/${moduleID}/templates/spellPrepare.hbs`, templateData);
const flags = {
Expand Down Expand Up @@ -479,6 +482,29 @@ async function toggleSheetMode(wrapped, event) {
await socket.executeAsGM('createMessage', flags, content, whisper);
}

function prepareItem(wrapped) {
// lg(this)
switch (this.type) {
case 'spell':
this.characterMonitor = {
prepared: this.system?.preparation?.prepared
};
break;

case 'weapon':
break;

case 'feat':
break;

case 'equipment':
// this.characterMonitor = {equipped: false}
break;

}
return wrapped();
}


class CharacterMonitorColorMenu extends FormApplication {

Expand Down

0 comments on commit c27f48c

Please sign in to comment.