Adding Prettier

* Added prettier with automatic useage on pre-commit to avoid style breakage
* Ran Prettier on the project
This commit is contained in:
WBHarry 2025-05-23 18:57:50 +02:00 committed by GitHub
parent 820c2df1f4
commit b24cdcc9ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
136 changed files with 13929 additions and 12206 deletions

View file

@ -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();
}
}
}