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