mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Ran prettier
This commit is contained in:
parent
5fc5d988e6
commit
48ab150a4e
133 changed files with 13852 additions and 12549 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue