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