Initial commit

This commit is contained in:
WBHarry 2025-05-22 16:53:39 +02:00
commit aa4021d1a2
163 changed files with 26530 additions and 0 deletions

View file

@ -0,0 +1,377 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export class Teest extends DhpApplicationMixin(ActorSheet) {
// static documentType = "adversary";
// constructor(options){
// super(options);
// this.editMode = false;
// }
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "adversary"],
// width: 600,
// height: 'auto',
// resizable: false,
// });
// }
// async getData() {
// const context = super.getData();
// context.config = SYSTEM;
// context.editMode = this.editMode;
// context.title = `${this.actor.name} - ${game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.actor.system.type].name)}`;
// context.data = {
// description: this.object.system.description,
// motivesAndTactics: this.object.system.motivesAndTactics.join(', '),
// tier: this.object.system.tier,
// type: game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.object.system.type].name),
// attack: {
// name: this.object.system.attack.name,
// 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,
// 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,
// },
// },
// damageThresholds: this.object.system.damageThresholds,
// difficulty: this.object.system.difficulty,
// hp: { ...this.object.system.resources.health, lastRowIndex: Math.floor(this.object.system.resources.health.max/5)*5 },
// stress: { ...this.object.system.resources.stress, lastRowIndex: Math.floor(this.object.system.resources.stress.max/5)*5 },
// moves: this.object.system.moves,
// };
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'viewMove':
// await this.viewMove(button);
// break;
// case 'addMove':
// this.addMove();
// break;
// case 'removeMove':
// await this.removeMove(button);
// break;
// case 'toggleSlider':
// this.toggleEditMode();
// break;
// case 'addMotive':
// await this.addMotive();
// break;
// case 'removeMotive':
// await this.removeMotive(button);
// break;
// case 'reactionRoll':
// await this.reactionRoll(event);
// break;
// case 'attackRoll':
// await this.attackRoll(event);
// break;
// case 'addExperience':
// await this.addExperience();
// break;
// case 'removeExperience':
// await this.removeExperience(button);
// break;
// case 'toggleHP':
// await this.toggleHP(button);
// break;
// case 'toggleStress':
// await this.toggleStress(button);
// break;
// }
// }
// async viewMove(button){
// const move = await fromUuid(button.dataset.move);
// move.sheet.render(true);
// }
// async addMove(){
// const result = await this.object.createEmbeddedDocuments("Item", [{
// name: game.i18n.localize('DAGGERHEART.Sheets.Adversary.NewMove'),
// type: 'feature',
// }]);
// await result[0].sheet.render(true);
// }
// async removeMove(button){
// await this.object.items.find(x => x.uuid === button.dataset.move).delete();
// }
// toggleEditMode(){
// this.editMode = !this.editMode;
// this.render();
// }
// async addMotive(){
// await this.object.update({ "system.motivesAndTactics": [...this.object.system.motivesAndTactics, ''] });
// }
// async removeMotive(button){
// await this.object.update({ "system.motivesAndTactics": this.object.system.motivesAndTactics.filter((_, index) => index !== Number.parseInt(button.dataset.motive) )});
// }
// 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 msg = new cls({
// type: 'adversaryRoll',
// system: {
// roll: roll._formula,
// total: roll._total,
// modifiers: modifiers,
// diceResults: diceResults,
// },
// content: "systems/daggerheart/templates/chat/adversary-roll.hbs",
// rolls: [roll]
// });
// cls.create(msg.toObject());
// }
// async attackRoll(event){
// const modifier = Number.parseInt(event.currentTarget.dataset.value);
// 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,
// }));
// const cls = getDocumentClass("ChatMessage");
// const msg = new cls({
// type: 'adversaryRoll',
// system: {
// roll: roll._formula,
// total: roll._total,
// modifiers: modifiers,
// diceResults: diceResults,
// targets: targets,
// damage: { value: event.currentTarget.dataset.damage, type: event.currentTarget.dataset.damageType },
// },
// content: "systems/daggerheart/templates/chat/adversary-attack-roll.hbs",
// rolls: [roll]
// });
// cls.create(msg.toObject());
// }
// async addExperience(){
// await this.object.update({ "system.experiences": [...this.object.system.experiences, { name: 'Experience', value: 1 }] });
// }
// async removeExperience(button){
// await this.object.update({ "system.experiences": this.object.system.experiences.filter((_, index) => index !== Number.parseInt(button.dataset.experience) )});
// }
// async toggleHP(button){
// const index = Number.parseInt(button.dataset.index);
// const newHP = index < this.object.system.resources.health.value ? index : index+1;
// await this.object.update({ "system.resources.health.value": newHP });
// }
// async toggleStress(button){
// const index = Number.parseInt(button.dataset.index);
// const newStress = index < this.object.system.resources.stress.value ? index : index+1;
// await this.object.update({ "system.resources.stress.value": newStress });
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ActorSheetV2 } = foundry.applications.sheets;
export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
constructor(options={}){
super(options);
this.editMode = false;
}
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-adversary",
classes: ["daggerheart", "sheet", "adversary"],
position: { width: 600 },
actions: {
viewMove: this.viewMove,
addMove: this.addMove,
removeMove: this.removeMove,
toggleSlider: this.toggleEditMode,
addMotive: this.addMotive,
removeMotive: this.removeMotive,
reactionRoll: this.reactionRoll,
attackRoll: this.attackRoll,
addExperience: this.addExperience,
removeExperience: this.removeExperience,
toggleHP: this.toggleHP,
toggleStress: this.toggleStress,
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/adversary.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.config = SYSTEM;
context.editMode = this.editMode;
context.title = `${this.actor.name} - ${game.i18n.localize(SYSTEM.ACTOR.adversaryTypes[this.actor.system.type].name)}`;
context.data = {
description: this.document.system.description,
motivesAndTactics: this.document.system.motivesAndTactics.join(', '),
tier: this.document.system.tier,
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,
damage: {
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,
},
},
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,
};
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
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',
}]);
await result[0].sheet.render(true);
}
static async removeMove(_, button){
await this.document.items.find(x => x.uuid === button.dataset.move).delete();
}
static toggleEditMode(){
this.editMode = !this.editMode;
this.render();
}
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 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 msg = new cls({
type: 'adversaryRoll',
system: {
roll: roll._formula,
total: roll._total,
modifiers: modifiers,
diceResults: diceResults,
},
content: "systems/daggerheart/templates/chat/adversary-roll.hbs",
rolls: [roll]
});
cls.create(msg.toObject());
}
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 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,
}));
const cls = getDocumentClass("ChatMessage");
const msg = new cls({
type: 'adversaryRoll',
system: {
roll: roll._formula,
total: roll._total,
modifiers: modifiers,
diceResults: diceResults,
targets: targets,
damage: { value: button.dataset.damage, type: button.dataset.damageType },
},
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 removeExperience(_, button){
await this.document.update({ "system.experiences": this.document.system.experiences.filter((_, index) => index !== Number.parseInt(button.dataset.experience) )});
}
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 });
}
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 });
}
}

