diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index d3b671d..acc27d2 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -13,7 +13,8 @@ export class OseActorSheet extends ActorSheet { data.config = CONFIG.OSE; // Settings data.config.ascendingAC = game.settings.get("ose", "ascendingAC"); - data.config.encumbranceBasic = game.settings.get("ose", "encumbranceOption") == 'basic'; + data.config.encumbranceBasic = + game.settings.get("ose", "encumbranceOption") == "basic"; // Prepare owned items this._prepareItems(data); @@ -42,11 +43,17 @@ export class OseActorSheet extends ActorSheet { // Sort spells by level var sortedSpells = {}; + var slots = {}; for (var i = 0; i < spells.length; i++) { let lvl = spells[i].data.lvl; if (!sortedSpells[lvl]) sortedSpells[lvl] = []; + if (!slots[lvl]) slots[lvl] = 0; + slots[lvl] += spells[i].data.memorized; sortedSpells[lvl].push(spells[i]); } + data.slots = { + used: slots + }; // Assign and return data.owned = { items: items, @@ -74,7 +81,19 @@ export class OseActorSheet extends ActorSheet { li.toggleClass("expanded"); } - + async _onSpellChange(event) { + event.preventDefault(); + const itemId = event.currentTarget.closest(".item").dataset.itemId; + const item = this.actor.getOwnedItem(itemId); + if (event.target.dataset.field == "cast") { + return item.update({ "data.cast": parseInt(event.target.value) }); + } else if (event.target.dataset.field == "memorize") { + return item.update({ + "data.memorized": parseInt(event.target.value), + }); + } + } + activateListeners(html) { // Item summaries html @@ -114,26 +133,34 @@ export class OseActorSheet extends ActorSheet { html.find(".item .item-controls .item-show").click(async (ev) => { const li = $(ev.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("itemId")); - item.roll({skipDialog: event.ctrlKey}); + item.roll({ skipDialog: event.ctrlKey }); }); - html.find(".item .item-rollable .item-image").click(async ev => { + html.find(".item .item-rollable .item-image").click(async (ev) => { const li = $(ev.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("itemId")); - if (item.type == 'weapon') { + if (item.type == "weapon") { item.rollWeapon(); } else { item.rollFormula(); } }); - html.find(".attack a").click(ev => { + html + .find(".memorize input") + .click((ev) => ev.target.select()) + .change(this._onSpellChange.bind(this)); + + html.find(".attack a").click((ev) => { let actorObject = this.actor; let element = event.currentTarget; let attack = element.parentElement.parentElement.dataset.attack; - actorObject.rollAttack({label: this.actor.name, type: attack}, { event: event }); + actorObject.rollAttack( + { label: this.actor.name, type: attack }, + { event: event } + ); }); - + html.find(".hit-dice .attribute-name a").click((ev) => { let actorObject = this.actor; actorObject.rollHitDice({ event: event }); diff --git a/src/scss/actor-base.scss b/src/scss/actor-base.scss index b36563a..c1263bc 100644 --- a/src/scss/actor-base.scss +++ b/src/scss/actor-base.scss @@ -281,6 +281,10 @@ flex-grow: 0; text-align: center; font-size: 12px; + &.memorize input { + border-bottom: none; + margin: 3px 0; + } } .field-short { font-size: 12px; diff --git a/src/scss/apps.scss b/src/scss/apps.scss index 214b31b..df4e823 100644 --- a/src/scss/apps.scss +++ b/src/scss/apps.scss @@ -7,26 +7,28 @@ .ose.chat-block { margin: 0; - .chat-title { + .chat-header { + height: 46px; + margin: 4px 0; background: $darkBackground; border: 1px solid black; border-radius: 3px; color: white; padding: 2px; - box-shadow: 0 0 2px #FFF inset; - margin: 4px 0; - display: flex; - h2 { - border: none; - line-height: 30px; - margin: 0; - text-indent: 10px; - font-size: 16px; + box-shadow: 0 0 2px #fff inset; + .chat-title { + margin: 4px 0; + h2 { + border: none; + line-height: 34px; + margin: 0; + text-indent: 10px; + font-size: 16px; + } } - img { - border: none; - width: 30px; - height: 30px; + .chat-img { + flex: 0 0 42px; + background-size: cover; } } .chat-details { diff --git a/src/template.json b/src/template.json index 1968e1e..4aaa789 100644 --- a/src/template.json +++ b/src/template.json @@ -57,27 +57,21 @@ "spells": { "enabled": false, "1": { - "value": 0, "max": 0 }, "2": { - "value": 0, "max": 0 }, "3": { - "value": 0, "max": 0 }, "4": { - "value": 0, "max": 0 }, "5": { - "value": 0, "max": 0 }, "6": { - "value": 0, "max": 0 } } @@ -191,8 +185,8 @@ "range": "", "roll": "", "description": "", - "memorized": false, - "cast": false, + "memorized": 0, + "cast": 0, "save": "" }, "ability": { diff --git a/src/templates/actors/partials/character-spells-tab.html b/src/templates/actors/partials/character-spells-tab.html index 26183a4..da40c31 100644 --- a/src/templates/actors/partials/character-spells-tab.html +++ b/src/templates/actors/partials/character-spells-tab.html @@ -5,8 +5,10 @@