ENH: Attack counter
parent
fcf24d2c52
commit
0a81e46725
|
@ -107,29 +107,6 @@ export class OseActorSheet extends ActorSheet {
|
|||
actorObject.rollSave(save, { event: event });
|
||||
});
|
||||
|
||||
//Toggle Spells
|
||||
html.find(".item-cast").click(async (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
await this.actor.updateOwnedItem({
|
||||
_id: li.data("itemId"),
|
||||
data: {
|
||||
cast: !item.data.data.cast,
|
||||
},
|
||||
});
|
||||
});
|
||||
//Toggle Equipment
|
||||
html.find(".item-memorize").click(async (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
await this.actor.updateOwnedItem({
|
||||
_id: li.data("itemId"),
|
||||
data: {
|
||||
memorized: !item.data.data.memorized,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
html.find(".item .item-controls .item-show").click(async (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
|
@ -140,9 +117,12 @@ export class OseActorSheet extends ActorSheet {
|
|||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
if (item.type == "weapon") {
|
||||
item.rollWeapon();
|
||||
item.rollWeapon({event: ev});
|
||||
if (this.actor.data.type === 'monster') {
|
||||
item.update({data: {counter: {value: item.data.data.counter.value - 1}}})
|
||||
}
|
||||
} else {
|
||||
item.rollFormula();
|
||||
item.rollFormula({event: ev});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -157,7 +137,7 @@ export class OseActorSheet extends ActorSheet {
|
|||
let attack = element.parentElement.parentElement.dataset.attack;
|
||||
actorObject.rollAttack(
|
||||
{ label: this.actor.name, type: attack },
|
||||
{ event: event }
|
||||
ev
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -246,7 +246,6 @@ export class OseActor extends Actor {
|
|||
|
||||
rollAttack(attData, options = {}) {
|
||||
const data = this.data.data;
|
||||
|
||||
const rollParts = ["1d20"];
|
||||
const dmgParts = [];
|
||||
|
||||
|
|
|
@ -38,31 +38,29 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
*/
|
||||
getData() {
|
||||
const data = super.getData();
|
||||
|
||||
|
||||
// Settings
|
||||
data.config.morale = game.settings.get('ose', 'morale');
|
||||
data.config.morale = game.settings.get("ose", "morale");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
async _chooseItemType(
|
||||
choices = ['weapon', 'armor', 'shield', 'gear'],
|
||||
) {
|
||||
let templateData = { upper: '', lower: '', types: choices },
|
||||
async _chooseItemType(choices = ["weapon", "armor", "shield", "gear"]) {
|
||||
let templateData = { upper: "", lower: "", types: choices },
|
||||
dlg = await renderTemplate(
|
||||
'templates/sidebar/entity-create.html',
|
||||
templateData,
|
||||
"templates/sidebar/entity-create.html",
|
||||
templateData
|
||||
);
|
||||
//Create Dialog window
|
||||
return new Promise((resolve) => {
|
||||
new Dialog({
|
||||
title: '',
|
||||
title: "",
|
||||
content: dlg,
|
||||
buttons: {
|
||||
ok: {
|
||||
label: game.i18n.localize('OSE.Ok'),
|
||||
label: game.i18n.localize("OSE.Ok"),
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
callback: (html) => {
|
||||
resolve({
|
||||
|
@ -73,14 +71,28 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize('OSE.Cancel'),
|
||||
label: game.i18n.localize("OSE.Cancel"),
|
||||
},
|
||||
},
|
||||
default: 'ok',
|
||||
default: "ok",
|
||||
}).render(true);
|
||||
});
|
||||
}
|
||||
|
||||
async _onCountChange(event) {
|
||||
event.preventDefault();
|
||||
const itemId = event.currentTarget.closest(".item").dataset.itemId;
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
if (event.target.dataset.field == "value") {
|
||||
return item.update({
|
||||
"data.counter.value": parseInt(event.target.value),
|
||||
});
|
||||
} else if (event.target.dataset.field == "max") {
|
||||
return item.update({
|
||||
"data.counter.max": parseInt(event.target.value),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Activate event listeners using the prepared sheet HTML
|
||||
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM
|
||||
|
@ -109,22 +121,19 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
const type = header.dataset.type;
|
||||
|
||||
// item creation helper func
|
||||
let createItem = function (
|
||||
type,
|
||||
name = `New ${type.capitalize()}`,
|
||||
) {
|
||||
let createItem = function (type, name = `New ${type.capitalize()}`) {
|
||||
const itemData = {
|
||||
name: name ? name : `New ${type.capitalize()}`,
|
||||
type: type,
|
||||
data: duplicate(header.dataset),
|
||||
};
|
||||
delete itemData.data['type'];
|
||||
delete itemData.data["type"];
|
||||
return itemData;
|
||||
};
|
||||
|
||||
|
||||
// Getting back to main logic
|
||||
if (type == 'choice') {
|
||||
const choices = header.dataset.choices.split(',');
|
||||
if (type == "choice") {
|
||||
const choices = header.dataset.choices.split(",");
|
||||
this._chooseItemType(choices).then((dialogInput) => {
|
||||
const itemData = createItem(dialogInput.type, dialogInput.name);
|
||||
this.actor.createOwnedItem(itemData, {});
|
||||
|
@ -140,6 +149,11 @@ export class OseActorSheetMonster extends OseActorSheet {
|
|||
actorObject.rollMorale({ event: event });
|
||||
});
|
||||
|
||||
html
|
||||
.find(".counter input")
|
||||
.click((ev) => ev.target.select())
|
||||
.change(this._onCountChange.bind(this));
|
||||
|
||||
html.find(".hp-roll").click((ev) => {
|
||||
let actorObject = this.actor;
|
||||
actorObject.rollHP({ event: event });
|
||||
|
|
|
@ -240,7 +240,6 @@ export class OseDice {
|
|||
flavor: flavor,
|
||||
speaker: speaker
|
||||
};
|
||||
|
||||
if (skipDialog) {
|
||||
return data.rollData.type === "Attack"
|
||||
? OseDice.sendAttackRoll(rollData)
|
||||
|
|
|
@ -45,7 +45,7 @@ export class OseItem extends Item {
|
|||
return data;
|
||||
}
|
||||
|
||||
rollWeapon(skipDialog) {
|
||||
rollWeapon(options = {}) {
|
||||
let isNPC = this.actor.data.type != "character";
|
||||
const data = this.data.data;
|
||||
let type = "raw";
|
||||
|
@ -66,7 +66,7 @@ export class OseItem extends Item {
|
|||
dmg: this.data.data.damage,
|
||||
bonus: data.bonus,
|
||||
},
|
||||
{ event: { ctrlKey: skipDialog } }
|
||||
options
|
||||
);
|
||||
},
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ export class OseItem extends Item {
|
|||
label: this.name,
|
||||
dmg: this.data.data.damage,
|
||||
},
|
||||
{ event: { ctrlKey: skipDialog } }
|
||||
options
|
||||
);
|
||||
},
|
||||
},
|
||||
|
@ -95,7 +95,7 @@ export class OseItem extends Item {
|
|||
}
|
||||
this.actor.rollAttack(
|
||||
{ type: type, label: this.name, dmg: data.damage, bonus: data.bonus },
|
||||
{ event: { ctrlKey: skipDialog } }
|
||||
options
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -170,7 +170,11 @@
|
|||
"melee": true,
|
||||
"cost": 0,
|
||||
"equipped": false,
|
||||
"weight": 0
|
||||
"weight": 0,
|
||||
"counter": {
|
||||
"value": 0,
|
||||
"max": 0
|
||||
}
|
||||
},
|
||||
"armor": {
|
||||
"description": "",
|
||||
|
|
|
@ -113,6 +113,12 @@
|
|||
{{item.name~}}
|
||||
</h4>
|
||||
</div>
|
||||
{{#if (eq item.type 'weapon')}}
|
||||
<div class="field-long counter flexrow">
|
||||
<input type="text" value="{{item.data.counter.value}}" data-dtype="Number" placeholder="0" data-field="value">
|
||||
/
|
||||
<input type="text" value="{{item.data.counter.max}}" data-field="max" data-dtype="Number" placeholder="0"></div>
|
||||
{{/if}}
|
||||
<div class="item-controls">
|
||||
{{#if ../../owner}}
|
||||
<a class="item-control item-edit" title='{{localize "OSE.Edit"}}'><i
|
||||
|
|
Loading…
Reference in New Issue