diff --git a/src/lang/en.json b/src/lang/en.json index 50bd5af..382cc4b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -57,6 +57,7 @@ "OSE.InitiativeShort": "INIT", "OSE.Attacks": "Attacks Usable per Round", "OSE.AttacksShort": "ATT", + "OSE.Spellcaster": "Spellcaster", "OSE.category.attributes": "Attributes", @@ -74,5 +75,7 @@ "OSE.Setting.Morale": "Enable Monster Morale checks", "OSE.Setting.MoraleHint": "Morale Rating is shown on monster sheets", "OSE.Setting.THAC0Attacks": "Attacks with THAC0", - "OSE.Setting.THAC0AttacksHint": "Attacks are resolved using the THAC0 value" + "OSE.Setting.THAC0AttacksHint": "Attacks are resolved using the THAC0 value, not compatible with AAC", + "OSE.Setting.VariableWeaponDamage": "Variable Weapon Damage", + "OSE.Setting.VariableWeaponDamageHint": "Weapons have different damage dice" } \ No newline at end of file diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index c42789c..6168c30 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -1,4 +1,5 @@ import { OseActor } from "./entity.js"; +import { OseEntityTweaks } from "../dialog/entity-tweaks.js"; export class OseActorSheet extends ActorSheet { constructor(...args) { @@ -6,6 +7,13 @@ export class OseActorSheet extends ActorSheet { } /* -------------------------------------------- */ + activateListeners(html) { + super.activateListeners(html); + html.find('.saving-throw .attribute-name').click(ev => { + console.log('hey'); + }) + } + // Override to set resizable initial size async _renderInner(...args) { const html = await super._renderInner(...args); @@ -32,4 +40,35 @@ export class OseActorSheet extends ActorSheet { el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`; }); } + + + _onConfigureActor(event) { + event.preventDefault(); + new OseEntityTweaks(this.actor, { + top: this.position.top + 40, + left: this.position.left + (this.position.width - 400) / 2, + }).render(true); + } + + /** + * Extend and override the sheet header buttons + * @override + */ + _getHeaderButtons() { + let buttons = super._getHeaderButtons(); + + // Token Configuration + const canConfigure = game.user.isGM || this.actor.owner; + if (this.options.editable && canConfigure) { + buttons = [ + { + label: 'Tweaks', + class: 'configure-actor', + icon: 'fas fa-dice', + onclick: (ev) => this._onConfigureActor(ev), + }, + ].concat(buttons); + } + return buttons; + } } \ No newline at end of file diff --git a/src/module/dialog/entity-tweaks.js b/src/module/dialog/entity-tweaks.js new file mode 100644 index 0000000..01c03ac --- /dev/null +++ b/src/module/dialog/entity-tweaks.js @@ -0,0 +1,58 @@ +// eslint-disable-next-line no-unused-vars +import { OseActor } from '../actor/entity.js'; + +export class OseEntityTweaks extends FormApplication { + static get defaultOptions() { + const options = super.defaultOptions; + options.id = 'sheet-tweaks'; + options.template = + 'systems/ose/templates/actors/dialogs/tweaks-dialog.html'; + options.width = 380; + return options; + } + + /* -------------------------------------------- */ + + /** + * Add the Entity name into the window title + * @type {String} + */ + get title() { + return `${this.object.name}: OSE Tweaks`; + } + + /* -------------------------------------------- */ + + /** + * Construct and return the data object used to render the HTML template for this form application. + * @return {Object} + */ + getData() { + let data = this.object.data; + if (this.object.data.type === 'character') { + data.isCharacter = true; + } + return data; + } + + /* -------------------------------------------- */ + + /** @override */ + activateListeners(html) { + super.activateListeners(html); + } + + /** + * This method is called upon form submission after form data is validated + * @param event {Event} The initial triggering submission event + * @param formData {Object} The object of validated form data with which to update the object + * @private + */ + async _updateObject(event, formData) { + event.preventDefault(); + // Update the actor + this.object.update(formData); + // Re-draw the updated sheet + this.object.sheet.render(true); + } +} diff --git a/src/module/settings.js b/src/module/settings.js index 1f42d21..00f2f46 100644 --- a/src/module/settings.js +++ b/src/module/settings.js @@ -34,5 +34,14 @@ export const registerSettings = function () { type: Boolean, config: true }); + + game.settings.register('ose', 'variableDamage', { + name: game.i18n.localize('OSE.Setting.VariableWeaponDamage'), + hint: game.i18n.localize('OSE.Setting.VariableWeaponDamageHint'), + default: false, + scope: 'world', + type: Boolean, + config: true + }); } \ No newline at end of file diff --git a/src/template.json b/src/template.json index 7aa262b..f2cd2e6 100644 --- a/src/template.json +++ b/src/template.json @@ -1,7 +1,40 @@ { "Actor": { "types": ["character", "monster"], + "templates": { + "spellcaster": { + "spells": { + "enabled": false, + "dc": 0, + "lvl1": { + "value": 0, + "max": 0 + }, + "lvl2": { + "value": 0, + "max": 0 + }, + "lvl3": { + "value": 0, + "max": 0 + }, + "lvl4": { + "value": 0, + "max": 0 + }, + "lvl5": { + "value": 0, + "max": 0 + }, + "lvl6": { + "value": 0, + "max": 0 + } + } + } + }, "character": { + "templates": ["spellcaster"], "details": { "biography": "", "class": "", @@ -43,33 +76,6 @@ "silver": 0, "copper": 0 }, - "spells": { - "dc": 0, - "lvl1": { - "value": 0, - "max": 0 - }, - "lvl2": { - "value": 0, - "max": 0 - }, - "lvl3": { - "value": 0, - "max": 0 - }, - "lvl4": { - "value": 0, - "max": 0 - }, - "lvl5": { - "value": 0, - "max": 0 - }, - "lvl6": { - "value": 0, - "max": 0 - } - }, "hp": { "hd": "", "value": 20, @@ -103,6 +109,7 @@ "languages": [] }, "monster": { + "templates": ["spellcaster"], "details": { "biography": "", "alignment": "", @@ -138,33 +145,6 @@ "movement": { "base": 0, "encounter": 0 - }, - "spells": { - "dc": 0, - "lvl1": { - "value": 0, - "max": 0 - }, - "lvl2": { - "value": 0, - "max": 0 - }, - "lvl3": { - "value": 0, - "max": 0 - }, - "lvl4": { - "value": 0, - "max": 0 - }, - "lvl5": { - "value": 0, - "max": 0 - }, - "lvl6": { - "value": 0, - "max": 0 - } } } }, diff --git a/src/templates/actors/character-sheet.html b/src/templates/actors/character-sheet.html index a878aa4..1d2ede3 100644 --- a/src/templates/actors/character-sheet.html +++ b/src/templates/actors/character-sheet.html @@ -12,9 +12,11 @@ {{localize "OSE.category.inventory"}} + {{#if data.spells.enabled}} {{localize "OSE.category.spells"}} + {{/if}} {{localize "OSE.category.notes"}} @@ -28,9 +30,11 @@
{{> "systems/ose/templates/actors/partials/character-inventory-tab.html"}}
+ {{#if data.spells.enabled}}
{{> "systems/ose/templates/actors/partials/character-spells-tab.html"}}
+ {{/if}}
{{editor content=data.details.biography target="data.details.biography" button=true owner=owner editable=editable}} diff --git a/src/templates/actors/dialogs/tweaks-dialog.html b/src/templates/actors/dialogs/tweaks-dialog.html new file mode 100644 index 0000000..fe376d4 --- /dev/null +++ b/src/templates/actors/dialogs/tweaks-dialog.html @@ -0,0 +1,20 @@ +
+
+ +
+ +
+
+
+ +
+
+ \ No newline at end of file diff --git a/src/templates/actors/monster-sheet.html b/src/templates/actors/monster-sheet.html index 9786ce7..88abee4 100644 --- a/src/templates/actors/monster-sheet.html +++ b/src/templates/actors/monster-sheet.html @@ -9,9 +9,11 @@ {{localize "OSE.category.attributes"}} + {{#if data.spells.enabled}} {{localize "OSE.category.spells"}} + {{/if}} {{localize "OSE.category.notes"}} @@ -22,9 +24,11 @@
{{> "systems/ose/templates/actors/partials/monster-attributes-tab.html"}}
+ {{#if data.spells.enabled}}
{{> "systems/ose/templates/actors/partials/character-spells-tab.html"}}
+ {{/if}}
{{editor content=data.details.biography target="data.details.biography" button=true owner=owner editable=editable}} diff --git a/src/templates/actors/partials/character-attributes-tab.html b/src/templates/actors/partials/character-attributes-tab.html index 03265fe..85804b3 100644 --- a/src/templates/actors/partials/character-attributes-tab.html +++ b/src/templates/actors/partials/character-attributes-tab.html @@ -129,32 +129,32 @@ {{!-- Saving throws --}}