View file

@ -0,0 +1,117 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class AncestrySheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "ancestry";
// constructor(options){
// super(options);
// }
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "heritage"],
// width: 600,
// height: 'auto',
// dragDrop: [{ dragSelector: null, dropSelector: null }],
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'editAbility':
// this.editAbility(button);
// break;
// case 'deleteAbility':
// this.deleteAbility(event);
// break;
// }
// }
// async editAbility(button){
// const feature = await fromUuid(button.dataset.ability);
// feature.sheet.render(true);
// }
// async deleteAbility(event){
// event.preventDefault();
// event.stopPropagation();
// await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== event.currentTarget.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.object.update({ "system.abilities": [...this.item.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class AncestrySheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-ancestry",
classes: ["daggerheart", "sheet", "heritage"],
position: { width: 600 },
actions: {
editAbility: this.editAbility,
deleteAbility: this.deleteAbility,
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
dragDrop: [{ dragSelector: null, dropSelector: null }],
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/ancestry.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
static async editAbility(_, button){
const feature = await fromUuid(button.dataset.ability);
feature.sheet.render(true);
}
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) })
}
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 }] });
}
}
}

View file

@ -0,0 +1,65 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class ArmorSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "armor";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "armor"],
// width: 400,
// height: 'auto',
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// context.config = CONFIG.daggerheart;
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class ArmorSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-armor",
classes: ["daggerheart", "sheet", "armor"],
position: { width: 400 },
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
dragDrop: [{ dragSelector: null, dropSelector: null }],
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/armor.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.config = CONFIG.daggerheart;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
}

View file

@ -0,0 +1,419 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// import Tagify from '@yaireo/tagify';
// export default class ClassSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "class";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "class"],
// width: 600,
// height: 'auto',
// resizable: false,
// tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }],
// dragDrop: [
// { dragSelector: '.suggested-item', dropSelector: null },
// { dragSelector: null, dropSelector: '.take-section' },
// { dragSelector: null, dropSelector: '.choice-a-section' },
// { dragSelector: null, dropSelector: '.choice-b-section' },
// { dragSelector: null, dropSelector: '.primary-weapon-section' },
// { dragSelector: null, dropSelector: '.secondary-weapon-section' },
// { dragSelector: null, dropSelector: '.armor-section' },
// { dragSelector: null, dropSelector: null },
// ]
// });
// }
// /** @override */
// async getData() {
// const context = super.getData();
// context.domains = this.object.system.domains.map(x => SYSTEM.DOMAIN.domains[x].name)
// return context;
// }
// activateListeners(html){
// super.activateListeners(html);
// const domainInput = $(html).find('.domain-input')[0];
// 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.name), 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 : ""}"
// ${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>
// <img src="${tagData.src}"></i>
// </div>
// </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) });
// this.render(true);
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'removeSubclass':
// await this.removeSubclass(button);
// break;
// case 'viewSubclass':
// await this.viewSubclass(button);
// break;
// case 'removeFeature':
// await this.removeFeature(button);
// break;
// case 'viewFeature':
// await this.viewFeature(button);
// break;
// case 'removeItem':
// await this.removeItem(event);
// break;
// case 'viewItem':
// await this.viewItem(button);
// break;
// case 'removePrimaryWeapon':
// await this.removePrimaryWeapon(event);
// break;
// case 'removeSecondaryWeapon':
// await this.removeSecondaryWeapon(event);
// break;
// case 'removeArmor':
// await this.removeArmor(event);
// break;
// }
// }
// async removeSubclass(button){
// await this.object.update({ "system.subclasses": this.object.system.subclasses.filter(x => x.uuid !== button.dataset.subclass)});
// }
// async viewSubclass(button){
// const subclass = await fromUuid(button.dataset.subclass);
// subclass.sheet.render(true);
// }
// async removeFeature(button){
// await this.object.update({ "system.features": this.object.system.features.filter(x => x.uuid !== button.dataset.feature)});
// }
// async viewFeature(button){
// const feature = await fromUuid(button.dataset.feature);
// feature.sheet.render(true);
// }
// async removeItem(event){
// event.stopPropagation();
// const type = event.currentTarget.dataset.type;
// const path = `system.inventory.${type}`;
// await this.object.update({ [path]: this.object.system.inventory[type].filter(x => x.uuid !== event.currentTarget.dataset.item)});
// }
// async viewItem(button){
// const item = await fromUuid(button.dataset.item);
// item.sheet.render(true);
// }
// async removePrimaryWeapon(event){
// event.stopPropagation();
// await this.object.update({ "system.characterGuide.suggestedPrimaryWeapon": null }, { diff: false });
// }
// async removeSecondaryWeapon(event){
// event.stopPropagation();
// await this.object.update({ "system.characterGuide.suggestedSecondaryWeapon": null }, { diff: false });
// }
// async removeArmor(event){
// event.stopPropagation();
// await this.object.update({ "system.characterGuide.suggestedArmor": null }, { diff: false });
// }
// async _onDragStart(event){
// if(event.currentTarget.classList.contains('suggested-item')){
// event.dataTransfer.setData("text/plain", JSON.stringify({ type: 'Item', uuid: event.currentTarget.dataset.item }));
// }
// super._onDragStart(event);
// }
// async _onDrop(event) {
// const data = TextEditor.getDragEventData(event);
// const item = await fromUuid(data.uuid);
// if(item.type === 'subclass') {
// await this.object.update({ "system.subclasses": [...this.object.system.subclasses, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// else if(item.type === 'feature') {
// await this.object.update({ "system.features": [...this.object.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.object.system.characterGuide.suggestedPrimaryWeapon && !item.system.secondary) await this.object.update({ "system.characterGuide.suggestedPrimaryWeapon": { img: item.img, name: item.name, uuid: item.uuid } });
// } else if(event.currentTarget.classList.contains('secondary-weapon-section')){
// if(!this.object.system.characterGuide.suggestedSecondaryWeapon && item.system.secondary) await this.object.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.object.system.characterGuide.suggestedArmor) await this.object.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.object.system.inventory.choiceA.length < 2) await this.object.update({ "system.inventory.choiceA": [...this.object.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.object.system.inventory.take.length < 3) await this.object.update({ "system.inventory.take": [...this.object.system.inventory.take, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// else if(event.currentTarget.classList.contains('choice-b-section')){
// if(this.object.system.inventory.choiceB.length < 2) await this.object.update({ "system.inventory.choiceB": [...this.object.system.inventory.choiceB, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
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"],
position: { width: 600 },
actions: {
removeSubclass: this.removeSubclass,
viewSubclass: this.viewSubclass,
removeFeature: this.removeFeature,
viewFeature: this.viewFeature,
removeItem: this.removeItem,
viewItem: this.viewItem,
removePrimaryWeapon: this.removePrimaryWeapon,
removeSecondaryWeapon: this.removeSecondaryWeapon,
removeArmor: this.removeArmor,
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
dragDrop: [
{ dragSelector: '.suggested-item', dropSelector: null },
{ dragSelector: null, dropSelector: '.take-section' },
{ dragSelector: null, dropSelector: '.choice-a-section' },
{ dragSelector: null, dropSelector: '.choice-b-section' },
{ dragSelector: null, dropSelector: '.primary-weapon-section' },
{ dragSelector: null, dropSelector: '.secondary-weapon-section' },
{ dragSelector: null, dropSelector: '.armor-section' },
{ dragSelector: null, dropSelector: null },
]
};
static PARTS = {
form: {
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) ) {
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
v.cssClass = v.active ? "active" : "";
}
return tabs;
}
_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)}"
contenteditable='false'
spellcheck='false'
tabIndex="${this.settings.a11y.focusableTags ? 0 : -1}"
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>
<span class="${this.settings.classNames.tagText}">${tagData[this.settings.tagTextProp] || tagData.value}</span>
<img src="${tagData.src}"></i>
</div>
</tag>`;
}}
});
domainTagify.on('change', this.onDomainSelect.bind(this));
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.tabs = this._getTabs();
context.domains = this.document.system.domains.map(x => SYSTEM.DOMAIN.domains[x].label);
return context;
}
static async updateForm(event, _, formData) {
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"));
}
}
async onDomainSelect(event) {
const domains = event.detail?.value ? JSON.parse(event.detail.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 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 viewFeature(_, button){
const feature = await fromUuid(button.dataset.feature);
feature.sheet.render(true);
}
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)});
}
static async viewItem(_, button){
const item = await fromUuid(button.dataset.item);
item.sheet.render(true);
}
static async removePrimaryWeapon(event){
event.stopPropagation();
await this.document.update({ "system.characterGuide.suggestedPrimaryWeapon": null }, { diff: false });
}
static async removeSecondaryWeapon(event){
event.stopPropagation();
await this.document.update({ "system.characterGuide.suggestedSecondaryWeapon": null }, { diff: false });
}
static async removeArmor(event){
event.stopPropagation();
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 } });
}
}
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(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 }] });
}
}
}
}

View file

@ -0,0 +1,117 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class CommunitySheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "community";
// constructor(options){
// super(options);
// }
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "heritage"],
// width: 600,
// height: 'auto',
// dragDrop: [{ dragSelector: null, dropSelector: null }],
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'editAbility':
// this.editAbility(button);
// break;
// case 'deleteAbility':
// this.deleteAbility(event);
// break;
// }
// }
// async editAbility(button){
// const feature = await fromUuid(button.dataset.ability);
// feature.sheet.render(true);
// }
// async deleteAbility(event){
// event.preventDefault();
// event.stopPropagation();
// await this.item.update({ "system.abilities": this.item.system.abilities.filter(x => x.uuid !== event.currentTarget.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.object.update({ "system.abilities": [...this.item.system.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class CommunitySheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-community",
classes: ["daggerheart", "sheet", "heritage"],
position: { width: 600 },
actions: {
editAbility: this.editAbility,
deleteAbility: this.deleteAbility,
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
dragDrop: [{ dragSelector: null, dropSelector: null }],
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/community.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
static async editAbility(_, button){
const feature = await fromUuid(button.dataset.ability);
feature.sheet.render(true);
}
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) })
}
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 }] });
}
}
}

View file

@ -0,0 +1,57 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class ConsumableSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "consumable";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "consumable"],
// width: 480,
// height: 'auto',
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class ConsumableSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-consumable",
classes: ["daggerheart", "sheet", "consumable"],
position: { width: 480 },
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/consumable.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
}

View file

@ -0,0 +1,73 @@
const { HandlebarsApplicationMixin } = foundry.applications.api;
export default function DhpApplicationMixin(Base) {
return class DhpSheetV2 extends HandlebarsApplicationMixin(Base) {
constructor(options={}){
super(options);
this._dragDrop = this._createDragDropHandlers();
}
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
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)
};
return new foundry.applications.ux.DragDrop.implementation(d);
});
}
_onDrop(event) {}
}
}

View file

@ -0,0 +1,110 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class DomainCardSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "domainCard";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "domain-card"],
// width: 600,
// height: 600,
// tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// context.config = CONFIG.daggerheart;
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case 'attributeRoll':
// break;
// }
// }
// }
import DaggerheartAction from '../../data/action.mjs';
import DaggerheartActionConfig from '../config/Action.mjs';
import DaggerheartSheet from './daggerheart-sheet.mjs';
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"],
position: { width: 600, height: 600 },
actions: {
addAction: this.addAction,
editAction: this.editAction,
removeAction: this.removeAction,
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
};
static PARTS = {
form: {
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) ) {
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
v.cssClass = v.active ? "active" : "";
}
return tabs;
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.config = CONFIG.daggerheart;
context.tabs = this._getTabs();
return context;
}
static async updateForm(event, _, formData) {
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 editAction(_, button){
const action = this.document.system.actions[button.dataset.index];
await (new DaggerheartActionConfig(action)).render(true);
}
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)) });
}
}

View file

@ -0,0 +1,129 @@
import DaggerheartSheet from "./daggerheart-sheet.mjs";
const { DocumentSheetV2 } = foundry.applications.api;
export default class DhpEnvironment extends DaggerheartSheet(DocumentSheetV2) {
constructor(options){
super(options);
this.editMode = false;
}
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ["daggerheart", "sheet", "adversary", "environment"],
position: {
width: 600,
height: "auto"
},
actions: {
toggleSlider: this.toggleSlider,
viewFeature: this.viewFeature,
addFeature: this.addFeature,
removeFeature: this.removeFeature,
addTone: this.addTone,
removeTone: this.removeTone,
useFeature: this.useFeature,
},
form: {
handler: this._updateForm,
closeOnSubmit: false,
submitOnChange: true,
}
};
/** @override */
static PARTS = {
form: {
id: "form",
template: "systems/daggerheart/templates/sheets/environment.hbs"
}
}
/* -------------------------------------------- */
/** @inheritDoc */
get title() {
return `${game.i18n.localize('Environment')} - ${this.document.name}`;
}
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
});
}
return acc;
}, []),
},
editMode: this.editMode,
config: SYSTEM,
}
}
static async _updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
static toggleSlider(){
this.editMode = !this.editMode;
this.render();
}
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',
}]);
await result[0].sheet.render(true);
}
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 removeTone(button){
await this.document.update({ "system.toneAndFeel": this.document.system.toneAndFeel.filter((_, index) => index !== Number.parseInt(button.dataset.tone) )});
}
static async useFeature(_, button){
const item = this.document.items.find(x => x.uuid === button.dataset.feature);
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 },
}),
});
cls.create(msg.toObject());
}
}

View file

@ -0,0 +1,116 @@
import DaggerheartAction from '../../data/action.mjs';
import DaggerheartActionConfig from '../config/Action.mjs';
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
constructor(options={}){
super(options);
this.selectedEffectType = null;
}
static DEFAULT_OPTIONS = {
tag: 'form',
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,
},
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
};
static PARTS = {
form: {
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) ) {
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
v.cssClass = v.active ? "active" : "";
}
return tabs;
}
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
$(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.itemConfig = SYSTEM.ITEM;
context.properties = SYSTEM.ACTOR.featureProperties;
context.dice = SYSTEM.GENERAL.diceTypes;
context.selectedEffectType = this.selectedEffectType;
context.effectConfig = SYSTEM.EFFECTS;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
effectSelect(event){
this.selectedEffectType = event.currentTarget.value;
this.render(true);
}
static async addEffect(){
if(!this.selectedEffectType) return;
const { id, name, ...rest } = SYSTEM.EFFECTS.effectTypes[this.selectedEffectType];
const update = {
[foundry.utils.randomID()]: {
type: this.selectedEffectType,
value: '',
...rest
}
};
await this.item.update({ "system.effects": update });
}
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 editAction(_, button){
const action = this.document.system.actions[button.dataset.index];
await (new DaggerheartActionConfig(action)).render(true);
}
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)) });
}
}

View file

@ -0,0 +1,57 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class MiscellaneousSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "miscellaneous";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "miscellaneous"],
// width: 400,
// height: 'auto',
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// return context;
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class MiscellaneousSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-miscellaneous",
classes: ["daggerheart", "sheet", "miscellaneous"],
position: { width: 400 },
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/miscellaneous.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,168 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class SubclassSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "subclass";
// constructor(options){
// super(options);
// }
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "subclass"],
// width: 600,
// height: 720,
// tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "general" }],
// dragDrop: [
// { dragSelector: null, dropSelector: '.foundation-tab' },
// { dragSelector: null, dropSelector: '.specialization-tab' },
// { dragSelector: null, dropSelector: '.mastery-tab' }
// ],
// });
// }
// getData() {
// const context = super.getData();
// context.config = CONFIG.daggerheart;
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// case "editAbility":
// this.editAbility(button);
// break;
// case "deleteFeatureAbility":
// this.deleteFeatureAbility(event);
// break;
// }
// }
// async editAbility(button){
// const feature = await fromUuid(button.dataset.ability);
// feature.sheet.render(true);
// }
// async deleteFeatureAbility(event){
// event.preventDefault();
// event.stopPropagation();
// 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 });
// }
// 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.object.update({ "system.foundationFeature.abilities": [...this.item.system.foundationFeature.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// else if(event.currentTarget.classList.contains('specialization-tab')){
// await this.object.update({ "system.specializationFeature.abilities": [...this.item.system.specializationFeature.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// else if(event.currentTarget.classList.contains('mastery-tab')){
// await this.object.update({ "system.masteryFeature.abilities": [...this.item.system.masteryFeature.abilities, { img: item.img, name: item.name, uuid: item.uuid }] });
// }
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
import DaggerheartFeature from '../../data/feature.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class SubclassSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-subclass",
classes: ["daggerheart", "sheet", "subclass"],
position: { width: 600 },
actions: {
editAbility: this.editAbility,
deleteFeatureAbility: this.deleteFeatureAbility,
},
form: {
handler: this.updateForm,
submitOnChange: true,
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) ) {
v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active;
v.cssClass = v.active ? "active" : "";
}
return tabs;
}
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/subclass.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.config = CONFIG.daggerheart;
context.tabs = this._getTabs();
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
static async editAbility(_, button){
const feature = await fromUuid(button.dataset.ability);
feature.sheet.render(true);
}
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 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] });
}
}
}
}

View file

@ -0,0 +1,65 @@
// import DhpApplicationMixin from '../daggerheart-sheet.mjs';
// export default class WeaponSheet extends DhpApplicationMixin(ItemSheet) {
// static documentType = "weapon";
// /** @override */
// static get defaultOptions() {
// return foundry.utils.mergeObject(super.defaultOptions, {
// classes: ["daggerheart", "sheet", "weapon"],
// width: 400,
// height: 'auto',
// });
// }
// /** @override */
// getData() {
// const context = super.getData();
// context.config = CONFIG.daggerheart;
// return context;
// }
// async _handleAction(action, event, button) {
// switch(action){
// }
// }
// }
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ItemSheetV2 } = foundry.applications.sheets;
export default class WeaponSheet extends DaggerheartSheet(ItemSheetV2) {
static DEFAULT_OPTIONS = {
tag: 'form',
id: "daggerheart-weapon",
classes: ["daggerheart", "sheet", "weapon"],
position: { width: 400 },
form: {
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false,
},
};
static PARTS = {
form: {
id: "feature",
template: "systems/daggerheart/templates/sheets/weapon.hbs"
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
context.config = CONFIG.daggerheart;
return context;
}
static async updateForm(event, _, formData) {
await this.document.update(formData.object)
this.render();
}
}