ENH: Spell counter
parent
f877f6e213
commit
e4889030cb
|
@ -169,6 +169,7 @@
|
|||
"OSE.armor.heavy": "Heavy",
|
||||
"OSE.armor.shield": "Shield",
|
||||
|
||||
"OSE.spells.spend": "{speaker} is casting {name}!",
|
||||
"OSE.spells.Memorized": "Memorized",
|
||||
"OSE.spells.Cast": "Cast",
|
||||
"OSE.spells.Range": "Range",
|
||||
|
@ -177,6 +178,7 @@
|
|||
"OSE.spells.Duration": "Duration",
|
||||
"OSE.spells.Level": "Level",
|
||||
"OSE.spells.Save": "Save",
|
||||
"OSE.spells.ResetSlots": "Reset Spell slots",
|
||||
|
||||
"OSE.abilities.Requirements": "Requirements",
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ export class OseActorSheet extends ActorSheet {
|
|||
sortedSpells[lvl].push(spells[i]);
|
||||
}
|
||||
data.slots = {
|
||||
used: slots
|
||||
used: slots,
|
||||
};
|
||||
// Assign and return
|
||||
data.owned = {
|
||||
|
@ -94,6 +94,18 @@ export class OseActorSheet extends ActorSheet {
|
|||
}
|
||||
}
|
||||
|
||||
async _resetSpells(event) {
|
||||
let spells = $(event.currentTarget).closest(".inventory.spells").find(".item");
|
||||
spells.each((_, el) => {
|
||||
let itemId = el.dataset.itemId;
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
item.update({
|
||||
_id: item.id,
|
||||
"data.cast": item.data.data.memorized,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
// Item summaries
|
||||
html
|
||||
|
@ -117,12 +129,16 @@ export class OseActorSheet extends ActorSheet {
|
|||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
if (item.type == "weapon") {
|
||||
if (this.actor.data.type === 'monster') {
|
||||
item.update({data: {counter: {value: item.data.data.counter.value - 1}}})
|
||||
if (this.actor.data.type === "monster") {
|
||||
item.update({
|
||||
data: { counter: { value: item.data.data.counter.value - 1 } },
|
||||
});
|
||||
}
|
||||
item.rollWeapon({event: ev});
|
||||
item.rollWeapon({ event: ev });
|
||||
} else if (item.type == "spell") {
|
||||
item.spendSpell();
|
||||
} else {
|
||||
item.rollFormula({event: ev});
|
||||
item.rollFormula({ event: ev });
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -135,10 +151,11 @@ export class OseActorSheet extends ActorSheet {
|
|||
let actorObject = this.actor;
|
||||
let element = event.currentTarget;
|
||||
let attack = element.parentElement.parentElement.dataset.attack;
|
||||
actorObject.rollAttack(
|
||||
{ label: this.actor.name, type: attack },
|
||||
ev
|
||||
);
|
||||
actorObject.rollAttack({ label: this.actor.name, type: attack }, ev);
|
||||
});
|
||||
|
||||
html.find(".spells .item-reset").click((ev) => {
|
||||
this._resetSpells(ev);
|
||||
});
|
||||
|
||||
html.find(".hit-dice .attribute-name a").click((ev) => {
|
||||
|
|
|
@ -95,13 +95,23 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
}
|
||||
|
||||
async _resetCounters(event) {
|
||||
$(event.currentTarget).closest('.abilities').find(".item").each(async (_, el) => {
|
||||
let itemId = el.dataset.itemId;
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
if (item.data.type == 'weapon') {
|
||||
await item.update({"data.counter.value": parseInt(item.data.data.counter.max)});
|
||||
}
|
||||
})
|
||||
$(event.currentTarget)
|
||||
.closest(".abilities")
|
||||
.find(".item")
|
||||
.each(async (_, el) => {
|
||||
let itemId = el.dataset.itemId;
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
if (item.data.type == "weapon") {
|
||||
await item.update({
|
||||
_id: item.id,
|
||||
data: {
|
||||
counter: {
|
||||
value: parseInt(item.data.data.counter.max),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,9 +165,9 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
return this.actor.createOwnedItem(itemData, {});
|
||||
});
|
||||
|
||||
html.find('.item-reset').click(ev => {
|
||||
html.find(".item-reset").click((ev) => {
|
||||
this._resetCounters(ev);
|
||||
})
|
||||
});
|
||||
|
||||
html.find(".morale-check a").click((ev) => {
|
||||
let actorObject = this.actor;
|
||||
|
|
|
@ -131,6 +131,14 @@ export class OseItem extends Item {
|
|||
});
|
||||
}
|
||||
|
||||
spendSpell() {
|
||||
this.update({data: {
|
||||
cast: this.data.data.cast - 1
|
||||
}}).then(() => {
|
||||
this.roll({skipDialog: true})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll the item to Chat, creating a chat card which contains follow up attack or damage roll options
|
||||
* @return {Promise}
|
||||
|
|
|
@ -30,8 +30,11 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
<div class="tab" data-group="primary" data-tab="notes">
|
||||
{{editor content=data.details.biography target="data.details.biography"
|
||||
button=true owner=owner editable=editable}}
|
||||
<div class="inventory">
|
||||
<div class="item-titles">{{localize "OSE.category.notes"}}</div>
|
||||
{{editor content=data.details.biography target="data.details.biography"
|
||||
button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
|
@ -4,6 +4,9 @@
|
|||
<li class="item-titles flexrow">
|
||||
<div class="item-caret"><i class="fas fa-caret-down"></i> </div>
|
||||
<div class="item-name">{{localize "OSE.spells.Level"}} {{id}}</div>
|
||||
<div class="field-short">
|
||||
<a class="item-control item-reset" title='{{localize "OSE.spells.ResetSlots"}}'><i class="fas fa-sync"></i></a>
|
||||
</div>
|
||||
<div class="field-short">{{localize 'OSE.spells.Slots'}}</div>
|
||||
<div class="field-long flexrow">
|
||||
<input type="text" value="{{lookup @root.slots.used @key}}"
|
||||
|
@ -12,14 +15,14 @@
|
|||
placeholder="0"></div>
|
||||
<div class="item-controls">
|
||||
<a class="item-control item-create" data-type="spell" data-lvl="{{id}}" title="{{localize 'OSE.Add'}}"><i
|
||||
class="fa fa-plus"></i></a>
|
||||
class="fa fa-plus"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
<ol class="item-list">
|
||||
{{#each spellGroup as |item|}}
|
||||
<li class="item-entry">
|
||||
<div class="item flexrow" data-item-id="{{item._id}}">
|
||||
<div class="item-name {{#if item.data.roll}}item-rollable{{/if}} flexrow">
|
||||
<div class="item-name item-rollable flexrow">
|
||||
<div class="item-image" style="background-image: url({{item.img}})"></div>
|
||||
<a>
|
||||
<h4 title="{{item.name}}">
|
||||
|
|
Loading…
Reference in New Issue