mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Adding Prettier
* Added prettier with automatic useage on pre-commit to avoid style breakage * Ran Prettier on the project
This commit is contained in:
parent
820c2df1f4
commit
b24cdcc9ed
136 changed files with 13929 additions and 12206 deletions
|
|
@ -11,4 +11,4 @@ export { default as DhpConsumable } from './sheets/consumable.mjs';
|
|||
export { default as DhpWeapon } from './sheets/weapon.mjs';
|
||||
export { default as DhpArmor } from './sheets/armor.mjs';
|
||||
export { default as DhpChatMessage } from './chatMessage.mjs';
|
||||
export { default as DhpEnvironment } from './sheets/environment.mjs';
|
||||
export { default as DhpEnvironment } from './sheets/environment.mjs';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
|
||||
constructor(resolve){
|
||||
constructor(resolve) {
|
||||
super({});
|
||||
|
||||
|
||||
this.resolve = resolve;
|
||||
this.data = {
|
||||
ancestries: [],
|
||||
|
|
@ -13,17 +12,17 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
name: '',
|
||||
img: null,
|
||||
customImg: 'icons/svg/mystery-man.svg',
|
||||
description: '',
|
||||
},
|
||||
description: ''
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ["daggerheart", "views", "ancestry-selection"],
|
||||
classes: ['daggerheart', 'views', 'ancestry-selection'],
|
||||
position: {
|
||||
width: 800,
|
||||
height: "auto"
|
||||
width: 800,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
selectAncestry: this.selectAncestry,
|
||||
|
|
@ -31,21 +30,21 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
viewItem: this.viewItem,
|
||||
selectImage: this.selectImage,
|
||||
editImage: this._onEditImage,
|
||||
saveAncestry: this.saveAncestry,
|
||||
saveAncestry: this.saveAncestry
|
||||
},
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: "ancestrySelection",
|
||||
template: "systems/daggerheart/templates/views/ancestrySelection.hbs"
|
||||
id: 'ancestrySelection',
|
||||
template: 'systems/daggerheart/templates/views/ancestrySelection.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
|
@ -57,10 +56,10 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
const ancestryNameInput = $(htmlElement).find(".ancestry-name");
|
||||
if(ancestryNameInput.length > 0){
|
||||
ancestryNameInput.on("change", this.setName.bind(this));
|
||||
$(htmlElement).find(".ancestry-description").on("change", this.setDescription.bind(this));
|
||||
const ancestryNameInput = $(htmlElement).find('.ancestry-name');
|
||||
if (ancestryNameInput.length > 0) {
|
||||
ancestryNameInput.on('change', this.setName.bind(this));
|
||||
$(htmlElement).find('.ancestry-description').on('change', this.setDescription.bind(this));
|
||||
}
|
||||
// $(htmlElement).find(".ancestry-image").on("change", this.selectImage.bind(this));
|
||||
}
|
||||
|
|
@ -68,19 +67,26 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
async _prepareContext(_options) {
|
||||
const systemAncestries = Array.from((await game.packs.get('daggerheart.playtest-ancestries')).index).map(x => ({
|
||||
...x,
|
||||
selected: this.data.ancestries.some(selected => selected.uuid === x.uuid),
|
||||
selected: this.data.ancestries.some(selected => selected.uuid === x.uuid)
|
||||
}));
|
||||
|
||||
const customAncestries = game.items.reduce((acc, x) => {
|
||||
if(x.type === 'ancestry'){
|
||||
acc.push({ ...x, uuid: x.uuid, selected: this.data.ancestries.some(selected => selected.uuid === x.uuid) });
|
||||
if (x.type === 'ancestry') {
|
||||
acc.push({
|
||||
...x,
|
||||
uuid: x.uuid,
|
||||
selected: this.data.ancestries.some(selected => selected.uuid === x.uuid)
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const ancestryFeatures = this.data.ancestries.flatMap(x =>
|
||||
x.system.abilities.map(x => ({ ...x, selected: this.data.features.some(selected => selected.uuid === x.uuid) }))
|
||||
const ancestryFeatures = this.data.ancestries.flatMap(x =>
|
||||
x.system.abilities.map(x => ({
|
||||
...x,
|
||||
selected: this.data.features.some(selected => selected.uuid === x.uuid)
|
||||
}))
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
@ -89,13 +95,13 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
ancestryFeatures,
|
||||
selectedAncestries: this.data.ancestries,
|
||||
selectedFeatures: this.data.features,
|
||||
ancestryInfo: this.data.ancestryInfo,
|
||||
ancestryInfo: this.data.ancestryInfo
|
||||
};
|
||||
}
|
||||
|
||||
static async selectAncestry(_, button) {
|
||||
const newAncestries = [...this.data.ancestries];
|
||||
if(!newAncestries.findSplice(x => x.uuid === button.dataset.uuid) && this.data.ancestries.length < 2){
|
||||
if (!newAncestries.findSplice(x => x.uuid === button.dataset.uuid) && this.data.ancestries.length < 2) {
|
||||
const ancestry = await fromUuid(button.dataset.uuid);
|
||||
newAncestries.push(ancestry);
|
||||
}
|
||||
|
|
@ -108,7 +114,7 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
|
||||
static async selectFeature(_, button) {
|
||||
const newFeatures = [...this.data.features];
|
||||
if(!newFeatures.findSplice(x => x.uuid === button.dataset.uuid) && this.data.features.length < 2){
|
||||
if (!newFeatures.findSplice(x => x.uuid === button.dataset.uuid) && this.data.features.length < 2) {
|
||||
const feature = await fromUuid(button.dataset.uuid);
|
||||
newFeatures.push(feature);
|
||||
}
|
||||
|
|
@ -125,7 +131,7 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
this.data.ancestryInfo.name = event.currentTarget.value;
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
|
||||
setDescription(event) {
|
||||
this.data.ancestryInfo.description = event.currentTarget.value;
|
||||
this.render(true);
|
||||
|
|
@ -139,7 +145,7 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
static _onEditImage() {
|
||||
const fp = new FilePicker({
|
||||
current: this.data.ancestryInfo.img,
|
||||
type: "image",
|
||||
type: 'image',
|
||||
redirectToRoot: ['icons/svg/mystery-man.svg'],
|
||||
callback: async path => this._updateImage.bind(this)(path),
|
||||
top: this.position.top + 40,
|
||||
|
|
@ -148,17 +154,32 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
return fp.browse();
|
||||
}
|
||||
|
||||
_updateImage(path){
|
||||
this.data.ancestryInfo.customImg = path;
|
||||
this.data.ancestryInfo.img = path;
|
||||
this.render(true);
|
||||
_updateImage(path) {
|
||||
this.data.ancestryInfo.customImg = path;
|
||||
this.data.ancestryInfo.img = path;
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async saveAncestry(_, button) {
|
||||
if(this.data.ancestries.length === 2){
|
||||
if (this.data.ancestries.length === 2) {
|
||||
const { name, img, description } = this.data.ancestryInfo;
|
||||
|
||||
this.resolve({ data: { name: name, img: img, type: "ancestry", system: { description: description, abilities: this.data.features.map(x => ({ name: x.name, img: x.img, uuid: x.uuid, subclassLevel: '' })) }}});
|
||||
this.resolve({
|
||||
data: {
|
||||
name: name,
|
||||
img: img,
|
||||
type: 'ancestry',
|
||||
system: {
|
||||
description: description,
|
||||
abilities: this.data.features.map(x => ({
|
||||
name: x.name,
|
||||
img: x.img,
|
||||
uuid: x.uuid,
|
||||
subclassLevel: ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.resolve({ data: this.data.ancestries[0].toObject() });
|
||||
}
|
||||
|
|
@ -170,7 +191,7 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
// export default class DamageSelectionDialog extends FormApplication {
|
||||
// constructor(rollString, bonusDamage, resolve){
|
||||
// super({}, {});
|
||||
|
||||
|
||||
// this.data = {
|
||||
// rollString,
|
||||
// bonusDamage: bonusDamage.map(x => ({
|
||||
|
|
@ -180,11 +201,11 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
// }
|
||||
// this.resolve = resolve;
|
||||
// }
|
||||
|
||||
|
||||
// get title (){
|
||||
// return 'Damage Options';
|
||||
// }
|
||||
|
||||
|
||||
// static get defaultOptions() {
|
||||
// const defaults = super.defaultOptions;
|
||||
// const overrides = {
|
||||
|
|
@ -195,35 +216,35 @@ export default class AncestrySelectionDialog extends HandlebarsApplicationMixin(
|
|||
// closeOnSubmit: false,
|
||||
// classes: ["daggerheart", "views", "damage-selection"],
|
||||
// };
|
||||
|
||||
|
||||
// const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
|
||||
// return mergedOptions;
|
||||
// }
|
||||
|
||||
|
||||
// async getData(){
|
||||
// const context = super.getData();
|
||||
// context.rollString = this.data.rollString;
|
||||
// context.bonusDamage = this.data.bonusDamage;
|
||||
|
||||
|
||||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// activateListeners(html) {
|
||||
// super.activateListeners(html);
|
||||
|
||||
|
||||
// html.find('.roll-button').click(this.finish.bind(this));
|
||||
// html.find('.').change();
|
||||
// }
|
||||
|
||||
|
||||
// // async _updateObject(_, formData) {
|
||||
// // const data = foundry.utils.expandObject(formData);
|
||||
// // this.data = foundry.utils.mergeObject(this.data, data);
|
||||
// // this.render(true);
|
||||
// // }
|
||||
|
||||
|
||||
// finish(){
|
||||
// this.resolve(this.data);
|
||||
// this.close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export default class DhpChatMesssage extends ChatMessage {
|
||||
async renderHTML() {
|
||||
if(this.type === 'dualityRoll' || this.type === 'adversaryRoll' || this.type === 'abilityUse'){
|
||||
if (this.type === 'dualityRoll' || this.type === 'adversaryRoll' || this.type === 'abilityUse') {
|
||||
this.content = await foundry.applications.handlebars.renderTemplate(this.content, this.system);
|
||||
}
|
||||
|
||||
return super.renderHTML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
|
||||
|
||||
const {ApplicationV2} = foundry.applications.api;
|
||||
const { ApplicationV2 } = foundry.applications.api;
|
||||
export default class DaggerheartActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||
constructor(action){
|
||||
constructor(action) {
|
||||
super({});
|
||||
|
||||
this.action = action;
|
||||
|
|
@ -10,40 +10,47 @@ export default class DaggerheartActionConfig extends DaggerheartSheet(Applicatio
|
|||
}
|
||||
|
||||
// get title(){
|
||||
// return `Action - ${this.action.name}`;
|
||||
// return `Action - ${this.action.name}`;
|
||||
// }
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-action",
|
||||
classes: ["daggerheart", "views", "action"],
|
||||
id: 'daggerheart-action',
|
||||
classes: ['daggerheart', 'views', 'action'],
|
||||
position: { width: 600, height: 'auto' },
|
||||
actions: {
|
||||
toggleSection: this.toggleSection,
|
||||
toggleSection: this.toggleSection
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
closeOnSubmit: true,
|
||||
},
|
||||
closeOnSubmit: true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "action",
|
||||
template: "systems/daggerheart/templates/views/action.hbs"
|
||||
id: 'action',
|
||||
template: 'systems/daggerheart/templates/views/action.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_getTabs() {
|
||||
const tabs = {
|
||||
effects: { active: true, cssClass: '', group: 'primary', id: 'effects', icon: null, label: 'Effects' },
|
||||
useage: { active: false, cssClass: '', group: 'primary', id: 'useage', icon: null, label: 'Useage' },
|
||||
conditions: { active: false, cssClass: '', group: 'primary', id: 'conditions', icon: null, label: 'Conditions' },
|
||||
}
|
||||
conditions: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'conditions',
|
||||
icon: null,
|
||||
label: 'Conditions'
|
||||
}
|
||||
};
|
||||
|
||||
for ( const v of Object.values(tabs) ) {
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
|
||||
v.cssClass = v.active ? "active" : "";
|
||||
v.cssClass = v.active ? 'active' : '';
|
||||
}
|
||||
|
||||
return tabs;
|
||||
|
|
@ -61,14 +68,14 @@ export default class DaggerheartActionConfig extends DaggerheartSheet(Applicatio
|
|||
this.openSection = button.dataset.section === this.openSection ? null : button.dataset.section;
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
const data = foundry.utils.expandObject(foundry.utils.mergeObject(this.action.toObject(), formData.object));
|
||||
const newActions = this.action.parent.actions.map(x => x.toObject());
|
||||
if(!newActions.findSplice(x => x.id === data.id, data)){
|
||||
if (!newActions.findSplice(x => x.id === data.id, data)) {
|
||||
newActions.push(data);
|
||||
}
|
||||
|
||||
await this.action.parent.parent.update({ "system.actions": newActions });
|
||||
await this.action.parent.parent.update({ 'system.actions': newActions });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
export default function DhpApplicationMixin(Base) {
|
||||
return class DhpSheet extends Base {
|
||||
static applicationType = "sheets";
|
||||
static documentType = "";
|
||||
static applicationType = 'sheets';
|
||||
static documentType = '';
|
||||
|
||||
static get defaultOptions() {
|
||||
return Object.assign(super.defaultOptions, {
|
||||
classes: ["daggerheart", "sheet", this.documentType],
|
||||
classes: ['daggerheart', 'sheet', this.documentType],
|
||||
template: `systems/${SYSTEM.id}/templates/${this.applicationType}/${this.documentType}.hbs`,
|
||||
height: "auto",
|
||||
height: 'auto',
|
||||
submitOnChange: true,
|
||||
submitOnClose: false,
|
||||
width: 450
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** @override */
|
||||
get title() {
|
||||
const {documentName, type, name} = this.object;
|
||||
const { documentName, type, name } = this.object;
|
||||
// const typeLabel = game.i18n.localize(CONFIG[documentName].typeLabels[type]);
|
||||
const typeLabel = documentName;
|
||||
return `[${typeLabel}] ${name}`;
|
||||
|
|
@ -32,17 +32,17 @@ export default function DhpApplicationMixin(Base) {
|
|||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
html.on("click", "[data-action]", this.#onClickAction.bind(this));
|
||||
html.on('click', '[data-action]', this.#onClickAction.bind(this));
|
||||
}
|
||||
|
||||
async #onClickAction(event) {
|
||||
event.preventDefault();
|
||||
const button = event.currentTarget;
|
||||
const action = button.dataset.action;
|
||||
|
||||
return this._handleAction(action, event, button);
|
||||
event.preventDefault();
|
||||
const button = event.currentTarget;
|
||||
const action = button.dataset.action;
|
||||
|
||||
return this._handleAction(action, event, button);
|
||||
}
|
||||
|
||||
async _handleAction(action, event, button) {}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,53 +1,52 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class DamageSelectionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
|
||||
constructor(rollString, bonusDamage, hope, resolve){
|
||||
constructor(rollString, bonusDamage, hope, resolve) {
|
||||
super({});
|
||||
|
||||
|
||||
this.data = {
|
||||
rollString,
|
||||
bonusDamage: bonusDamage.reduce((acc, x) => {
|
||||
if(x.appliesOn === SYSTEM.EFFECTS.applyLocations.damageRoll.id){
|
||||
acc.push(({
|
||||
if (x.appliesOn === SYSTEM.EFFECTS.applyLocations.damageRoll.id) {
|
||||
acc.push({
|
||||
...x,
|
||||
hopeUses: 0
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
hope,
|
||||
}
|
||||
hope
|
||||
};
|
||||
this.resolve = resolve;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ["daggerheart", "views", "damage-selection"],
|
||||
classes: ['daggerheart', 'views', 'damage-selection'],
|
||||
position: {
|
||||
width: 400,
|
||||
height: "auto"
|
||||
width: 400,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
decreaseHopeUse: this.decreaseHopeUse,
|
||||
increaseHopeUse: this.increaseHopeUse,
|
||||
rollDamage: this.rollDamage,
|
||||
rollDamage: this.rollDamage
|
||||
},
|
||||
form: {
|
||||
handler: this.updateSelection,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: "damageSelection",
|
||||
template: "systems/daggerheart/templates/views/damageSelection.hbs"
|
||||
id: 'damageSelection',
|
||||
template: 'systems/daggerheart/templates/views/damageSelection.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
|
@ -60,19 +59,19 @@ export default class DamageSelectionDialog extends HandlebarsApplicationMixin(Ap
|
|||
return {
|
||||
rollString: this.getRollString(),
|
||||
bonusDamage: this.data.bonusDamage,
|
||||
hope: this.data.hope+1,
|
||||
hopeUsed: this.getHopeUsed(),
|
||||
}
|
||||
hope: this.data.hope + 1,
|
||||
hopeUsed: this.getHopeUsed()
|
||||
};
|
||||
}
|
||||
|
||||
static updateSelection(event, _, formData){
|
||||
static updateSelection(event, _, formData) {
|
||||
const { bonusDamage, ...rest } = foundry.utils.expandObject(formData.object);
|
||||
|
||||
for(var index in bonusDamage){
|
||||
|
||||
for (var index in bonusDamage) {
|
||||
this.data.bonusDamage[index].initiallySelected = bonusDamage[index].initiallySelected;
|
||||
if(bonusDamage[index].hopeUses){
|
||||
if (bonusDamage[index].hopeUses) {
|
||||
const value = Number.parseInt(bonusDamage[index].hopeUses);
|
||||
if(!Number.isNaN(value)) this.data.bonusDamage[index].hopeUses = value;
|
||||
if (!Number.isNaN(value)) this.data.bonusDamage[index].hopeUses = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,40 +79,46 @@ export default class DamageSelectionDialog extends HandlebarsApplicationMixin(Ap
|
|||
this.render(true);
|
||||
}
|
||||
|
||||
getRollString(){
|
||||
return this.data.rollString.concat(this.data.bonusDamage.reduce((acc, x) => {
|
||||
if(x.initiallySelected){
|
||||
const nr = 1+x.hopeUses;
|
||||
const baseDamage = x.value;
|
||||
return acc.concat(` + ${nr}${baseDamage}`);
|
||||
}
|
||||
getRollString() {
|
||||
return this.data.rollString.concat(
|
||||
this.data.bonusDamage.reduce((acc, x) => {
|
||||
if (x.initiallySelected) {
|
||||
const nr = 1 + x.hopeUses;
|
||||
const baseDamage = x.value;
|
||||
return acc.concat(` + ${nr}${baseDamage}`);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, ""));
|
||||
return acc;
|
||||
}, '')
|
||||
);
|
||||
}
|
||||
|
||||
getHopeUsed(){
|
||||
return this.data.bonusDamage.reduce((acc, x) => acc+x.hopeUses, 0);
|
||||
getHopeUsed() {
|
||||
return this.data.bonusDamage.reduce((acc, x) => acc + x.hopeUses, 0);
|
||||
}
|
||||
|
||||
static decreaseHopeUse(_, button){
|
||||
static decreaseHopeUse(_, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
if(this.data.bonusDamage[index].hopeUses - 1 >= 0) {
|
||||
if (this.data.bonusDamage[index].hopeUses - 1 >= 0) {
|
||||
this.data.bonusDamage[index].hopeUses -= 1;
|
||||
this.render(true);
|
||||
}
|
||||
}
|
||||
|
||||
static increaseHopeUse(_, button){
|
||||
static increaseHopeUse(_, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
if(this.data.bonusDamage[index].hopeUses <= this.data.hope+1) {
|
||||
if (this.data.bonusDamage[index].hopeUses <= this.data.hope + 1) {
|
||||
this.data.bonusDamage[index].hopeUses += 1;
|
||||
this.render(true);
|
||||
}
|
||||
}
|
||||
|
||||
static rollDamage(){
|
||||
this.resolve({ rollString: this.getRollString(), bonusDamage: this.data.bonusDamage, hopeUsed: this.getHopeUsed() });
|
||||
static rollDamage() {
|
||||
this.resolve({
|
||||
rollString: this.getRollString(),
|
||||
bonusDamage: this.data.bonusDamage,
|
||||
hopeUsed: this.getHopeUsed()
|
||||
});
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +126,7 @@ export default class DamageSelectionDialog extends HandlebarsApplicationMixin(Ap
|
|||
// export default class DamageSelectionDialog extends FormApplication {
|
||||
// constructor(rollString, bonusDamage, resolve){
|
||||
// super({}, {});
|
||||
|
||||
|
||||
// this.data = {
|
||||
// rollString,
|
||||
// bonusDamage: bonusDamage.map(x => ({
|
||||
|
|
@ -131,11 +136,11 @@ export default class DamageSelectionDialog extends HandlebarsApplicationMixin(Ap
|
|||
// }
|
||||
// this.resolve = resolve;
|
||||
// }
|
||||
|
||||
|
||||
// get title (){
|
||||
// return 'Damage Options';
|
||||
// }
|
||||
|
||||
|
||||
// static get defaultOptions() {
|
||||
// const defaults = super.defaultOptions;
|
||||
// const overrides = {
|
||||
|
|
@ -146,35 +151,35 @@ export default class DamageSelectionDialog extends HandlebarsApplicationMixin(Ap
|
|||
// closeOnSubmit: false,
|
||||
// classes: ["daggerheart", "views", "damage-selection"],
|
||||
// };
|
||||
|
||||
|
||||
// const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
|
||||
// return mergedOptions;
|
||||
// }
|
||||
|
||||
|
||||
// async getData(){
|
||||
// const context = super.getData();
|
||||
// context.rollString = this.data.rollString;
|
||||
// context.bonusDamage = this.data.bonusDamage;
|
||||
|
||||
|
||||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// activateListeners(html) {
|
||||
// super.activateListeners(html);
|
||||
|
||||
|
||||
// html.find('.roll-button').click(this.finish.bind(this));
|
||||
// html.find('.').change();
|
||||
// }
|
||||
|
||||
|
||||
// // async _updateObject(_, formData) {
|
||||
// // const data = foundry.utils.expandObject(formData);
|
||||
// // this.data = foundry.utils.mergeObject(this.data, data);
|
||||
// // this.render(true);
|
||||
// // }
|
||||
|
||||
|
||||
// finish(){
|
||||
// this.resolve(this.data);
|
||||
// this.close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
const {HandlebarsApplicationMixin, ApplicationV2} = foundry.applications.api;
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhpDeathMove extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actor){
|
||||
constructor(actor) {
|
||||
super({});
|
||||
|
||||
this.actor = actor;
|
||||
this.selectedMove = null;
|
||||
}
|
||||
|
||||
get title(){
|
||||
return game.i18n.format("DAGGERHEART.Application.DeathMove.Title", { actor: this.actor.name });
|
||||
get title() {
|
||||
return game.i18n.format('DAGGERHEART.Application.DeathMove.Title', { actor: this.actor.name });
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["daggerheart", "views", "death-move"],
|
||||
classes: ['daggerheart', 'views', 'death-move'],
|
||||
position: { width: 800, height: 'auto' },
|
||||
actions: {
|
||||
selectMove: this.selectMove,
|
||||
takeMove: this.takeMove,
|
||||
},
|
||||
takeMove: this.takeMove
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
application: {
|
||||
id: "death-move",
|
||||
template: "systems/daggerheart/templates/views/deathMove.hbs"
|
||||
id: 'death-move',
|
||||
template: 'systems/daggerheart/templates/views/deathMove.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -36,28 +36,27 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
|
|||
return context;
|
||||
}
|
||||
|
||||
|
||||
static selectMove(_, button){
|
||||
static selectMove(_, button) {
|
||||
const move = button.dataset.move;
|
||||
this.selectedMove = SYSTEM.GENERAL.deathMoves[move];
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async takeMove(){
|
||||
const cls = getDocumentClass("ChatMessage");
|
||||
static async takeMove() {
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = new cls({
|
||||
user: game.user.id,
|
||||
content: await renderTemplate("systems/daggerheart/templates/chat/deathMove.hbs", {
|
||||
player: game.user.character.name,
|
||||
title: game.i18n.localize(this.selectedMove.name),
|
||||
content: await renderTemplate('systems/daggerheart/templates/chat/deathMove.hbs', {
|
||||
player: game.user.character.name,
|
||||
title: game.i18n.localize(this.selectedMove.name),
|
||||
img: this.selectedMove.img,
|
||||
description: game.i18n.localize(this.selectedMove.description),
|
||||
}),
|
||||
description: game.i18n.localize(this.selectedMove.description)
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
cls.create(msg.toObject());
|
||||
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const {HandlebarsApplicationMixin, ApplicationV2} = foundry.applications.api;
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actor, shortrest){
|
||||
constructor(actor, shortrest) {
|
||||
super({});
|
||||
|
||||
this.actor = actor;
|
||||
|
|
@ -11,27 +11,27 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
|||
this.customActivity = SYSTEM.GENERAL.downtime.custom;
|
||||
}
|
||||
|
||||
get title(){
|
||||
return `${this.actor.name} - ${this.shortrest ? 'Short Rest': 'Long Rest'}`;
|
||||
get title() {
|
||||
return `${this.actor.name} - ${this.shortrest ? 'Short Rest' : 'Long Rest'}`;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ["daggerheart", "views", "downtime"],
|
||||
classes: ['daggerheart', 'views', 'downtime'],
|
||||
position: { width: 800, height: 'auto' },
|
||||
actions: {
|
||||
selectActivity: this.selectActivity,
|
||||
takeDowntime: this.takeDowntime,
|
||||
takeDowntime: this.takeDowntime
|
||||
},
|
||||
form: { handler: this.updateData, submitOnChange: true }
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
application: {
|
||||
id: "downtime",
|
||||
template: "systems/daggerheart/templates/views/downtime.hbs"
|
||||
id: 'downtime',
|
||||
template: 'systems/daggerheart/templates/views/downtime.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -39,44 +39,53 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
|||
context.options = this.shortrest ? SYSTEM.GENERAL.downtime.shortRest : SYSTEM.GENERAL.downtime.longRest;
|
||||
context.customActivity = this.customActivity;
|
||||
|
||||
context.disabledDowntime = !this.selectedActivity || (this.selectedActivity.id === this.customActivity.id && (!this.customActivity.name || !this.customActivity.description));
|
||||
context.disabledDowntime =
|
||||
!this.selectedActivity ||
|
||||
(this.selectedActivity.id === this.customActivity.id &&
|
||||
(!this.customActivity.name || !this.customActivity.description));
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
static selectActivity(_, button){
|
||||
static selectActivity(_, button) {
|
||||
const activity = button.dataset.activity;
|
||||
this.selectedActivity = activity === this.customActivity.id ? this.customActivity : this.shortrest ? SYSTEM.GENERAL.downtime.shortRest[activity] : SYSTEM.GENERAL.downtime.longRest[activity];
|
||||
this.selectedActivity =
|
||||
activity === this.customActivity.id
|
||||
? this.customActivity
|
||||
: this.shortrest
|
||||
? SYSTEM.GENERAL.downtime.shortRest[activity]
|
||||
: SYSTEM.GENERAL.downtime.longRest[activity];
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async takeDowntime(){
|
||||
const refreshedFeatures = this.shortrest ? this.actor.system.refreshableFeatures.shortRest : [...this.actor.system.refreshableFeatures.shortRest, ...this.actor.system.refreshableFeatures.longRest];
|
||||
for(var feature of refreshedFeatures){
|
||||
static async takeDowntime() {
|
||||
const refreshedFeatures = this.shortrest
|
||||
? this.actor.system.refreshableFeatures.shortRest
|
||||
: [...this.actor.system.refreshableFeatures.shortRest, ...this.actor.system.refreshableFeatures.longRest];
|
||||
for (var feature of refreshedFeatures) {
|
||||
await feature.system.refresh();
|
||||
}
|
||||
|
||||
const cls = getDocumentClass("ChatMessage");
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = new cls({
|
||||
user: game.user.id,
|
||||
content: await renderTemplate("systems/daggerheart/templates/chat/downtime.hbs", {
|
||||
player: game.user.character.name,
|
||||
title: game.i18n.localize(this.selectedActivity.name),
|
||||
content: await renderTemplate('systems/daggerheart/templates/chat/downtime.hbs', {
|
||||
player: game.user.character.name,
|
||||
title: game.i18n.localize(this.selectedActivity.name),
|
||||
img: this.selectedActivity.img,
|
||||
description: game.i18n.localize(this.selectedActivity.description),
|
||||
refreshedFeatures: refreshedFeatures,
|
||||
}),
|
||||
refreshedFeatures: refreshedFeatures
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
cls.create(msg.toObject());
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
||||
static async updateData(event, element, formData){
|
||||
static async updateData(event, element, formData) {
|
||||
this.customActivity = foundry.utils.mergeObject(this.customActivity, formData.object);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,77 +1,82 @@
|
|||
import SelectDialog from "../dialogs/selectDialog.mjs";
|
||||
import { getTier } from "../helpers/utils.mjs";
|
||||
import DhpMulticlassDialog from "./multiclassDialog.mjs";
|
||||
import SelectDialog from '../dialogs/selectDialog.mjs';
|
||||
import { getTier } from '../helpers/utils.mjs';
|
||||
import DhpMulticlassDialog from './multiclassDialog.mjs';
|
||||
|
||||
const {HandlebarsApplicationMixin, ApplicationV2} = foundry.applications.api;
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhpLevelup extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actor){
|
||||
constructor(actor) {
|
||||
super({});
|
||||
|
||||
this.actor = actor;
|
||||
this.data = foundry.utils.deepClone(actor.system.levelData);
|
||||
this.activeLevel = actor.system.levelData.currentLevel+1;
|
||||
this.activeLevel = actor.system.levelData.currentLevel + 1;
|
||||
}
|
||||
|
||||
get title(){
|
||||
return `${this.actor.name} - Level Up`;
|
||||
get title() {
|
||||
return `${this.actor.name} - Level Up`;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: "daggerheart-levelup",
|
||||
classes: ["daggerheart", "views", "levelup"],
|
||||
id: 'daggerheart-levelup',
|
||||
classes: ['daggerheart', 'views', 'levelup'],
|
||||
position: { width: 1200, height: 'auto' },
|
||||
window: {
|
||||
resizable: true,
|
||||
resizable: true
|
||||
},
|
||||
|
||||
actions: {
|
||||
toggleBox: this.toggleBox,
|
||||
advanceLevel: this.advanceLevel,
|
||||
finishLevelup: this.finishLevelup,
|
||||
},
|
||||
finishLevelup: this.finishLevelup
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "levelup",
|
||||
template: "systems/daggerheart/templates/views/levelup.hbs"
|
||||
id: 'levelup',
|
||||
template: 'systems/daggerheart/templates/views/levelup.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
let selectedChoices = 0, multiclassing = {}, subclassing = {};
|
||||
const leveledTiers = Object.keys(this.data.levelups).reduce((acc, levelKey) => {
|
||||
const levelData = this.data.levelups[levelKey];
|
||||
['tier1','tier2','tier3'].forEach(tierKey => {
|
||||
let tierUpdate = {};
|
||||
const tierData = levelData[tierKey];
|
||||
if(tierData){
|
||||
tierUpdate = Object.keys(tierData).reduce((acc, propertyKey) => {
|
||||
const values = tierData[propertyKey];
|
||||
const level = Number.parseInt(levelKey);
|
||||
let selectedChoices = 0,
|
||||
multiclassing = {},
|
||||
subclassing = {};
|
||||
const leveledTiers = Object.keys(this.data.levelups).reduce(
|
||||
(acc, levelKey) => {
|
||||
const levelData = this.data.levelups[levelKey];
|
||||
['tier1', 'tier2', 'tier3'].forEach(tierKey => {
|
||||
let tierUpdate = {};
|
||||
const tierData = levelData[tierKey];
|
||||
if (tierData) {
|
||||
tierUpdate = Object.keys(tierData).reduce((acc, propertyKey) => {
|
||||
const values = tierData[propertyKey];
|
||||
const level = Number.parseInt(levelKey);
|
||||
|
||||
acc[propertyKey] = Object.values(values).map(value => {
|
||||
if(value && level === this.activeLevel) selectedChoices++;
|
||||
if(propertyKey === 'multiclass') multiclassing[levelKey] = true;
|
||||
if(propertyKey === 'subclass') subclassing[tierKey] = true;
|
||||
|
||||
return { level: level, value: value };
|
||||
});
|
||||
acc[propertyKey] = Object.values(values).map(value => {
|
||||
if (value && level === this.activeLevel) selectedChoices++;
|
||||
if (propertyKey === 'multiclass') multiclassing[levelKey] = true;
|
||||
if (propertyKey === 'subclass') subclassing[tierKey] = true;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
Object.keys(tierUpdate).forEach(propertyKey => {
|
||||
const property = tierUpdate[propertyKey];
|
||||
const propertyValues = foundry.utils.getProperty(acc, `${tierKey}.${propertyKey}`)??[];
|
||||
foundry.utils.setProperty(acc, `${tierKey}.${propertyKey}`, [...propertyValues, ...property]);
|
||||
return { level: level, value: value };
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
Object.keys(tierUpdate).forEach(propertyKey => {
|
||||
const property = tierUpdate[propertyKey];
|
||||
const propertyValues = foundry.utils.getProperty(acc, `${tierKey}.${propertyKey}`) ?? [];
|
||||
foundry.utils.setProperty(acc, `${tierKey}.${propertyKey}`, [...propertyValues, ...property]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, { tier1: {}, tier2: {}, tier3: {} });
|
||||
return acc;
|
||||
},
|
||||
{ tier1: {}, tier2: {}, tier3: {} }
|
||||
);
|
||||
|
||||
const activeTier = getTier(this.activeLevel);
|
||||
const data = Object.keys(SYSTEM.ACTOR.levelupData).reduce((acc, tierKey) => {
|
||||
|
|
@ -85,21 +90,35 @@ export default class DhpLevelup extends HandlebarsApplicationMixin(ApplicationV2
|
|||
choices: Object.keys(tier.choices).reduce((acc, propertyKey) => {
|
||||
const property = tier.choices[propertyKey];
|
||||
acc[propertyKey] = { description: property.description, cost: property.cost ?? 1, values: [] };
|
||||
for(var i = 0; i < property.maxChoices; i++){
|
||||
for (var i = 0; i < property.maxChoices; i++) {
|
||||
const leveledValue = leveledTiers[tierKey][propertyKey]?.[i];
|
||||
const subclassLock = propertyKey === 'subclass' && Object.keys(multiclassing).find(x => getTier(Number.parseInt(x)) === tierKey);
|
||||
const subclassLock =
|
||||
propertyKey === 'subclass' &&
|
||||
Object.keys(multiclassing).find(x => getTier(Number.parseInt(x)) === tierKey);
|
||||
const subclassMulticlassLock = propertyKey === 'multiclass' && subclassing[tierKey];
|
||||
const multiclassLock = propertyKey === 'multiclass' && Object.keys(multiclassing).length > 0 && !(leveledValue && Object.keys(multiclassing).find(x => Number.parseInt(x) === leveledValue.level));
|
||||
const locked = leveledValue && leveledValue.level !== this.activeLevel || subclassLock || subclassMulticlassLock || multiclassLock;
|
||||
const disabled = tierKey > activeTier || (selectedChoices === 2 && !(leveledValue && leveledValue.level === this.activeLevel)) || locked;
|
||||
|
||||
const multiclassLock =
|
||||
propertyKey === 'multiclass' &&
|
||||
Object.keys(multiclassing).length > 0 &&
|
||||
!(
|
||||
leveledValue &&
|
||||
Object.keys(multiclassing).find(x => Number.parseInt(x) === leveledValue.level)
|
||||
);
|
||||
const locked =
|
||||
(leveledValue && leveledValue.level !== this.activeLevel) ||
|
||||
subclassLock ||
|
||||
subclassMulticlassLock ||
|
||||
multiclassLock;
|
||||
const disabled =
|
||||
tierKey > activeTier ||
|
||||
(selectedChoices === 2 && !(leveledValue && leveledValue.level === this.activeLevel)) ||
|
||||
locked;
|
||||
|
||||
acc[propertyKey].values.push({
|
||||
selected: leveledValue?.value !== undefined,
|
||||
path: `levelups.${this.activeLevel}.${tierKey}.${propertyKey}.${i}`,
|
||||
description: game.i18n.localize(property.description),
|
||||
disabled: disabled,
|
||||
locked: locked,
|
||||
locked: locked
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -114,70 +133,122 @@ export default class DhpLevelup extends HandlebarsApplicationMixin(ApplicationV2
|
|||
data: data,
|
||||
activeLevel: this.activeLevel,
|
||||
changedLevel: this.actor.system.levelData.changedLevel,
|
||||
completedSelection: selectedChoices === 2,
|
||||
}
|
||||
completedSelection: selectedChoices === 2
|
||||
};
|
||||
}
|
||||
|
||||
static async toggleBox(_, button){
|
||||
static async toggleBox(_, button) {
|
||||
const path = button.dataset.path;
|
||||
if(foundry.utils.getProperty(this.data, path)){
|
||||
if (foundry.utils.getProperty(this.data, path)) {
|
||||
const pathParts = path.split('.');
|
||||
const arrayPart = pathParts.slice(0, pathParts.length-1).join('.');
|
||||
const arrayPart = pathParts.slice(0, pathParts.length - 1).join('.');
|
||||
let array = foundry.utils.getProperty(this.data, arrayPart);
|
||||
if(button.dataset.levelAttribute === 'multiclass'){
|
||||
if (button.dataset.levelAttribute === 'multiclass') {
|
||||
array = [];
|
||||
}
|
||||
else {
|
||||
delete array[Number.parseInt(pathParts[pathParts.length-1])];
|
||||
} else {
|
||||
delete array[Number.parseInt(pathParts[pathParts.length - 1])];
|
||||
}
|
||||
foundry.utils.setProperty(this.data, arrayPart, array);
|
||||
} else {
|
||||
const updates = [{ path: path, value: { level: this.activeLevel } }];
|
||||
const levelChoices = SYSTEM.ACTOR.levelChoices[button.dataset.levelAttribute];
|
||||
if(button.dataset.levelAttribute === 'subclass'){
|
||||
if(!this.actor.system.multiclassSubclass){
|
||||
updates[0].value.value = { multiclass: false, feature: this.actor.system.subclass.system.specializationFeature.unlocked ? 'mastery' : 'specialization' };
|
||||
}
|
||||
else {
|
||||
const choices = [{name: this.actor.system.subclass.name, value: this.actor.system.subclass.uuid}, {name: this.actor.system.multiclassSubclass.name, value: this.actor.system.multiclassSubclass.uuid}];
|
||||
const indexes = await SelectDialog.selectItem({ actor: this.actor, choices: choices, title: levelChoices.title, nrChoices: 1 });
|
||||
if(indexes.length === 0) {
|
||||
if (button.dataset.levelAttribute === 'subclass') {
|
||||
if (!this.actor.system.multiclassSubclass) {
|
||||
updates[0].value.value = {
|
||||
multiclass: false,
|
||||
feature: this.actor.system.subclass.system.specializationFeature.unlocked
|
||||
? 'mastery'
|
||||
: 'specialization'
|
||||
};
|
||||
} else {
|
||||
const choices = [
|
||||
{ name: this.actor.system.subclass.name, value: this.actor.system.subclass.uuid },
|
||||
{
|
||||
name: this.actor.system.multiclassSubclass.name,
|
||||
value: this.actor.system.multiclassSubclass.uuid
|
||||
}
|
||||
];
|
||||
const indexes = await SelectDialog.selectItem({
|
||||
actor: this.actor,
|
||||
choices: choices,
|
||||
title: levelChoices.title,
|
||||
nrChoices: 1
|
||||
});
|
||||
if (indexes.length === 0) {
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
const multiclassSubclass = choices[indexes[0]].name === this.actor.system.multiclassSubclass.name;
|
||||
updates[0].value.value = { multiclass: multiclassSubclass, feature: this.actor.system.multiclassSubclass.system.specializationFeature.unlocked ? 'mastery' : 'specialization' };
|
||||
updates[0].value.value = {
|
||||
multiclass: multiclassSubclass,
|
||||
feature: this.actor.system.multiclassSubclass.system.specializationFeature.unlocked
|
||||
? 'mastery'
|
||||
: 'specialization'
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (button.dataset.levelAttribute === 'multiclass'){
|
||||
const multiclassAwait = new Promise((resolve) => {
|
||||
} else if (button.dataset.levelAttribute === 'multiclass') {
|
||||
const multiclassAwait = new Promise(resolve => {
|
||||
new DhpMulticlassDialog(this.actor.name, this.actor.system.class, resolve).render(true);
|
||||
});
|
||||
const multiclassData = await multiclassAwait;
|
||||
if(!multiclassData) {
|
||||
if (!multiclassData) {
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
|
||||
const pathParts = path.split('.');
|
||||
const arrayPart = pathParts.slice(0, pathParts.length-1).join('.');
|
||||
updates[0] = { path: [arrayPart, '0'].join('.'), value: { level: this.activeLevel, value: { class: multiclassData.class, subclass: multiclassData.subclass, domain: multiclassData.domain, level: this.activeLevel } } };
|
||||
updates[1] = { path: [arrayPart, '1'].join('.'), value: { level: this.activeLevel, value: { class: multiclassData.class, subclass: multiclassData.subclass, domain: multiclassData.domain, level: this.activeLevel } } };
|
||||
}
|
||||
else {
|
||||
if(levelChoices.choices.length > 0){
|
||||
if(typeof levelChoices.choices === 'string'){
|
||||
const choices = foundry.utils.getProperty(this.actor, levelChoices.choices).map(x => ({ name: x.description, value: x.id }));
|
||||
const indexes = await SelectDialog.selectItem({ actor: this.actor, choices: choices, title: levelChoices.title, nrChoices: levelChoices.nrChoices });
|
||||
if(indexes.length === 0) {
|
||||
const arrayPart = pathParts.slice(0, pathParts.length - 1).join('.');
|
||||
updates[0] = {
|
||||
path: [arrayPart, '0'].join('.'),
|
||||
value: {
|
||||
level: this.activeLevel,
|
||||
value: {
|
||||
class: multiclassData.class,
|
||||
subclass: multiclassData.subclass,
|
||||
domain: multiclassData.domain,
|
||||
level: this.activeLevel
|
||||
}
|
||||
}
|
||||
};
|
||||
updates[1] = {
|
||||
path: [arrayPart, '1'].join('.'),
|
||||
value: {
|
||||
level: this.activeLevel,
|
||||
value: {
|
||||
class: multiclassData.class,
|
||||
subclass: multiclassData.subclass,
|
||||
domain: multiclassData.domain,
|
||||
level: this.activeLevel
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
if (levelChoices.choices.length > 0) {
|
||||
if (typeof levelChoices.choices === 'string') {
|
||||
const choices = foundry.utils
|
||||
.getProperty(this.actor, levelChoices.choices)
|
||||
.map(x => ({ name: x.description, value: x.id }));
|
||||
const indexes = await SelectDialog.selectItem({
|
||||
actor: this.actor,
|
||||
choices: choices,
|
||||
title: levelChoices.title,
|
||||
nrChoices: levelChoices.nrChoices
|
||||
});
|
||||
if (indexes.length === 0) {
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
updates[0].value.value = choices.filter((_, index) => indexes.includes(index)).map(x => x.value);
|
||||
}
|
||||
else {
|
||||
const indexes = await SelectDialog.selectItem({ actor: this.actor, choices: levelChoices.choices, title: levelChoices.title, nrChoices: levelChoices.nrChoices });
|
||||
if(indexes.length === 0) {
|
||||
updates[0].value.value = choices
|
||||
.filter((_, index) => indexes.includes(index))
|
||||
.map(x => x.value);
|
||||
} else {
|
||||
const indexes = await SelectDialog.selectItem({
|
||||
actor: this.actor,
|
||||
choices: levelChoices.choices,
|
||||
title: levelChoices.title,
|
||||
nrChoices: levelChoices.nrChoices
|
||||
});
|
||||
if (indexes.length === 0) {
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
|
|
@ -198,44 +269,57 @@ export default class DhpLevelup extends HandlebarsApplicationMixin(ApplicationV2
|
|||
this.render();
|
||||
}
|
||||
|
||||
static advanceLevel(){
|
||||
static advanceLevel() {
|
||||
this.activeLevel += 1;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async finishLevelup(){
|
||||
static async finishLevelup() {
|
||||
this.data.currentLevel = this.data.changedLevel;
|
||||
let multiclass = null;
|
||||
for(var level in this.data.levelups){
|
||||
for(var tier in this.data.levelups[level]){
|
||||
for(var category in this.data.levelups[level][tier]) {
|
||||
for (var value in this.data.levelups[level][tier][category]){
|
||||
if(category === 'multiclass'){
|
||||
for (var level in this.data.levelups) {
|
||||
for (var tier in this.data.levelups[level]) {
|
||||
for (var category in this.data.levelups[level][tier]) {
|
||||
for (var value in this.data.levelups[level][tier][category]) {
|
||||
if (category === 'multiclass') {
|
||||
multiclass = this.data.levelups[level][tier][category][value].value;
|
||||
this.data.levelups[level][tier][category][value] = true;
|
||||
} else {
|
||||
this.data.levelups[level][tier][category][value] = this.data.levelups[level][tier][category][value].value ?? true;
|
||||
this.data.levelups[level][tier][category][value] =
|
||||
this.data.levelups[level][tier][category][value].value ?? true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tiersMoved = getTier(this.actor.system.levelData.changedLevel, true) - getTier(this.actor.system.levelData.currentLevel, true);
|
||||
const experiences = Array.from(Array(tiersMoved), (_,index) => ({ id: foundry.utils.randomID(), level: this.actor.system.experiences.length+index*3, description: '', value: 1 }));
|
||||
const tiersMoved =
|
||||
getTier(this.actor.system.levelData.changedLevel, true) -
|
||||
getTier(this.actor.system.levelData.currentLevel, true);
|
||||
const experiences = Array.from(Array(tiersMoved), (_, index) => ({
|
||||
id: foundry.utils.randomID(),
|
||||
level: this.actor.system.experiences.length + index * 3,
|
||||
description: '',
|
||||
value: 1
|
||||
}));
|
||||
|
||||
await this.actor.update({ system: {
|
||||
levelData: this.data,
|
||||
experiences: [...this.actor.system.experiences, ...experiences],
|
||||
}}, { diff: false });
|
||||
await this.actor.update(
|
||||
{
|
||||
system: {
|
||||
levelData: this.data,
|
||||
experiences: [...this.actor.system.experiences, ...experiences]
|
||||
}
|
||||
},
|
||||
{ diff: false }
|
||||
);
|
||||
|
||||
if(!this.actor.multiclass && multiclass){
|
||||
if (!this.actor.multiclass && multiclass) {
|
||||
const multiclassClass = (await fromUuid(multiclass.class.uuid)).toObject();
|
||||
multiclassClass.system.domains = [multiclass.domain.id];
|
||||
multiclassClass.system.multiclass = multiclass.level;
|
||||
|
||||
const multiclassFeatures = [];
|
||||
for(var i = 0; i < multiclassClass.system.features.length; i++){
|
||||
for (var i = 0; i < multiclassClass.system.features.length; i++) {
|
||||
const feature = (await fromUuid(multiclassClass.system.features[i].uuid)).toObject();
|
||||
feature.system.multiclass = multiclass.level;
|
||||
multiclassFeatures.push(feature);
|
||||
|
|
@ -243,17 +327,21 @@ export default class DhpLevelup extends HandlebarsApplicationMixin(ApplicationV2
|
|||
|
||||
const multiclassSubclass = (await fromUuid(multiclass.subclass.uuid)).toObject();
|
||||
multiclassSubclass.system.multiclass = multiclass.level;
|
||||
|
||||
|
||||
const multiclassSubclassFeatures = {};
|
||||
const features = [multiclassSubclass.system.foundationFeature, multiclassSubclass.system.specializationFeature, multiclassSubclass.system.masteryFeature];
|
||||
for(var i = 0; i < features.length; i++){
|
||||
const features = [
|
||||
multiclassSubclass.system.foundationFeature,
|
||||
multiclassSubclass.system.specializationFeature,
|
||||
multiclassSubclass.system.masteryFeature
|
||||
];
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
const path = i === 0 ? 'foundationFeature' : i === 1 ? 'specializationFeature' : 'masteryFeature';
|
||||
const feature = features[i];
|
||||
for(var ability of feature.abilities){
|
||||
for (var ability of feature.abilities) {
|
||||
const data = (await fromUuid(ability.uuid)).toObject();
|
||||
if(i > 0 ) data.system.disabled = true;
|
||||
if (i > 0) data.system.disabled = true;
|
||||
data.system.multiclass = multiclass.level;
|
||||
if(!multiclassSubclassFeatures[path]) multiclassSubclassFeatures[path] = [data];
|
||||
if (!multiclassSubclassFeatures[path]) multiclassSubclassFeatures[path] = [data];
|
||||
else multiclassSubclassFeatures[path].push(data);
|
||||
// data.uuid = feature.uuid;
|
||||
|
||||
|
|
@ -264,18 +352,21 @@ export default class DhpLevelup extends HandlebarsApplicationMixin(ApplicationV2
|
|||
}
|
||||
}
|
||||
|
||||
for(let subclassFeaturesKey in multiclassSubclassFeatures){
|
||||
for (let subclassFeaturesKey in multiclassSubclassFeatures) {
|
||||
const values = multiclassSubclassFeatures[subclassFeaturesKey];
|
||||
const abilityResults = await this.actor.createEmbeddedDocuments('Item', values);
|
||||
for(var i = 0; i < abilityResults.length; i++){
|
||||
for (var i = 0; i < abilityResults.length; i++) {
|
||||
multiclassSubclass.system[subclassFeaturesKey].abilities[i].uuid = abilityResults[i].uuid;
|
||||
}
|
||||
}
|
||||
|
||||
await this.actor.createEmbeddedDocuments('Item', [multiclassClass, ...multiclassFeatures, multiclassSubclass]);
|
||||
}
|
||||
|
||||
await this.actor.createEmbeddedDocuments('Item', [
|
||||
multiclassClass,
|
||||
...multiclassFeatures,
|
||||
multiclassSubclass
|
||||
]);
|
||||
}
|
||||
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +1,60 @@
|
|||
const {HandlebarsApplicationMixin, ApplicationV2} = foundry.applications.api;
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhpMulticlassDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actorName, actorClass, resolve){
|
||||
constructor(actorName, actorClass, resolve) {
|
||||
super({});
|
||||
|
||||
this.actorName = actorName;
|
||||
this.actorClass = actorClass;
|
||||
this.resolve = resolve;
|
||||
|
||||
this.classChoices = Array.from(game.items.reduce((acc, x) => {
|
||||
if(x.type === 'class' && x.name !== actorClass.name){
|
||||
acc.add(x);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, new Set()));
|
||||
this.classChoices = Array.from(
|
||||
game.items.reduce((acc, x) => {
|
||||
if (x.type === 'class' && x.name !== actorClass.name) {
|
||||
acc.add(x);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, new Set())
|
||||
);
|
||||
this.subclassChoices = [];
|
||||
this.domainChoices = [];
|
||||
|
||||
this.data = {
|
||||
class: null,
|
||||
subclass: null,
|
||||
domain: null,
|
||||
domain: null
|
||||
};
|
||||
}
|
||||
|
||||
get title(){
|
||||
return `${this.actorName} - Multiclass`;
|
||||
get title() {
|
||||
return `${this.actorName} - Multiclass`;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["daggerheart", "views", "multiclass"],
|
||||
classes: ['daggerheart', 'views', 'multiclass'],
|
||||
position: { width: 600, height: 'auto' },
|
||||
actions: {
|
||||
selectClass: this.selectClass,
|
||||
selectSubclass: this.selectSubclass,
|
||||
selectDomain: this.selectDomain,
|
||||
finish: this.finish,
|
||||
},
|
||||
finish: this.finish
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "levelup",
|
||||
template: "systems/daggerheart/templates/views/multiclass.hbs"
|
||||
id: 'levelup',
|
||||
template: 'systems/daggerheart/templates/views/multiclass.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.classChoices = this.classChoices;
|
||||
context.subclassChoices = this.subclassChoices;
|
||||
context.domainChoices = this.domainChoices;
|
||||
context.disabledFinish = !this.data.class || !this.data.subclass || !this.data.domain;
|
||||
context.disabledFinish = !this.data.class || !this.data.subclass || !this.data.domain;
|
||||
context.data = this.data;
|
||||
|
||||
return context;
|
||||
|
|
@ -61,38 +63,51 @@ export default class DhpMulticlassDialog extends HandlebarsApplicationMixin(Appl
|
|||
static async selectClass(_, button) {
|
||||
const oldClass = this.data.class;
|
||||
this.data.class = this.data.class?.uuid === button.dataset.class ? null : await fromUuid(button.dataset.class);
|
||||
if(oldClass !== button.dataset.class){
|
||||
if (oldClass !== button.dataset.class) {
|
||||
this.data.subclass = null;
|
||||
this.data.domain = null;
|
||||
this.subclassChoices = this.data.class ? this.data.class.system.subclasses : [];
|
||||
this.domainChoices = this.data.class ? this.data.class.system.domains.map(x => {
|
||||
const config = SYSTEM.DOMAIN.domains[x];
|
||||
return { name: game.i18n.localize(config.name), id: config.id, img: config.src, disabled: this.actorClass.system.domains.includes(config.id) };
|
||||
}) : [];
|
||||
this.domainChoices = this.data.class
|
||||
? this.data.class.system.domains.map(x => {
|
||||
const config = SYSTEM.DOMAIN.domains[x];
|
||||
return {
|
||||
name: game.i18n.localize(config.name),
|
||||
id: config.id,
|
||||
img: config.src,
|
||||
disabled: this.actorClass.system.domains.includes(config.id)
|
||||
};
|
||||
})
|
||||
: [];
|
||||
}
|
||||
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async selectSubclass(_, button) {
|
||||
this.data.subclass = this.data.subclass?.uuid === button.dataset.subclass ? null : this.subclassChoices.find(x => x.uuid === button.dataset.subclass);
|
||||
this.data.subclass =
|
||||
this.data.subclass?.uuid === button.dataset.subclass
|
||||
? null
|
||||
: this.subclassChoices.find(x => x.uuid === button.dataset.subclass);
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async selectDomain(_, button) {
|
||||
const domain = this.data.domain?.id === button.dataset.domain ? null : this.domainChoices.find(x => x.id === button.dataset.domain);;
|
||||
if(domain?.disabled) return;
|
||||
const domain =
|
||||
this.data.domain?.id === button.dataset.domain
|
||||
? null
|
||||
: this.domainChoices.find(x => x.id === button.dataset.domain);
|
||||
if (domain?.disabled) return;
|
||||
|
||||
this.data.domain = domain;
|
||||
this.data.domain = domain;
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static finish(){
|
||||
static finish() {
|
||||
this.close({}, this.data);
|
||||
}
|
||||
|
||||
async close(options={}, data=null) {
|
||||
async close(options = {}, data = null) {
|
||||
this.resolve(data);
|
||||
super.close(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,76 +1,81 @@
|
|||
export default class NpcRollSelectionDialog extends FormApplication {
|
||||
constructor(experiences, resolve, isNpc){
|
||||
super({}, {});
|
||||
constructor(experiences, resolve, isNpc) {
|
||||
super({}, {});
|
||||
|
||||
this.experiences = experiences;
|
||||
this.resolve = resolve;
|
||||
this.selectedExperiences = [];
|
||||
this.data = {
|
||||
nrDice: 1,
|
||||
advantage: null,
|
||||
};
|
||||
}
|
||||
this.experiences = experiences;
|
||||
this.resolve = resolve;
|
||||
this.selectedExperiences = [];
|
||||
this.data = {
|
||||
nrDice: 1,
|
||||
advantage: null
|
||||
};
|
||||
}
|
||||
|
||||
get title (){
|
||||
return 'Roll Options';
|
||||
}
|
||||
get title() {
|
||||
return 'Roll Options';
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'roll-selection',
|
||||
template: 'systems/daggerheart/templates/views/npcRollSelection.hbs',
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true,
|
||||
classes: ["daggerheart", "views", "npc-roll-selection"],
|
||||
};
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData(){
|
||||
const context = super.getData();
|
||||
context.nrDice = this.data.nrDice;
|
||||
context.advantage = this.data.advantage;
|
||||
context.experiences = this.experiences.map(x => ({ ...x, selected: this.selectedExperiences.find(selected => selected.id === x.id) }));
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'roll-selection',
|
||||
template: 'systems/daggerheart/templates/views/npcRollSelection.hbs',
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true,
|
||||
classes: ['daggerheart', 'views', 'npc-roll-selection']
|
||||
};
|
||||
|
||||
return context;
|
||||
}
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
html.find('.increase').click(_ => this.updateNrDice(1));
|
||||
html.find('.decrease').click(_ => this.updateNrDice(-1));
|
||||
html.find('.advantage').click(_ => this.updateIsAdvantage(true));
|
||||
html.find('.disadvantage').click(_ => this.updateIsAdvantage(false));
|
||||
html.find('.roll-button').click(this.finish.bind(this));
|
||||
html.find('.roll-dialog-chip').click(this.selectExperience.bind(this));
|
||||
}
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.nrDice = this.data.nrDice;
|
||||
context.advantage = this.data.advantage;
|
||||
context.experiences = this.experiences.map(x => ({
|
||||
...x,
|
||||
selected: this.selectedExperiences.find(selected => selected.id === x.id)
|
||||
}));
|
||||
|
||||
updateNrDice(value){
|
||||
this.data.nrDice += value;
|
||||
this.render();
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
updateIsAdvantage(advantage) {
|
||||
this.data.advantage = this.data.advantage === advantage ? null : advantage;
|
||||
this.render();
|
||||
}
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
selectExperience(event){
|
||||
const experience = this.experiences[event.currentTarget.dataset.key];
|
||||
this.selectedExperiences = this.selectedExperiences.find(x => x.name === experience.name) ? this.selectedExperiences.filter(x => x.name !== experience.name) : [...this.selectedExperiences, experience];
|
||||
html.find('.increase').click(_ => this.updateNrDice(1));
|
||||
html.find('.decrease').click(_ => this.updateNrDice(-1));
|
||||
html.find('.advantage').click(_ => this.updateIsAdvantage(true));
|
||||
html.find('.disadvantage').click(_ => this.updateIsAdvantage(false));
|
||||
html.find('.roll-button').click(this.finish.bind(this));
|
||||
html.find('.roll-dialog-chip').click(this.selectExperience.bind(this));
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
updateNrDice(value) {
|
||||
this.data.nrDice += value;
|
||||
this.render();
|
||||
}
|
||||
|
||||
finish(){
|
||||
this.resolve({ ...this.data, experiences: this.selectedExperiences });
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
updateIsAdvantage(advantage) {
|
||||
this.data.advantage = this.data.advantage === advantage ? null : advantage;
|
||||
this.render();
|
||||
}
|
||||
|
||||
selectExperience(event) {
|
||||
const experience = this.experiences[event.currentTarget.dataset.key];
|
||||
this.selectedExperiences = this.selectedExperiences.find(x => x.name === experience.name)
|
||||
? this.selectedExperiences.filter(x => x.name !== experience.name)
|
||||
: [...this.selectedExperiences, experience];
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
finish() {
|
||||
this.resolve({ ...this.data, experiences: this.selectedExperiences });
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,147 +1,161 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class RollSelectionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(experiences, bonusDamage, hopeResource, resolve, isNpc){
|
||||
super({}, {});
|
||||
constructor(experiences, bonusDamage, hopeResource, resolve, isNpc) {
|
||||
super({}, {});
|
||||
|
||||
this.experiences = experiences;
|
||||
this.resolve = resolve;
|
||||
this.isNpc;
|
||||
this.selectedExperiences = [];
|
||||
this.data = {
|
||||
diceOptions: [{ name: 'd12', value: 'd12' }, { name: 'd20', value: 'd20' }],
|
||||
hope: ['d12'],
|
||||
fear: ['d12'],
|
||||
advantage: null,
|
||||
disadvantage: null,
|
||||
bonusDamage: bonusDamage.reduce((acc, x) => {
|
||||
if(x.appliesOn === SYSTEM.EFFECTS.applyLocations.attackRoll.id){
|
||||
acc.push(({
|
||||
...x,
|
||||
hopeUses: 0
|
||||
}));
|
||||
this.experiences = experiences;
|
||||
this.resolve = resolve;
|
||||
this.isNpc;
|
||||
this.selectedExperiences = [];
|
||||
this.data = {
|
||||
diceOptions: [
|
||||
{ name: 'd12', value: 'd12' },
|
||||
{ name: 'd20', value: 'd20' }
|
||||
],
|
||||
hope: ['d12'],
|
||||
fear: ['d12'],
|
||||
advantage: null,
|
||||
disadvantage: null,
|
||||
bonusDamage: bonusDamage.reduce((acc, x) => {
|
||||
if (x.appliesOn === SYSTEM.EFFECTS.applyLocations.attackRoll.id) {
|
||||
acc.push({
|
||||
...x,
|
||||
hopeUses: 0
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
hopeResource: hopeResource
|
||||
};
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'views', 'roll-selection'],
|
||||
position: {
|
||||
width: 400,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
selectExperience: this.selectExperience,
|
||||
decreaseHopeUse: this.decreaseHopeUse,
|
||||
increaseHopeUse: this.increaseHopeUse,
|
||||
setAdvantage: this.setAdvantage,
|
||||
setDisadvantage: this.setDisadvantage,
|
||||
finish: this.finish
|
||||
},
|
||||
form: {
|
||||
handler: this.updateSelection,
|
||||
submitOnChange: true,
|
||||
submitOnClose: false
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
hopeResource: hopeResource,
|
||||
};
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ["daggerheart", "views", "roll-selection"],
|
||||
position: {
|
||||
width: 400,
|
||||
height: "auto"
|
||||
},
|
||||
actions: {
|
||||
selectExperience: this.selectExperience,
|
||||
decreaseHopeUse: this.decreaseHopeUse,
|
||||
increaseHopeUse: this.increaseHopeUse,
|
||||
setAdvantage: this.setAdvantage,
|
||||
setDisadvantage: this.setDisadvantage,
|
||||
finish: this.finish,
|
||||
},
|
||||
form: {
|
||||
handler: this.updateSelection,
|
||||
submitOnChange: true,
|
||||
submitOnClose: false,
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: "damageSelection",
|
||||
template: "systems/daggerheart/templates/views/rollSelection.hbs"
|
||||
}
|
||||
}
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: 'damageSelection',
|
||||
template: 'systems/daggerheart/templates/views/rollSelection.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
get title() {
|
||||
return `Roll Options`;
|
||||
}
|
||||
get title() {
|
||||
return `Roll Options`;
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.isNpc = this.isNpc;
|
||||
context.diceOptions = this.data.diceOptions;
|
||||
context.hope = this.data.hope;
|
||||
context.fear = this.data.fear;
|
||||
context.advantage = this.data.advantage;
|
||||
context.disadvantage = this.data.disadvantage;
|
||||
context.experiences = this.experiences.map(x => ({ ...x, selected: this.selectedExperiences.find(selected => selected.id === x.id) }));
|
||||
context.bonusDamage = this.data.bonusDamage;
|
||||
context.hopeResource = this.data.hopeResource+1;
|
||||
context.hopeUsed = this.getHopeUsed();
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.isNpc = this.isNpc;
|
||||
context.diceOptions = this.data.diceOptions;
|
||||
context.hope = this.data.hope;
|
||||
context.fear = this.data.fear;
|
||||
context.advantage = this.data.advantage;
|
||||
context.disadvantage = this.data.disadvantage;
|
||||
context.experiences = this.experiences.map(x => ({
|
||||
...x,
|
||||
selected: this.selectedExperiences.find(selected => selected.id === x.id)
|
||||
}));
|
||||
context.bonusDamage = this.data.bonusDamage;
|
||||
context.hopeResource = this.data.hopeResource + 1;
|
||||
context.hopeUsed = this.getHopeUsed();
|
||||
|
||||
return context;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
static updateSelection(event, _, formData){
|
||||
const { bonusDamage, ...rest } = foundry.utils.expandObject(formData.object);
|
||||
|
||||
for(var index in bonusDamage){
|
||||
this.data.bonusDamage[index].initiallySelected = bonusDamage[index].initiallySelected;
|
||||
if(bonusDamage[index].hopeUses){
|
||||
const value = Number.parseInt(bonusDamage[index].hopeUses);
|
||||
if(!Number.isNaN(value)) this.data.bonusDamage[index].hopeUses = value;
|
||||
static updateSelection(event, _, formData) {
|
||||
const { bonusDamage, ...rest } = foundry.utils.expandObject(formData.object);
|
||||
|
||||
for (var index in bonusDamage) {
|
||||
this.data.bonusDamage[index].initiallySelected = bonusDamage[index].initiallySelected;
|
||||
if (bonusDamage[index].hopeUses) {
|
||||
const value = Number.parseInt(bonusDamage[index].hopeUses);
|
||||
if (!Number.isNaN(value)) this.data.bonusDamage[index].hopeUses = value;
|
||||
}
|
||||
}
|
||||
|
||||
this.data = foundry.utils.mergeObject(this.data, rest);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static selectExperience(_, button) {
|
||||
if (this.selectedExperiences.find(x => x.id === button.dataset.key)) {
|
||||
this.selectedExperiences = this.selectedExperiences.filter(x => x.id !== button.dataset.key);
|
||||
} else {
|
||||
this.selectedExperiences = [
|
||||
...this.selectedExperiences,
|
||||
this.experiences.find(x => x.id === button.dataset.key)
|
||||
];
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
getHopeUsed() {
|
||||
return this.data.bonusDamage.reduce((acc, x) => acc + x.hopeUses, 0);
|
||||
}
|
||||
|
||||
static decreaseHopeUse(_, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
if (this.data.bonusDamage[index].hopeUses - 1 >= 0) {
|
||||
this.data.bonusDamage[index].hopeUses -= 1;
|
||||
this.render(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.data = foundry.utils.mergeObject(this.data, rest);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static selectExperience(_, button){
|
||||
if(this.selectedExperiences.find(x => x.id === button.dataset.key)){
|
||||
this.selectedExperiences = this.selectedExperiences.filter(x => x.id !== button.dataset.key);
|
||||
} else {
|
||||
this.selectedExperiences = [...this.selectedExperiences, this.experiences.find(x => x.id === button.dataset.key)];
|
||||
static increaseHopeUse(_, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
if (this.data.bonusDamage[index].hopeUses <= this.data.hopeResource + 1) {
|
||||
this.data.bonusDamage[index].hopeUses += 1;
|
||||
this.render(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
static setAdvantage() {
|
||||
this.data.advantage = this.data.advantage ? null : 'd6';
|
||||
this.data.disadvantage = null;
|
||||
|
||||
getHopeUsed(){
|
||||
return this.data.bonusDamage.reduce((acc, x) => acc+x.hopeUses, 0);
|
||||
}
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static decreaseHopeUse(_, button){
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
if(this.data.bonusDamage[index].hopeUses - 1 >= 0) {
|
||||
this.data.bonusDamage[index].hopeUses -= 1;
|
||||
this.render(true);
|
||||
}
|
||||
}
|
||||
static setDisadvantage() {
|
||||
this.data.advantage = null;
|
||||
this.data.disadvantage = this.data.disadvantage ? null : 'd6';
|
||||
|
||||
static increaseHopeUse(_, button){
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
if(this.data.bonusDamage[index].hopeUses <= this.data.hopeResource+1) {
|
||||
this.data.bonusDamage[index].hopeUses += 1;
|
||||
this.render(true);
|
||||
}
|
||||
}
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static setAdvantage(){
|
||||
this.data.advantage = this.data.advantage ? null : 'd6';
|
||||
this.data.disadvantage = null;
|
||||
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static setDisadvantage(){
|
||||
this.data.advantage = null;
|
||||
this.data.disadvantage = this.data.disadvantage ? null : 'd6';
|
||||
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async finish(){
|
||||
const { diceOptions, ...rest } = this.data;
|
||||
this.resolve({ ...rest, experiences: this.selectedExperiences, hopeUsed: this.getHopeUsed(), bonusDamage: this.data.bonusDamage.reduce((acc, x) => acc.concat(` + ${1+x.hopeUses}${x.value}`), "") });
|
||||
this.close();
|
||||
}
|
||||
static async finish() {
|
||||
const { diceOptions, ...rest } = this.data;
|
||||
this.resolve({
|
||||
...rest,
|
||||
experiences: this.selectedExperiences,
|
||||
hopeUsed: this.getHopeUsed(),
|
||||
bonusDamage: this.data.bonusDamage.reduce((acc, x) => acc.concat(` + ${1 + x.hopeUses}${x.value}`), '')
|
||||
});
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
// V1.3
|
||||
|
|
@ -194,7 +208,7 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
|
|||
// closeOnSubmit: false,
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
// /** @override */
|
||||
// static PARTS = {
|
||||
// damageSelection: {
|
||||
|
|
@ -225,7 +239,7 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
|
|||
|
||||
// static updateSelection(event, _, formData){
|
||||
// const { bonusDamage, ...rest } = foundry.utils.expandObject(formData.object);
|
||||
|
||||
|
||||
// for(var index in bonusDamage){
|
||||
// this.data.bonusDamage[index].initiallySelected = bonusDamage[index].initiallySelected;
|
||||
// if(bonusDamage[index].hopeUses){
|
||||
|
|
@ -273,4 +287,4 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
|
|||
// this.resolve({ ...rest, experiences: this.selectedExperiences, hopeUsed: this.getHopeUsed(), bonusDamage: this.data.bonusDamage.reduce((acc, x) => acc.concat(` + ${1+x.hopeUses}${x.value}`), "") });
|
||||
// this.close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
class DhpAutomationSettings extends FormApplication {
|
||||
constructor(object={}, options={}){
|
||||
constructor(object = {}, options = {}) {
|
||||
super(object, options);
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-automation-settings',
|
||||
template: 'systems/daggerheart/templates/views/automation-settings.hbs',
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
classes: ["daggerheart", "views", "settings"],
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-automation-settings',
|
||||
template: 'systems/daggerheart/templates/views/automation-settings.hbs',
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
classes: ['daggerheart', 'views', 'settings']
|
||||
};
|
||||
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData(){
|
||||
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.settings = SYSTEM.SETTINGS.gameSettings.Automation;
|
||||
context.hope = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope);
|
||||
|
|
@ -36,35 +36,35 @@ class DhpAutomationSettings extends FormApplication {
|
|||
async _updateObject(_, formData) {
|
||||
const data = foundry.utils.expandObject(formData);
|
||||
const updateSettingsKeys = Object.keys(data);
|
||||
for(var i = 0; i < updateSettingsKeys.length; i++){
|
||||
for (var i = 0; i < updateSettingsKeys.length; i++) {
|
||||
await game.settings.set(SYSTEM.id, updateSettingsKeys[i], data[updateSettingsKeys[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DhpHomebrewSettings extends FormApplication {
|
||||
constructor(object={}, options={}){
|
||||
constructor(object = {}, options = {}) {
|
||||
super(object, options);
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-homebrew-settings',
|
||||
template: 'systems/daggerheart/templates/views/homebrew-settings.hbs',
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
classes: ["daggerheart", "views", "settings"],
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-homebrew-settings',
|
||||
template: 'systems/daggerheart/templates/views/homebrew-settings.hbs',
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
classes: ['daggerheart', 'views', 'settings']
|
||||
};
|
||||
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData(){
|
||||
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.settings = SYSTEM.SETTINGS.gameSettings.General;
|
||||
context.abilityArray = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.AbilityArray);
|
||||
|
|
@ -79,14 +79,14 @@ class DhpHomebrewSettings extends FormApplication {
|
|||
async _updateObject(_, formData) {
|
||||
const data = foundry.utils.expandObject(formData);
|
||||
const updateSettingsKeys = Object.keys(data);
|
||||
for(var i = 0; i < updateSettingsKeys.length; i++){
|
||||
for (var i = 0; i < updateSettingsKeys.length; i++) {
|
||||
await game.settings.set(SYSTEM.id, updateSettingsKeys[i], data[updateSettingsKeys[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DhpRangeSettings extends FormApplication {
|
||||
constructor(object={}, options={}){
|
||||
constructor(object = {}, options = {}) {
|
||||
super(object, options);
|
||||
|
||||
this.range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement);
|
||||
|
|
@ -95,25 +95,33 @@ class DhpRangeSettings extends FormApplication {
|
|||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-range-settings',
|
||||
template: 'systems/daggerheart/templates/views/range-settings.hbs',
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true,
|
||||
classes: ["daggerheart", "views", "settings"],
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-range-settings',
|
||||
template: 'systems/daggerheart/templates/views/range-settings.hbs',
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true,
|
||||
classes: ['daggerheart', 'views', 'settings']
|
||||
};
|
||||
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData(){
|
||||
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.settings = SYSTEM.SETTINGS.gameSettings.General;
|
||||
context.range = this.range;
|
||||
context.disabled = context.range.enabled && [context.range.melee, context.range.veryClose, context.range.close, context.range.far, context.range.veryFar].some(x => x === null || x === false);
|
||||
context.disabled =
|
||||
context.range.enabled &&
|
||||
[
|
||||
context.range.melee,
|
||||
context.range.veryClose,
|
||||
context.range.close,
|
||||
context.range.far,
|
||||
context.range.veryFar
|
||||
].some(x => x === null || x === false);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
@ -121,9 +129,9 @@ class DhpRangeSettings extends FormApplication {
|
|||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
html.find(".range-reset").click(this.reset.bind(this));
|
||||
html.find(".save").click(this.save.bind(this));
|
||||
html.find(".close").click(this.close.bind(this));
|
||||
html.find('.range-reset').click(this.reset.bind(this));
|
||||
html.find('.save').click(this.save.bind(this));
|
||||
html.find('.close').click(this.close.bind(this));
|
||||
}
|
||||
|
||||
async _updateObject(_, formData) {
|
||||
|
|
@ -132,7 +140,7 @@ class DhpRangeSettings extends FormApplication {
|
|||
this.render(true);
|
||||
}
|
||||
|
||||
reset(){
|
||||
reset() {
|
||||
this.range = {
|
||||
enabled: false,
|
||||
melee: 5,
|
||||
|
|
@ -144,7 +152,7 @@ class DhpRangeSettings extends FormApplication {
|
|||
this.render(true);
|
||||
}
|
||||
|
||||
async save(){
|
||||
async save() {
|
||||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement, this.range);
|
||||
this.close();
|
||||
}
|
||||
|
|
@ -154,44 +162,44 @@ export const registerDHPSettings = () => {
|
|||
// const debouncedReload = foundry.utils.debounce(() => window.location.reload(), 100);
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.AbilityArray, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.General.AbilityArray.Name"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.General.AbilityArray.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.General.AbilityArray.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.General.AbilityArray.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: String,
|
||||
default: '[2,1,1,0,0,-1]',
|
||||
default: '[2,1,1,0,0,-1]'
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.Fear, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.Resources.Fear.Name"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.Resources.Fear.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Resources.Fear.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Resources.Fear.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Number,
|
||||
default: 0,
|
||||
default: 0
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.Automation.Hope.Name"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.Automation.Hope.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Automation.Hope.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Automation.Hope.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: false
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.ActionPoints, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.Automation.ActionPoints.Name"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.Automation.ActionPoints.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Automation.ActionPoints.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Automation.ActionPoints.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Boolean,
|
||||
default: true,
|
||||
default: true
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.General.RangeMeasurement.Name"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.General.RangeMeasurement.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.General.RangeMeasurement.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.General.RangeMeasurement.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Object,
|
||||
|
|
@ -202,35 +210,34 @@ export const registerDHPSettings = () => {
|
|||
close: 30,
|
||||
far: 60,
|
||||
veryFar: 120
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Automation.Name, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.Menu.Automation.Name"),
|
||||
label: game.i18n.localize("DAGGERHEART.Settings.Menu.Automation.Label"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.Menu.Automation.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Automation.Icon,
|
||||
type: DhpAutomationSettings,
|
||||
restricted: true
|
||||
});
|
||||
});
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Homebrew.Name, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.Menu.Homebrew.Name"),
|
||||
label: game.i18n.localize("DAGGERHEART.Settings.Menu.Homebrew.Label"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.Menu.Homebrew.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Homebrew.Icon,
|
||||
type: DhpHomebrewSettings,
|
||||
restricted: true
|
||||
});
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Range.Name, {
|
||||
name: game.i18n.localize("DAGGERHEART.Settings.Menu.Range.Name"),
|
||||
label: game.i18n.localize("DAGGERHEART.Settings.Menu.Range.Label"),
|
||||
hint: game.i18n.localize("DAGGERHEART.Settings.Menu.Range.Hint"),
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Range.Icon,
|
||||
type: DhpRangeSettings,
|
||||
restricted: true
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// const {HandlebarsApplicationMixin, ApplicationV2} = foundry.applications.api;
|
||||
|
||||
|
|
@ -246,7 +253,7 @@ export const registerDHPSettings = () => {
|
|||
// }
|
||||
|
||||
// get title(){
|
||||
// return game.i18n.localize("DAGGERHEART.Application.Settings.Title");
|
||||
// return game.i18n.localize("DAGGERHEART.Application.Settings.Title");
|
||||
// }
|
||||
|
||||
// static DEFAULT_OPTIONS = {
|
||||
|
|
@ -258,7 +265,7 @@ export const registerDHPSettings = () => {
|
|||
// },
|
||||
// form: { handler: this.updateData }
|
||||
// };
|
||||
|
||||
|
||||
// static PARTS = {
|
||||
// application: {
|
||||
// id: "settings",
|
||||
|
|
@ -279,4 +286,4 @@ export const registerDHPSettings = () => {
|
|||
// static close(){
|
||||
// super.close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
|
||||
|
||||
// export class Teest extends DhpApplicationMixin(ActorSheet) {
|
||||
|
|
@ -33,10 +32,10 @@
|
|||
// type: game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.object.system.type].name),
|
||||
// attack: {
|
||||
// name: this.object.system.attack.name,
|
||||
// attackModifier: this.object.system.attackModifier,
|
||||
// attackModifier: this.object.system.attackModifier,
|
||||
// range: this.object.system.attack.range ? game.i18n.localize(SYSTEM.GENERAL.range[this.object.system.attack.range].name) : null,
|
||||
// damage: {
|
||||
// value: this.object.system.attack.damage.value,
|
||||
// value: this.object.system.attack.damage.value,
|
||||
// type: this.object.system.attack.damage.type,
|
||||
// typeName: this.object.system.attack.damage.type ? game.i18n.localize(SYSTEM.GENERAL.damageTypes[this.object.system.attack.damage.type].abbreviation).toLowerCase() : null,
|
||||
// },
|
||||
|
|
@ -68,7 +67,7 @@
|
|||
// case 'addMotive':
|
||||
// await this.addMotive();
|
||||
// break;
|
||||
// case 'removeMotive':
|
||||
// case 'removeMotive':
|
||||
// await this.removeMotive(button);
|
||||
// break;
|
||||
// case 'reactionRoll':
|
||||
|
|
@ -138,7 +137,7 @@
|
|||
// content: "systems/daggerheart/templates/chat/adversary-roll.hbs",
|
||||
// rolls: [roll]
|
||||
// });
|
||||
|
||||
|
||||
// cls.create(msg.toObject());
|
||||
// }
|
||||
|
||||
|
|
@ -169,7 +168,7 @@
|
|||
// content: "systems/daggerheart/templates/chat/adversary-attack-roll.hbs",
|
||||
// rolls: [roll]
|
||||
// });
|
||||
|
||||
|
||||
// cls.create(msg.toObject());
|
||||
// }
|
||||
|
||||
|
|
@ -198,16 +197,16 @@ import DaggerheartSheet from './daggerheart-sheet.mjs';
|
|||
|
||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||
export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
||||
constructor(options={}){
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
|
||||
this.editMode = false;
|
||||
}
|
||||
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-adversary",
|
||||
classes: ["daggerheart", "sheet", "adversary"],
|
||||
id: 'daggerheart-adversary',
|
||||
classes: ['daggerheart', 'sheet', 'adversary'],
|
||||
position: { width: 600 },
|
||||
actions: {
|
||||
viewMove: this.viewMove,
|
||||
|
|
@ -221,21 +220,21 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
addExperience: this.addExperience,
|
||||
removeExperience: this.removeExperience,
|
||||
toggleHP: this.toggleHP,
|
||||
toggleStress: this.toggleStress,
|
||||
toggleStress: this.toggleStress
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/adversary.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/adversary.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -251,93 +250,119 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
type: game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.document.system.type].name),
|
||||
attack: {
|
||||
name: this.document.system.attack.name,
|
||||
attackModifier: this.document.system.attackModifier,
|
||||
range: this.document.system.attack.range ? game.i18n.localize(SYSTEM.GENERAL.range[this.document.system.attack.range].name) : null,
|
||||
attackModifier: this.document.system.attackModifier,
|
||||
range: this.document.system.attack.range
|
||||
? game.i18n.localize(SYSTEM.GENERAL.range[this.document.system.attack.range].name)
|
||||
: null,
|
||||
damage: {
|
||||
value: this.document.system.attack.damage.value,
|
||||
value: this.document.system.attack.damage.value,
|
||||
type: this.document.system.attack.damage.type,
|
||||
typeName: this.document.system.attack.damage.type ? game.i18n.localize(SYSTEM.GENERAL.damageTypes[this.document.system.attack.damage.type].abbreviation).toLowerCase() : null,
|
||||
},
|
||||
typeName: this.document.system.attack.damage.type
|
||||
? game.i18n
|
||||
.localize(
|
||||
SYSTEM.GENERAL.damageTypes[this.document.system.attack.damage.type].abbreviation
|
||||
)
|
||||
.toLowerCase()
|
||||
: null
|
||||
}
|
||||
},
|
||||
damageThresholds: this.document.system.damageThresholds,
|
||||
difficulty: this.document.system.difficulty,
|
||||
hp: { ...this.document.system.resources.health, lastRowIndex: Math.floor(this.document.system.resources.health.max/5)*5 },
|
||||
stress: { ...this.document.system.resources.stress, lastRowIndex: Math.floor(this.document.system.resources.stress.max/5)*5 },
|
||||
moves: this.document.system.moves,
|
||||
hp: {
|
||||
...this.document.system.resources.health,
|
||||
lastRowIndex: Math.floor(this.document.system.resources.health.max / 5) * 5
|
||||
},
|
||||
stress: {
|
||||
...this.document.system.resources.stress,
|
||||
lastRowIndex: Math.floor(this.document.system.resources.stress.max / 5) * 5
|
||||
},
|
||||
moves: this.document.system.moves
|
||||
};
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async viewMove(_, button){
|
||||
static async viewMove(_, button) {
|
||||
const move = await fromUuid(button.dataset.move);
|
||||
move.sheet.render(true);
|
||||
}
|
||||
|
||||
static async addMove(){
|
||||
const result = await this.document.createEmbeddedDocuments("Item", [{
|
||||
name: game.i18n.localize('DAGGERHEART.Sheets.Adversary.NewMove'),
|
||||
type: 'feature',
|
||||
}]);
|
||||
static async addMove() {
|
||||
const result = await this.document.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
name: game.i18n.localize('DAGGERHEART.Sheets.Adversary.NewMove'),
|
||||
type: 'feature'
|
||||
}
|
||||
]);
|
||||
|
||||
await result[0].sheet.render(true);
|
||||
}
|
||||
|
||||
static async removeMove(_, button){
|
||||
static async removeMove(_, button) {
|
||||
await this.document.items.find(x => x.uuid === button.dataset.move).delete();
|
||||
}
|
||||
|
||||
static toggleEditMode(){
|
||||
static toggleEditMode() {
|
||||
this.editMode = !this.editMode;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async addMotive(){
|
||||
await this.document.update({ "system.motivesAndTactics": [...this.document.system.motivesAndTactics, ''] });
|
||||
static async addMotive() {
|
||||
await this.document.update({ 'system.motivesAndTactics': [...this.document.system.motivesAndTactics, ''] });
|
||||
}
|
||||
|
||||
static async removeMotive(button){
|
||||
await this.document.update({ "system.motivesAndTactics": this.document.system.motivesAndTactics.filter((_, index) => index !== Number.parseInt(button.dataset.motive) )});
|
||||
static async removeMotive(button) {
|
||||
await this.document.update({
|
||||
'system.motivesAndTactics': this.document.system.motivesAndTactics.filter(
|
||||
(_, index) => index !== Number.parseInt(button.dataset.motive)
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
static async reactionRoll(event){
|
||||
const { roll, diceResults, modifiers } = await this.actor.diceRoll({ title: `${this.actor.name} - Reaction Roll`, value: 0 }, event.shiftKey);
|
||||
static async reactionRoll(event) {
|
||||
const { roll, diceResults, modifiers } = await this.actor.diceRoll(
|
||||
{ title: `${this.actor.name} - Reaction Roll`, value: 0 },
|
||||
event.shiftKey
|
||||
);
|
||||
|
||||
const cls = getDocumentClass("ChatMessage");
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = new cls({
|
||||
type: 'adversaryRoll',
|
||||
system: {
|
||||
roll: roll._formula,
|
||||
total: roll._total,
|
||||
modifiers: modifiers,
|
||||
diceResults: diceResults,
|
||||
diceResults: diceResults
|
||||
},
|
||||
content: "systems/daggerheart/templates/chat/adversary-roll.hbs",
|
||||
content: 'systems/daggerheart/templates/chat/adversary-roll.hbs',
|
||||
rolls: [roll]
|
||||
});
|
||||
|
||||
|
||||
cls.create(msg.toObject());
|
||||
}
|
||||
|
||||
static async attackRoll(event, button){
|
||||
static async attackRoll(event, button) {
|
||||
const modifier = Number.parseInt(button.dataset.value);
|
||||
|
||||
const { roll, diceResults, modifiers } = await this.actor.diceRoll({ title: `${this.actor.name} - Attack Roll`, value: modifier }, event.shiftKey);
|
||||
const { roll, diceResults, modifiers } = await this.actor.diceRoll(
|
||||
{ title: `${this.actor.name} - Attack Roll`, value: modifier },
|
||||
event.shiftKey
|
||||
);
|
||||
|
||||
const targets = Array.from(game.user.targets).map(x => ({
|
||||
id: x.id,
|
||||
name: x.actor.name,
|
||||
img: x.actor.img,
|
||||
difficulty: x.actor.system.difficulty,
|
||||
evasion: x.actor.system.evasion,
|
||||
evasion: x.actor.system.evasion
|
||||
}));
|
||||
|
||||
const cls = getDocumentClass("ChatMessage");
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = new cls({
|
||||
type: 'adversaryRoll',
|
||||
system: {
|
||||
|
|
@ -346,32 +371,38 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
modifiers: modifiers,
|
||||
diceResults: diceResults,
|
||||
targets: targets,
|
||||
damage: { value: button.dataset.damage, type: button.dataset.damageType },
|
||||
damage: { value: button.dataset.damage, type: button.dataset.damageType }
|
||||
},
|
||||
content: "systems/daggerheart/templates/chat/adversary-attack-roll.hbs",
|
||||
content: 'systems/daggerheart/templates/chat/adversary-attack-roll.hbs',
|
||||
rolls: [roll]
|
||||
});
|
||||
|
||||
|
||||
cls.create(msg.toObject());
|
||||
}
|
||||
|
||||
static async addExperience(){
|
||||
await this.document.update({ "system.experiences": [...this.document.system.experiences, { name: 'Experience', value: 1 }] });
|
||||
static async addExperience() {
|
||||
await this.document.update({
|
||||
'system.experiences': [...this.document.system.experiences, { name: 'Experience', value: 1 }]
|
||||
});
|
||||
}
|
||||
|
||||
static async removeExperience(_, button){
|
||||
await this.document.update({ "system.experiences": this.document.system.experiences.filter((_, index) => index !== Number.parseInt(button.dataset.experience) )});
|
||||
static async removeExperience(_, button) {
|
||||
await this.document.update({
|
||||
'system.experiences': this.document.system.experiences.filter(
|
||||
(_, index) => index !== Number.parseInt(button.dataset.experience)
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
static async toggleHP(_, button){
|
||||
static async toggleHP(_, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
const newHP = index < this.document.system.resources.health.value ? index : index+1;
|
||||
await this.document.update({ "system.resources.health.value": newHP });
|
||||
const newHP = index < this.document.system.resources.health.value ? index : index + 1;
|
||||
await this.document.update({ 'system.resources.health.value': newHP });
|
||||
}
|
||||
|
||||
static async toggleStress(_, button){
|
||||
static async toggleStress(_, button) {
|
||||
const index = Number.parseInt(button.dataset.index);
|
||||
const newStress = index < this.document.system.resources.stress.value ? index : index+1;
|
||||
await this.document.update({ "system.resources.stress.value": newStress });
|
||||
const newStress = index < this.document.system.resources.stress.value ? index : index + 1;
|
||||
await this.document.update({ 'system.resources.stress.value': newStress });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,12 @@
|
|||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// async _handleAction(action, event, button) {
|
||||
// switch(action){
|
||||
// case 'editAbility':
|
||||
// this.editAbility(button);
|
||||
// break;
|
||||
// case 'deleteAbility':
|
||||
// case 'deleteAbility':
|
||||
// this.deleteAbility(event);
|
||||
// break;
|
||||
// }
|
||||
|
|
@ -59,30 +58,30 @@
|
|||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class AncestrySheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
export default class AncestrySheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-ancestry",
|
||||
classes: ["daggerheart", "sheet", "heritage"],
|
||||
id: 'daggerheart-ancestry',
|
||||
classes: ['daggerheart', 'sheet', 'heritage'],
|
||||
position: { width: 600 },
|
||||
actions: {
|
||||
editAbility: this.editAbility,
|
||||
deleteAbility: this.deleteAbility,
|
||||
deleteAbility: this.deleteAbility
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }]
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/ancestry.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/ancestry.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -92,26 +91,33 @@ export default class AncestrySheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async editAbility(_, button){
|
||||
static async editAbility(_, button) {
|
||||
const feature = await fromUuid(button.dataset.ability);
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async deleteAbility(event, button){
|
||||
static async deleteAbility(event, button) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability) })
|
||||
await this.item.update({
|
||||
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability)
|
||||
});
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
if(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.ancestry.id) {
|
||||
await this.document.update({ "system.abilities": [...this.document.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.ancestry.id) {
|
||||
await this.document.update({
|
||||
'system.abilities': [
|
||||
...this.document.system.abilities,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// async _handleAction(action, event, button) {
|
||||
// switch(action){
|
||||
// }
|
||||
|
|
@ -29,26 +28,26 @@
|
|||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class ArmorSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
export default class ArmorSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-armor",
|
||||
classes: ["daggerheart", "sheet", "armor"],
|
||||
id: 'daggerheart-armor',
|
||||
classes: ['daggerheart', 'sheet', 'armor'],
|
||||
position: { width: 400 },
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }]
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/armor.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/armor.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -59,7 +58,7 @@ export default class ArmorSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,17 +40,17 @@
|
|||
// const domainTagify = new Tagify(domainInput, {
|
||||
// tagTextProp: "name",
|
||||
// enforceWhitelist: true,
|
||||
// whitelist : Object.keys(SYSTEM.DOMAIN.domains).map(key => {
|
||||
// whitelist : Object.keys(SYSTEM.DOMAIN.domains).map(key => {
|
||||
// const domain = SYSTEM.DOMAIN.domains[key];
|
||||
// return { value: key, name: game.i18n.localize(domain.name), src: domain.src, background: domain.background };
|
||||
// }),
|
||||
// maxTags: 2,
|
||||
// callbacks : { invalid: this.onAddTag },
|
||||
// callbacks : { invalid: this.onAddTag },
|
||||
// dropdown : {
|
||||
// mapValueTo: 'name',
|
||||
// searchKeys: ['name'],
|
||||
// enabled: 0,
|
||||
// maxItems: 20,
|
||||
// enabled: 0,
|
||||
// maxItems: 20,
|
||||
// closeOnSelect : true,
|
||||
// highlightFirst: false,
|
||||
// },
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
// spellcheck='false'
|
||||
// tabIndex="${this.settings.a11y.focusableTags ? 0 : -1}"
|
||||
// class="${this.settings.classNames.tag} ${tagData.class ? tagData.class : ""}"
|
||||
// ${this.getAttributes(tagData)}>
|
||||
// ${this.getAttributes(tagData)}>
|
||||
// <x class="${this.settings.classNames.tagX}" role='button' aria-label='remove tag'></x>
|
||||
// <div>
|
||||
// <span class="${this.settings.classNames.tagText}">${tagData[this.settings.tagTextProp] || tagData.value}</span>
|
||||
|
|
@ -70,16 +70,16 @@
|
|||
// </tag>`;
|
||||
// }}
|
||||
// });
|
||||
|
||||
|
||||
// domainTagify.on('change', this.onDomainSelect.bind(this));
|
||||
// }
|
||||
// }
|
||||
|
||||
// onAddTag(e){
|
||||
// if( e.detail.index ===2 ){
|
||||
// ui.notifications.info(game.i18n.localize("DAGGERHEART.Notification.Info.ClassCanOnlyHaveTwoDomains"));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// async onDomainSelect(event) {
|
||||
// const domains = event.detail?.value ? JSON.parse(event.detail.value) : [];
|
||||
// await this.object.update({ "system.domains": domains.map(x => x.value) });
|
||||
|
|
@ -170,7 +170,7 @@
|
|||
|
||||
// super._onDragStart(event);
|
||||
// }
|
||||
|
||||
|
||||
// async _onDrop(event) {
|
||||
// const data = TextEditor.getDragEventData(event);
|
||||
// const item = await fromUuid(data.uuid);
|
||||
|
|
@ -210,14 +210,14 @@
|
|||
// }
|
||||
|
||||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
import Tagify from "@yaireo/tagify";
|
||||
import Tagify from '@yaireo/tagify';
|
||||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-class",
|
||||
classes: ["daggerheart", "sheet", "class"],
|
||||
id: 'daggerheart-class',
|
||||
classes: ['daggerheart', 'sheet', 'class'],
|
||||
position: { width: 600 },
|
||||
actions: {
|
||||
removeSubclass: this.removeSubclass,
|
||||
|
|
@ -228,13 +228,12 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
viewItem: this.viewItem,
|
||||
removePrimaryWeapon: this.removePrimaryWeapon,
|
||||
removeSecondaryWeapon: this.removeSecondaryWeapon,
|
||||
removeArmor: this.removeArmor,
|
||||
|
||||
removeArmor: this.removeArmor
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
dragDrop: [
|
||||
{ dragSelector: '.suggested-item', dropSelector: null },
|
||||
|
|
@ -244,25 +243,39 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
{ dragSelector: null, dropSelector: '.primary-weapon-section' },
|
||||
{ dragSelector: null, dropSelector: '.secondary-weapon-section' },
|
||||
{ dragSelector: null, dropSelector: '.armor-section' },
|
||||
{ dragSelector: null, dropSelector: null },
|
||||
{ dragSelector: null, dropSelector: null }
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/class.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/class.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_getTabs() {
|
||||
const tabs = {
|
||||
features: { active: true, cssClass: '', group: 'primary', id: 'features', icon: null, label: game.i18n.localize('DAGGERHEART.Sheets.Class.Tabs.Features') },
|
||||
guide: { active: false, cssClass: '', group: 'primary', id: 'guide', icon: null, label: game.i18n.localize('DAGGERHEART.Sheets.Class.Tabs.Guide') },
|
||||
}
|
||||
for ( const v of Object.values(tabs) ) {
|
||||
features: {
|
||||
active: true,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'features',
|
||||
icon: null,
|
||||
label: game.i18n.localize('DAGGERHEART.Sheets.Class.Tabs.Features')
|
||||
},
|
||||
guide: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'guide',
|
||||
icon: null,
|
||||
label: game.i18n.localize('DAGGERHEART.Sheets.Class.Tabs.Guide')
|
||||
}
|
||||
};
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
|
||||
v.cssClass = v.active ? "active" : "";
|
||||
v.cssClass = v.active ? 'active' : '';
|
||||
}
|
||||
|
||||
return tabs;
|
||||
|
|
@ -270,32 +283,38 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
|
||||
const domainInput = htmlElement.querySelector('.domain-input');
|
||||
const domainTagify = new Tagify(domainInput, {
|
||||
tagTextProp: "name",
|
||||
enforceWhitelist: true,
|
||||
whitelist : Object.keys(SYSTEM.DOMAIN.domains).map(key => {
|
||||
const domain = SYSTEM.DOMAIN.domains[key];
|
||||
return { value: key, name: game.i18n.localize(domain.label), src: domain.src, background: domain.background };
|
||||
}),
|
||||
maxTags: 2,
|
||||
callbacks : { invalid: this.onAddTag },
|
||||
dropdown : {
|
||||
mapValueTo: 'name',
|
||||
searchKeys: ['name'],
|
||||
enabled: 0,
|
||||
maxItems: 20,
|
||||
closeOnSelect : true,
|
||||
highlightFirst: false,
|
||||
},
|
||||
templates: {
|
||||
tag(tagData){ //z-index: unset; background-image: ${tagData.background}; Maybe a domain specific background for the chips?
|
||||
return `<tag title="${(tagData.title || tagData.value)}"
|
||||
tagTextProp: 'name',
|
||||
enforceWhitelist: true,
|
||||
whitelist: Object.keys(SYSTEM.DOMAIN.domains).map(key => {
|
||||
const domain = SYSTEM.DOMAIN.domains[key];
|
||||
return {
|
||||
value: key,
|
||||
name: game.i18n.localize(domain.label),
|
||||
src: domain.src,
|
||||
background: domain.background
|
||||
};
|
||||
}),
|
||||
maxTags: 2,
|
||||
callbacks: { invalid: this.onAddTag },
|
||||
dropdown: {
|
||||
mapValueTo: 'name',
|
||||
searchKeys: ['name'],
|
||||
enabled: 0,
|
||||
maxItems: 20,
|
||||
closeOnSelect: true,
|
||||
highlightFirst: false
|
||||
},
|
||||
templates: {
|
||||
tag(tagData) {
|
||||
//z-index: unset; background-image: ${tagData.background}; Maybe a domain specific background for the chips?
|
||||
return `<tag title="${tagData.title || tagData.value}"
|
||||
contenteditable='false'
|
||||
spellcheck='false'
|
||||
tabIndex="${this.settings.a11y.focusableTags ? 0 : -1}"
|
||||
class="${this.settings.classNames.tag} ${tagData.class ? tagData.class : ""}"
|
||||
class="${this.settings.classNames.tag} ${tagData.class ? tagData.class : ''}"
|
||||
${this.getAttributes(tagData)}>
|
||||
<x class="${this.settings.classNames.tagX}" role='button' aria-label='remove tag'></x>
|
||||
<div>
|
||||
|
|
@ -303,11 +322,12 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
<img src="${tagData.src}"></i>
|
||||
</div>
|
||||
</tag>`;
|
||||
}}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
domainTagify.on('change', this.onDomainSelect.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -319,101 +339,145 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onAddTag(e){
|
||||
if( e.detail.index ===2 ){
|
||||
ui.notifications.info(game.i18n.localize("DAGGERHEART.Notification.Info.ClassCanOnlyHaveTwoDomains"));
|
||||
onAddTag(e) {
|
||||
if (e.detail.index === 2) {
|
||||
ui.notifications.info(game.i18n.localize('DAGGERHEART.Notification.Info.ClassCanOnlyHaveTwoDomains'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async onDomainSelect(event) {
|
||||
const domains = event.detail?.value ? JSON.parse(event.detail.value) : [];
|
||||
await this.document.update({ "system.domains": domains.map(x => x.value) });
|
||||
await this.document.update({ 'system.domains': domains.map(x => x.value) });
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async removeSubclass(_, button){
|
||||
await this.document.update({ "system.subclasses": this.document.system.subclasses.filter(x => x.uuid !== button.dataset.subclass)});
|
||||
static async removeSubclass(_, button) {
|
||||
await this.document.update({
|
||||
'system.subclasses': this.document.system.subclasses.filter(x => x.uuid !== button.dataset.subclass)
|
||||
});
|
||||
}
|
||||
|
||||
static async viewSubclass(_, button){
|
||||
static async viewSubclass(_, button) {
|
||||
const subclass = await fromUuid(button.dataset.subclass);
|
||||
subclass.sheet.render(true);
|
||||
}
|
||||
|
||||
static async removeFeature(_, button){
|
||||
await this.document.update({ "system.features": this.document.system.features.filter(x => x.uuid !== button.dataset.feature)});
|
||||
static async removeFeature(_, button) {
|
||||
await this.document.update({
|
||||
'system.features': this.document.system.features.filter(x => x.uuid !== button.dataset.feature)
|
||||
});
|
||||
}
|
||||
|
||||
static async viewFeature(_, button){
|
||||
static async viewFeature(_, button) {
|
||||
const feature = await fromUuid(button.dataset.feature);
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async removeItem(event, button){
|
||||
static async removeItem(event, button) {
|
||||
event.stopPropagation();
|
||||
const type = button.dataset.type;
|
||||
const path = `system.inventory.${type}`;
|
||||
await this.document.update({ [path]: this.document.system.inventory[type].filter(x => x.uuid !== button.dataset.item)});
|
||||
await this.document.update({
|
||||
[path]: this.document.system.inventory[type].filter(x => x.uuid !== button.dataset.item)
|
||||
});
|
||||
}
|
||||
|
||||
static async viewItem(_, button){
|
||||
static async viewItem(_, button) {
|
||||
const item = await fromUuid(button.dataset.item);
|
||||
item.sheet.render(true);
|
||||
}
|
||||
|
||||
static async removePrimaryWeapon(event){
|
||||
static async removePrimaryWeapon(event) {
|
||||
event.stopPropagation();
|
||||
await this.document.update({ "system.characterGuide.suggestedPrimaryWeapon": null }, { diff: false });
|
||||
await this.document.update({ 'system.characterGuide.suggestedPrimaryWeapon': null }, { diff: false });
|
||||
}
|
||||
|
||||
static async removeSecondaryWeapon(event){
|
||||
static async removeSecondaryWeapon(event) {
|
||||
event.stopPropagation();
|
||||
await this.document.update({ "system.characterGuide.suggestedSecondaryWeapon": null }, { diff: false });
|
||||
await this.document.update({ 'system.characterGuide.suggestedSecondaryWeapon': null }, { diff: false });
|
||||
}
|
||||
|
||||
static async removeArmor(event){
|
||||
static async removeArmor(event) {
|
||||
event.stopPropagation();
|
||||
await this.document.update({ "system.characterGuide.suggestedArmor": null }, { diff: false });
|
||||
await this.document.update({ 'system.characterGuide.suggestedArmor': null }, { diff: false });
|
||||
}
|
||||
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
if(item.type === 'subclass') {
|
||||
await this.document.update({ "system.subclasses": [...this.document.system.subclasses, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
}
|
||||
else if(item.type === 'feature') {
|
||||
|
||||
await this.document.update({ "system.features": [...this.document.system.features, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
}
|
||||
else if(item.type === 'weapon'){
|
||||
if(event.currentTarget.classList.contains('primary-weapon-section')){
|
||||
if(!this.document.system.characterGuide.suggestedPrimaryWeapon && !item.system.secondary) await this.document.update({ "system.characterGuide.suggestedPrimaryWeapon": { img: item.img, name: item.name, uuid: item.uuid } });
|
||||
} else if(event.currentTarget.classList.contains('secondary-weapon-section')){
|
||||
if(!this.document.system.characterGuide.suggestedSecondaryWeapon && item.system.secondary) await this.document.update({ "system.characterGuide.suggestedSecondaryWeapon": { img: item.img, name: item.name, uuid: item.uuid } });
|
||||
if (item.type === 'subclass') {
|
||||
await this.document.update({
|
||||
'system.subclasses': [
|
||||
...this.document.system.subclasses,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
} else if (item.type === 'feature') {
|
||||
await this.document.update({
|
||||
'system.features': [
|
||||
...this.document.system.features,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
} else if (item.type === 'weapon') {
|
||||
if (event.currentTarget.classList.contains('primary-weapon-section')) {
|
||||
if (!this.document.system.characterGuide.suggestedPrimaryWeapon && !item.system.secondary)
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedPrimaryWeapon': {
|
||||
img: item.img,
|
||||
name: item.name,
|
||||
uuid: item.uuid
|
||||
}
|
||||
});
|
||||
} else if (event.currentTarget.classList.contains('secondary-weapon-section')) {
|
||||
if (!this.document.system.characterGuide.suggestedSecondaryWeapon && item.system.secondary)
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedSecondaryWeapon': {
|
||||
img: item.img,
|
||||
name: item.name,
|
||||
uuid: item.uuid
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(item.type === 'armor'){
|
||||
if(event.currentTarget.classList.contains('armor-section')){
|
||||
if(!this.document.system.characterGuide.suggestedArmor) await this.document.update({ "system.characterGuide.suggestedArmor": { img: item.img, name: item.name, uuid: item.uuid } });
|
||||
} else if (item.type === 'armor') {
|
||||
if (event.currentTarget.classList.contains('armor-section')) {
|
||||
if (!this.document.system.characterGuide.suggestedArmor)
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedArmor': { img: item.img, name: item.name, uuid: item.uuid }
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(event.currentTarget.classList.contains('choice-a-section')){
|
||||
if(item.type === 'miscellaneous' || item.type === 'consumable'){
|
||||
if(this.document.system.inventory.choiceA.length < 2) await this.document.update({ "system.inventory.choiceA": [...this.document.system.inventory.choiceA, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
} else if (event.currentTarget.classList.contains('choice-a-section')) {
|
||||
if (item.type === 'miscellaneous' || item.type === 'consumable') {
|
||||
if (this.document.system.inventory.choiceA.length < 2)
|
||||
await this.document.update({
|
||||
'system.inventory.choiceA': [
|
||||
...this.document.system.inventory.choiceA,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(item.type === 'miscellaneous'){
|
||||
if(event.currentTarget.classList.contains('take-section')){
|
||||
if(this.document.system.inventory.take.length < 3) await this.document.update({ "system.inventory.take": [...this.document.system.inventory.take, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
}
|
||||
else if(event.currentTarget.classList.contains('choice-b-section')){
|
||||
if(this.document.system.inventory.choiceB.length < 2) await this.document.update({ "system.inventory.choiceB": [...this.document.system.inventory.choiceB, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
} else if (item.type === 'miscellaneous') {
|
||||
if (event.currentTarget.classList.contains('take-section')) {
|
||||
if (this.document.system.inventory.take.length < 3)
|
||||
await this.document.update({
|
||||
'system.inventory.take': [
|
||||
...this.document.system.inventory.take,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
} else if (event.currentTarget.classList.contains('choice-b-section')) {
|
||||
if (this.document.system.inventory.choiceB.length < 2)
|
||||
await this.document.update({
|
||||
'system.inventory.choiceB': [
|
||||
...this.document.system.inventory.choiceB,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,12 @@
|
|||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// async _handleAction(action, event, button) {
|
||||
// switch(action){
|
||||
// case 'editAbility':
|
||||
// this.editAbility(button);
|
||||
// break;
|
||||
// case 'deleteAbility':
|
||||
// case 'deleteAbility':
|
||||
// this.deleteAbility(event);
|
||||
// break;
|
||||
// }
|
||||
|
|
@ -59,30 +58,30 @@
|
|||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-community",
|
||||
classes: ["daggerheart", "sheet", "heritage"],
|
||||
id: 'daggerheart-community',
|
||||
classes: ['daggerheart', 'sheet', 'heritage'],
|
||||
position: { width: 600 },
|
||||
actions: {
|
||||
editAbility: this.editAbility,
|
||||
deleteAbility: this.deleteAbility,
|
||||
deleteAbility: this.deleteAbility
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }]
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/community.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/community.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -92,26 +91,33 @@ export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async editAbility(_, button){
|
||||
static async editAbility(_, button) {
|
||||
const feature = await fromUuid(button.dataset.ability);
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async deleteAbility(event, button){
|
||||
static async deleteAbility(event, button) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability) })
|
||||
await this.item.update({
|
||||
'system.abilities': this.item.system.abilities.filter(x => x.uuid !== button.dataset.ability)
|
||||
});
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
if(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
|
||||
await this.document.update({ "system.abilities": [...this.document.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
|
||||
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.community.id) {
|
||||
await this.document.update({
|
||||
'system.abilities': [
|
||||
...this.document.system.abilities,
|
||||
{ img: item.img, name: item.name, uuid: item.uuid }
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,25 +23,25 @@
|
|||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class ConsumableSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
export default class ConsumableSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-consumable",
|
||||
classes: ["daggerheart", "sheet", "consumable"],
|
||||
id: 'daggerheart-consumable',
|
||||
classes: ['daggerheart', 'sheet', 'consumable'],
|
||||
position: { width: 480 },
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/consumable.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/consumable.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -51,7 +51,7 @@ export default class ConsumableSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +1,73 @@
|
|||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default function DhpApplicationMixin(Base) {
|
||||
return class DhpSheetV2 extends HandlebarsApplicationMixin(Base) {
|
||||
constructor(options={}){
|
||||
super(options);
|
||||
return class DhpSheetV2 extends HandlebarsApplicationMixin(Base) {
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
|
||||
this._dragDrop = this._createDragDropHandlers();
|
||||
}
|
||||
this._dragDrop = this._createDragDropHandlers();
|
||||
}
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
this._dragDrop.forEach(d => d.bind(htmlElement));
|
||||
}
|
||||
this._dragDrop.forEach(d => d.bind(htmlElement));
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
position: {
|
||||
width: 480,
|
||||
height: "auto"
|
||||
},
|
||||
actions: {
|
||||
onEditImage: this._onEditImage
|
||||
},
|
||||
dragDrop: [],
|
||||
};
|
||||
|
||||
async _prepareContext(_options, objectPath='document') {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.source = this[objectPath].toObject();
|
||||
context.fields = this[objectPath].schema.fields;
|
||||
context.systemFields = this[objectPath].system ? this[objectPath].system.schema.fields : {};
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static _onEditImage(event, target) {
|
||||
const attr = target.dataset.edit;
|
||||
const current = foundry.utils.getProperty(this.document, attr);
|
||||
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {};
|
||||
const fp = new FilePicker({
|
||||
current,
|
||||
type: "image",
|
||||
redirectToRoot: img ? [img] : [],
|
||||
callback: async path => this._updateImage.bind(this)(path),
|
||||
top: this.position.top + 40,
|
||||
left: this.position.left + 10
|
||||
});
|
||||
return fp.browse();
|
||||
}
|
||||
|
||||
async _updateImage(path){
|
||||
await this.document.update({ "img": path });
|
||||
}
|
||||
|
||||
_createDragDropHandlers() {
|
||||
return this.options.dragDrop.map(d => {
|
||||
// d.permissions = {
|
||||
// dragstart: this._canDragStart.bind(this),
|
||||
// drop: this._canDragDrop.bind(this)
|
||||
// };
|
||||
d.callbacks = {
|
||||
// dragstart: this._onDragStart.bind(this),
|
||||
// dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this)
|
||||
static DEFAULT_OPTIONS = {
|
||||
position: {
|
||||
width: 480,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
onEditImage: this._onEditImage
|
||||
},
|
||||
dragDrop: []
|
||||
};
|
||||
return new foundry.applications.ux.DragDrop.implementation(d);
|
||||
});
|
||||
}
|
||||
|
||||
_onDrop(event) {}
|
||||
}
|
||||
}
|
||||
async _prepareContext(_options, objectPath = 'document') {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.source = this[objectPath].toObject();
|
||||
context.fields = this[objectPath].schema.fields;
|
||||
context.systemFields = this[objectPath].system ? this[objectPath].system.schema.fields : {};
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static _onEditImage(event, target) {
|
||||
const attr = target.dataset.edit;
|
||||
const current = foundry.utils.getProperty(this.document, attr);
|
||||
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {};
|
||||
const fp = new FilePicker({
|
||||
current,
|
||||
type: 'image',
|
||||
redirectToRoot: img ? [img] : [],
|
||||
callback: async path => this._updateImage.bind(this)(path),
|
||||
top: this.position.top + 40,
|
||||
left: this.position.left + 10
|
||||
});
|
||||
return fp.browse();
|
||||
}
|
||||
|
||||
async _updateImage(path) {
|
||||
await this.document.update({ img: path });
|
||||
}
|
||||
|
||||
_createDragDropHandlers() {
|
||||
return this.options.dragDrop.map(d => {
|
||||
// d.permissions = {
|
||||
// dragstart: this._canDragStart.bind(this),
|
||||
// drop: this._canDragDrop.bind(this)
|
||||
// };
|
||||
d.callbacks = {
|
||||
// dragstart: this._onDragStart.bind(this),
|
||||
// dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this)
|
||||
};
|
||||
return new foundry.applications.ux.DragDrop.implementation(d);
|
||||
});
|
||||
}
|
||||
|
||||
_onDrop(event) {}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// async _handleAction(action, event, button) {
|
||||
// switch(action){
|
||||
// case 'attributeRoll':
|
||||
|
|
@ -39,36 +38,36 @@ const { ItemSheetV2 } = foundry.applications.sheets;
|
|||
export default class DomainCardSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-domainCard",
|
||||
classes: ["daggerheart", "sheet", "domain-card"],
|
||||
id: 'daggerheart-domainCard',
|
||||
classes: ['daggerheart', 'sheet', 'domain-card'],
|
||||
position: { width: 600, height: 600 },
|
||||
actions: {
|
||||
addAction: this.addAction,
|
||||
editAction: this.editAction,
|
||||
removeAction: this.removeAction,
|
||||
removeAction: this.removeAction
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/domainCard.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/domainCard.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_getTabs() {
|
||||
const tabs = {
|
||||
general: { active: true, cssClass: '', group: 'primary', id: 'general', icon: null, label: 'General' },
|
||||
actions: { active: false, cssClass: '', group: 'primary', id: 'actions', icon: null, label: 'Actions' },
|
||||
}
|
||||
for ( const v of Object.values(tabs) ) {
|
||||
actions: { active: false, cssClass: '', group: 'primary', id: 'actions', icon: null, label: 'Actions' }
|
||||
};
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
|
||||
v.cssClass = v.active ? "active" : "";
|
||||
v.cssClass = v.active ? 'active' : '';
|
||||
}
|
||||
|
||||
return tabs;
|
||||
|
|
@ -83,28 +82,37 @@ export default class DomainCardSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async addAction(){
|
||||
const actionIndexes = this.document.system.actions.map(x => x.id.split('-')[2]).sort((a, b) => a-b);
|
||||
const action = await new DaggerheartAction({
|
||||
id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0]+1 : 1}`,
|
||||
}, {
|
||||
parent: this.document,
|
||||
});
|
||||
await this.document.update({ "system.actions": [...this.document.system.actions, action] });
|
||||
await (new DaggerheartActionConfig(this.document.system.actions[this.document.system.actions.length-1])).render(true);
|
||||
static async addAction() {
|
||||
const actionIndexes = this.document.system.actions.map(x => x.id.split('-')[2]).sort((a, b) => a - b);
|
||||
const action = await new DaggerheartAction(
|
||||
{
|
||||
id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0] + 1 : 1}`
|
||||
},
|
||||
{
|
||||
parent: this.document
|
||||
}
|
||||
);
|
||||
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||
await new DaggerheartActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
static async editAction(_, button){
|
||||
static async editAction(_, button) {
|
||||
const action = this.document.system.actions[button.dataset.index];
|
||||
await (new DaggerheartActionConfig(action)).render(true);
|
||||
await new DaggerheartActionConfig(action).render(true);
|
||||
}
|
||||
|
||||
static async removeAction(event, button){
|
||||
static async removeAction(event, button) {
|
||||
event.stopPropagation();
|
||||
await this.document.update({ "system.actions": this.document.system.actions.filter((_, index) => index !== Number.parseInt(button.dataset.index)) });
|
||||
await this.document.update({
|
||||
'system.actions': this.document.system.actions.filter(
|
||||
(_, index) => index !== Number.parseInt(button.dataset.index)
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import DaggerheartSheet from "./daggerheart-sheet.mjs";
|
||||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
|
||||
const { DocumentSheetV2 } = foundry.applications.api;
|
||||
export default class DhpEnvironment extends DaggerheartSheet(DocumentSheetV2) {
|
||||
|
||||
constructor(options){
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.editMode = false;
|
||||
|
|
@ -11,10 +10,10 @@ export default class DhpEnvironment extends DaggerheartSheet(DocumentSheetV2) {
|
|||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ["daggerheart", "sheet", "adversary", "environment"],
|
||||
classes: ['daggerheart', 'sheet', 'adversary', 'environment'],
|
||||
position: {
|
||||
width: 600,
|
||||
height: "auto"
|
||||
width: 600,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
toggleSlider: this.toggleSlider,
|
||||
|
|
@ -23,22 +22,22 @@ export default class DhpEnvironment extends DaggerheartSheet(DocumentSheetV2) {
|
|||
removeFeature: this.removeFeature,
|
||||
addTone: this.addTone,
|
||||
removeTone: this.removeTone,
|
||||
useFeature: this.useFeature,
|
||||
useFeature: this.useFeature
|
||||
},
|
||||
form: {
|
||||
handler: this._updateForm,
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true,
|
||||
handler: this._updateForm,
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "form",
|
||||
template: "systems/daggerheart/templates/sheets/environment.hbs"
|
||||
id: 'form',
|
||||
template: 'systems/daggerheart/templates/sheets/environment.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
|
@ -49,81 +48,87 @@ export default class DhpEnvironment extends DaggerheartSheet(DocumentSheetV2) {
|
|||
|
||||
async _prepareContext(_options) {
|
||||
return {
|
||||
title: `${this.document.name} - ${game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.document.system.type].name)}`,
|
||||
user: this.document,
|
||||
source: this.document.toObject(),
|
||||
fields: this.document.schema.fields,
|
||||
data: {
|
||||
type: game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.document.system.type].name),
|
||||
features: this.document.items.reduce((acc, x) => {
|
||||
if(x.type === 'feature'){
|
||||
const feature = x.toObject();
|
||||
acc.push({
|
||||
...feature,
|
||||
system: {
|
||||
...feature.system,
|
||||
actionType: game.i18n.localize(SYSTEM.ITEM.actionTypes[feature.system.actionType].name)
|
||||
},
|
||||
uuid: x.uuid
|
||||
});
|
||||
}
|
||||
title: `${this.document.name} - ${game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.document.system.type].name)}`,
|
||||
user: this.document,
|
||||
source: this.document.toObject(),
|
||||
fields: this.document.schema.fields,
|
||||
data: {
|
||||
type: game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.document.system.type].name),
|
||||
features: this.document.items.reduce((acc, x) => {
|
||||
if (x.type === 'feature') {
|
||||
const feature = x.toObject();
|
||||
acc.push({
|
||||
...feature,
|
||||
system: {
|
||||
...feature.system,
|
||||
actionType: game.i18n.localize(SYSTEM.ITEM.actionTypes[feature.system.actionType].name)
|
||||
},
|
||||
uuid: x.uuid
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
},
|
||||
editMode: this.editMode,
|
||||
config: SYSTEM,
|
||||
}
|
||||
return acc;
|
||||
}, [])
|
||||
},
|
||||
editMode: this.editMode,
|
||||
config: SYSTEM
|
||||
};
|
||||
}
|
||||
|
||||
static async _updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static toggleSlider(){
|
||||
static toggleSlider() {
|
||||
this.editMode = !this.editMode;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async viewFeature(_, button){
|
||||
static async viewFeature(_, button) {
|
||||
const move = await fromUuid(button.dataset.feature);
|
||||
move.sheet.render(true);
|
||||
}
|
||||
|
||||
static async addFeature(){
|
||||
const result = await this.document.createEmbeddedDocuments("Item", [{
|
||||
name: game.i18n.localize('DAGGERHEART.Sheets.Environment.NewFeature'),
|
||||
type: 'feature',
|
||||
}]);
|
||||
static async addFeature() {
|
||||
const result = await this.document.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
name: game.i18n.localize('DAGGERHEART.Sheets.Environment.NewFeature'),
|
||||
type: 'feature'
|
||||
}
|
||||
]);
|
||||
|
||||
await result[0].sheet.render(true);
|
||||
}
|
||||
|
||||
static async removeFeature(_, button){
|
||||
static async removeFeature(_, button) {
|
||||
await this.document.items.find(x => x.uuid === button.dataset.feature).delete();
|
||||
}
|
||||
|
||||
static async addTone(){
|
||||
await this.document.update({ "system.toneAndFeel": [...this.document.system.toneAndFeel, ''] });
|
||||
static async addTone() {
|
||||
await this.document.update({ 'system.toneAndFeel': [...this.document.system.toneAndFeel, ''] });
|
||||
}
|
||||
|
||||
static async removeTone(button){
|
||||
await this.document.update({ "system.toneAndFeel": this.document.system.toneAndFeel.filter((_, index) => index !== Number.parseInt(button.dataset.tone) )});
|
||||
static async removeTone(button) {
|
||||
await this.document.update({
|
||||
'system.toneAndFeel': this.document.system.toneAndFeel.filter(
|
||||
(_, index) => index !== Number.parseInt(button.dataset.tone)
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
static async useFeature(_, button){
|
||||
static async useFeature(_, button) {
|
||||
const item = this.document.items.find(x => x.uuid === button.dataset.feature);
|
||||
|
||||
const cls = getDocumentClass("ChatMessage");
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = new cls({
|
||||
user: game.user.id,
|
||||
content: await renderTemplate("systems/daggerheart/templates/chat/ability-use.hbs", {
|
||||
title: game.i18n.format("DAGGERHEART.Chat.EnvironmentTitle", { actionType: button.dataset.actionType }),
|
||||
card: { name: item.name, img: item.img, description: item.system.description },
|
||||
}),
|
||||
content: await renderTemplate('systems/daggerheart/templates/chat/ability-use.hbs', {
|
||||
title: game.i18n.format('DAGGERHEART.Chat.EnvironmentTitle', { actionType: button.dataset.actionType }),
|
||||
card: { name: item.name, img: item.img, description: item.system.description }
|
||||
})
|
||||
});
|
||||
|
||||
cls.create(msg.toObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,47 +4,47 @@ import DaggerheartSheet from './daggerheart-sheet.mjs';
|
|||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
constructor(options={}){
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
|
||||
this.selectedEffectType = null;
|
||||
}
|
||||
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-feature",
|
||||
classes: ["daggerheart", "sheet", "feature"],
|
||||
id: 'daggerheart-feature',
|
||||
classes: ['daggerheart', 'sheet', 'feature'],
|
||||
position: { width: 600, height: 600 },
|
||||
actions: {
|
||||
addEffect: this.addEffect,
|
||||
removeEffect: this.removeEffect,
|
||||
addAction: this.addAction,
|
||||
editAction: this.editAction,
|
||||
removeAction: this.removeAction,
|
||||
removeAction: this.removeAction
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/feature.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/feature.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_getTabs() {
|
||||
const tabs = {
|
||||
features: { active: true, cssClass: '', group: 'primary', id: 'features', icon: null, label: 'Features' },
|
||||
effects: { active: false, cssClass: '', group: 'primary', id: 'effects', icon: null, label: 'Effects' },
|
||||
actions: { active: false, cssClass: '', group: 'primary', id: 'actions', icon: null, label: 'Actions' },
|
||||
}
|
||||
for ( const v of Object.values(tabs) ) {
|
||||
actions: { active: false, cssClass: '', group: 'primary', id: 'actions', icon: null, label: 'Actions' }
|
||||
};
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
|
||||
v.cssClass = v.active ? "active" : "";
|
||||
v.cssClass = v.active ? 'active' : '';
|
||||
}
|
||||
|
||||
return tabs;
|
||||
|
|
@ -52,14 +52,13 @@ export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
$(htmlElement).find(".effect-select").on("change", this.effectSelect.bind(this));
|
||||
$(htmlElement).find('.effect-select').on('change', this.effectSelect.bind(this));
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.document = this.document;
|
||||
context.tabs = this._getTabs(),
|
||||
context.generalConfig = SYSTEM.GENERAL;
|
||||
(context.tabs = this._getTabs()), (context.generalConfig = SYSTEM.GENERAL);
|
||||
context.itemConfig = SYSTEM.ITEM;
|
||||
context.properties = SYSTEM.ACTOR.featureProperties;
|
||||
context.dice = SYSTEM.GENERAL.diceTypes;
|
||||
|
|
@ -70,47 +69,53 @@ export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
effectSelect(event){
|
||||
effectSelect(event) {
|
||||
this.selectedEffectType = event.currentTarget.value;
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async addEffect(){
|
||||
if(!this.selectedEffectType) return;
|
||||
|
||||
static async addEffect() {
|
||||
if (!this.selectedEffectType) return;
|
||||
|
||||
const { id, name, ...rest } = SYSTEM.EFFECTS.effectTypes[this.selectedEffectType];
|
||||
const update = {
|
||||
const update = {
|
||||
[foundry.utils.randomID()]: {
|
||||
type: this.selectedEffectType,
|
||||
value: '',
|
||||
...rest
|
||||
}
|
||||
}
|
||||
};
|
||||
await this.item.update({ "system.effects": update });
|
||||
await this.item.update({ 'system.effects': update });
|
||||
}
|
||||
|
||||
static async removeEffect(_, button){
|
||||
static async removeEffect(_, button) {
|
||||
const path = `system.effects.-=${button.dataset.effect}`;
|
||||
await this.item.update({ [path]: null });
|
||||
}
|
||||
|
||||
static async addAction(){
|
||||
const action = await new DaggerheartAction({}, {parent: this.document});
|
||||
await this.document.update({ "system.actions": [...this.document.system.actions, action] });
|
||||
await (new DaggerheartActionConfig(this.document.system.actions[this.document.system.actions.length-1])).render(true);
|
||||
static async addAction() {
|
||||
const action = await new DaggerheartAction({}, { parent: this.document });
|
||||
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||
await new DaggerheartActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
static async editAction(_, button){
|
||||
static async editAction(_, button) {
|
||||
const action = this.document.system.actions[button.dataset.index];
|
||||
await (new DaggerheartActionConfig(action)).render(true);
|
||||
await new DaggerheartActionConfig(action).render(true);
|
||||
}
|
||||
|
||||
static async removeAction(event, button){
|
||||
static async removeAction(event, button) {
|
||||
event.stopPropagation();
|
||||
await this.document.update({ "system.actions": this.document.system.actions.filter((_, index) => index !== Number.parseInt(button.dataset.index)) });
|
||||
await this.document.update({
|
||||
'system.actions': this.document.system.actions.filter(
|
||||
(_, index) => index !== Number.parseInt(button.dataset.index)
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,22 +26,22 @@ const { ItemSheetV2 } = foundry.applications.sheets;
|
|||
export default class MiscellaneousSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-miscellaneous",
|
||||
classes: ["daggerheart", "sheet", "miscellaneous"],
|
||||
id: 'daggerheart-miscellaneous',
|
||||
classes: ['daggerheart', 'sheet', 'miscellaneous'],
|
||||
position: { width: 400 },
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/miscellaneous.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/miscellaneous.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -51,7 +51,7 @@ export default class MiscellaneousSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -51,7 +51,7 @@
|
|||
// const feature = event.currentTarget.dataset.feature;
|
||||
// const newAbilities = this.item.system[`${feature}Feature`].abilities.filter(x => x.uuid !== event.currentTarget.dataset.ability);
|
||||
// const path = `system.${feature}Feature.abilities`;
|
||||
|
||||
|
||||
// await this.item.update({ [path]: newAbilities });
|
||||
// }
|
||||
|
||||
|
|
@ -79,46 +79,74 @@ const { ItemSheetV2 } = foundry.applications.sheets;
|
|||
export default class SubclassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-subclass",
|
||||
classes: ["daggerheart", "sheet", "subclass"],
|
||||
id: 'daggerheart-subclass',
|
||||
classes: ['daggerheart', 'sheet', 'subclass'],
|
||||
position: { width: 600 },
|
||||
actions: {
|
||||
editAbility: this.editAbility,
|
||||
deleteFeatureAbility: this.deleteFeatureAbility,
|
||||
deleteFeatureAbility: this.deleteFeatureAbility
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
dragDrop: [
|
||||
{ dragSelector: null, dropSelector: '.foundation-tab' },
|
||||
{ dragSelector: null, dropSelector: '.specialization-tab' },
|
||||
{ dragSelector: null, dropSelector: '.mastery-tab' }
|
||||
],
|
||||
]
|
||||
};
|
||||
|
||||
_getTabs() {
|
||||
const tabs = {
|
||||
general: { active: true, cssClass: '', group: 'primary', id: 'general', icon: null, label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.General') },
|
||||
foundation: { active: false, cssClass: '', group: 'primary', id: 'foundation', icon: null, label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.Foundation') },
|
||||
specialization: { active: false, cssClass: '', group: 'primary', id: 'specialization', icon: null, label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.Specialization') },
|
||||
mastery: { active: false, cssClass: '', group: 'primary', id: 'mastery', icon: null, label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.Mastery') },
|
||||
}
|
||||
for ( const v of Object.values(tabs) ) {
|
||||
general: {
|
||||
active: true,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'general',
|
||||
icon: null,
|
||||
label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.General')
|
||||
},
|
||||
foundation: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'foundation',
|
||||
icon: null,
|
||||
label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.Foundation')
|
||||
},
|
||||
specialization: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'specialization',
|
||||
icon: null,
|
||||
label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.Specialization')
|
||||
},
|
||||
mastery: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'mastery',
|
||||
icon: null,
|
||||
label: game.i18n.localize('DAGGERHEART.Sheets.Subclass.Tabs.Mastery')
|
||||
}
|
||||
};
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
|
||||
v.cssClass = v.active ? "active" : "";
|
||||
v.cssClass = v.active ? 'active' : '';
|
||||
}
|
||||
|
||||
return tabs;
|
||||
}
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/subclass.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/subclass.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -130,39 +158,51 @@ export default class SubclassSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async editAbility(_, button){
|
||||
static async editAbility(_, button) {
|
||||
const feature = await fromUuid(button.dataset.ability);
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async deleteFeatureAbility(event, button){
|
||||
static async deleteFeatureAbility(event, button) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const feature = button.dataset.feature;
|
||||
const newAbilities = this.document.system[`${feature}Feature`].abilities.filter(x => x.uuid !== button.dataset.ability);
|
||||
const newAbilities = this.document.system[`${feature}Feature`].abilities.filter(
|
||||
x => x.uuid !== button.dataset.ability
|
||||
);
|
||||
const path = `system.${feature}Feature.abilities`;
|
||||
|
||||
|
||||
await this.document.update({ [path]: newAbilities });
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
if(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.subclass.id) {
|
||||
if(event.currentTarget.classList.contains('foundation-tab')){
|
||||
await this.document.update({ "system.foundationFeature.abilities": [...this.document.system.foundationFeature.abilities, item.system] });
|
||||
}
|
||||
else if(event.currentTarget.classList.contains('specialization-tab')){
|
||||
await this.document.update({ "system.specializationFeature.abilities": [...this.document.system.specializationFeature.abilities, data.system] });
|
||||
}
|
||||
else if(event.currentTarget.classList.contains('mastery-tab')){
|
||||
await this.document.update({ "system.masteryFeature.abilities": [...this.document.system.masteryFeature.abilities, data.system] });
|
||||
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.subclass.id) {
|
||||
if (event.currentTarget.classList.contains('foundation-tab')) {
|
||||
await this.document.update({
|
||||
'system.foundationFeature.abilities': [
|
||||
...this.document.system.foundationFeature.abilities,
|
||||
item.system
|
||||
]
|
||||
});
|
||||
} else if (event.currentTarget.classList.contains('specialization-tab')) {
|
||||
await this.document.update({
|
||||
'system.specializationFeature.abilities': [
|
||||
...this.document.system.specializationFeature.abilities,
|
||||
data.system
|
||||
]
|
||||
});
|
||||
} else if (event.currentTarget.classList.contains('mastery-tab')) {
|
||||
await this.document.update({
|
||||
'system.masteryFeature.abilities': [...this.document.system.masteryFeature.abilities, data.system]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
// return context;
|
||||
// }
|
||||
|
||||
|
||||
// async _handleAction(action, event, button) {
|
||||
// switch(action){
|
||||
// }
|
||||
|
|
@ -30,25 +29,25 @@
|
|||
import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
export default class WeaponSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
export default class WeaponSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: "daggerheart-weapon",
|
||||
classes: ["daggerheart", "sheet", "weapon"],
|
||||
id: 'daggerheart-weapon',
|
||||
classes: ['daggerheart', 'sheet', 'weapon'],
|
||||
position: { width: 400 },
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: "feature",
|
||||
template: "systems/daggerheart/templates/sheets/weapon.hbs"
|
||||
id: 'feature',
|
||||
template: 'systems/daggerheart/templates/sheets/weapon.hbs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
@ -59,7 +58,7 @@ export default class WeaponSheet extends DaggerheartSheet(ItemSheetV2) {
|
|||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
await this.document.update(formData.object)
|
||||
await this.document.update(formData.object);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue