2023-04-19 18:44:41 +02:00
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
|
|
* @extends {ActorSheet}
|
|
|
|
*/
|
|
|
|
|
2023-04-28 15:25:57 +02:00
|
|
|
import { EcrymeUtility } from "../common/ecryme-utility.js";
|
2023-04-19 18:44:41 +02:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
export class EcrymeActorSheet extends ActorSheet {
|
|
|
|
|
|
|
|
/** @override */
|
|
|
|
static get defaultOptions() {
|
|
|
|
|
|
|
|
return mergeObject(super.defaultOptions, {
|
|
|
|
classes: ["fvtt-ecryme", "sheet", "actor"],
|
|
|
|
template: "systems/fvtt-ecryme/templates/actors/actor-sheet.hbs",
|
2023-05-03 20:05:31 +02:00
|
|
|
width: 860,
|
2023-04-19 18:44:41 +02:00
|
|
|
height:680,
|
|
|
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }],
|
|
|
|
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
|
|
|
editScore: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async getData() {
|
|
|
|
|
|
|
|
let formData = {
|
|
|
|
title: this.title,
|
|
|
|
id: this.actor.id,
|
|
|
|
type: this.actor.type,
|
|
|
|
img: this.actor.img,
|
|
|
|
name: this.actor.name,
|
|
|
|
editable: this.isEditable,
|
|
|
|
cssClass: this.isEditable ? "editable" : "locked",
|
|
|
|
system: duplicate(this.object.system),
|
|
|
|
limited: this.object.limited,
|
2023-05-03 20:05:31 +02:00
|
|
|
skills: this.actor.prepareSkills(),
|
2023-05-26 07:46:06 +02:00
|
|
|
traits: this.actor.getRollTraits(),
|
2023-05-31 09:16:30 +02:00
|
|
|
confrontations: this.actor.getConfrontations(),
|
2023-05-26 07:46:06 +02:00
|
|
|
ideal: this.actor.getIdeal(),
|
|
|
|
spleen: this.actor.getSpleen(),
|
2023-05-30 22:22:52 +02:00
|
|
|
impacts: this.object.getImpacts(),
|
2023-05-03 20:05:31 +02:00
|
|
|
config: duplicate(game.system.ecryme.config),
|
2023-05-30 22:22:52 +02:00
|
|
|
weapons: this.actor.getWeapons(),
|
2023-05-31 09:16:30 +02:00
|
|
|
impactsMalus: this.actor.getImpactsMalus(),
|
2023-04-19 18:44:41 +02:00
|
|
|
archetype: duplicate(this.actor.getArchetype()),
|
2023-05-31 09:26:55 +02:00
|
|
|
equipements: this.actor.getEquipments(),
|
2023-07-21 18:57:41 +02:00
|
|
|
hasCephaly: EcrymeUtility.hasCephaly(),
|
|
|
|
cephalySkills: this.actor.getCephalySkills(),
|
2023-04-19 18:44:41 +02:00
|
|
|
subActors: duplicate(this.actor.getSubActors()),
|
|
|
|
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
|
|
|
|
notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }),
|
|
|
|
equipementlibre: await TextEditor.enrichHTML(this.object.system.equipementlibre, { async: true }),
|
|
|
|
options: this.options,
|
|
|
|
owner: this.document.isOwner,
|
|
|
|
editScore: this.options.editScore,
|
|
|
|
isGM: game.user.isGM
|
|
|
|
}
|
|
|
|
this.formData = formData;
|
|
|
|
|
|
|
|
console.log("PC : ", formData, this.object);
|
|
|
|
return formData;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
|
|
|
|
html.bind("keydown", function(e) { // Ignore Enter in actores sheet
|
|
|
|
if (e.keyCode === 13) return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Update Inventory Item
|
|
|
|
html.find('.item-edit').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item")
|
|
|
|
let itemId = li.data("item-id")
|
|
|
|
const item = this.actor.items.get( itemId );
|
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
|
|
|
// Delete Inventory Item
|
|
|
|
html.find('.item-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item")
|
2023-05-31 09:26:55 +02:00
|
|
|
EcrymeUtility.confirmDelete(this, li).catch("Error : No deletion confirmed")
|
2023-04-19 18:44:41 +02:00
|
|
|
})
|
|
|
|
html.find('.item-add').click(ev => {
|
|
|
|
let dataType = $(ev.currentTarget).data("type")
|
|
|
|
this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true })
|
|
|
|
})
|
|
|
|
|
|
|
|
html.find('.subactor-edit').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let actorId = li.data("actor-id");
|
|
|
|
let actor = game.actors.get( actorId );
|
|
|
|
actor.sheet.render(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.subactor-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let actorId = li.data("actor-id");
|
|
|
|
this.actor.delSubActor(actorId);
|
|
|
|
});
|
|
|
|
html.find('.quantity-minus').click(event => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
this.actor.incDecQuantity( li.data("item-id"), -1 );
|
|
|
|
} );
|
|
|
|
html.find('.quantity-plus').click(event => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
this.actor.incDecQuantity( li.data("item-id"), +1 );
|
|
|
|
} );
|
|
|
|
|
2023-04-28 09:39:18 +02:00
|
|
|
html.find('.roll-skill').click((event) => {
|
2023-05-03 20:05:31 +02:00
|
|
|
let categKey = $(event.currentTarget).data("category-key")
|
|
|
|
let skillKey = $(event.currentTarget).data("skill-key")
|
|
|
|
this.actor.rollSkill(categKey, skillKey)
|
2023-04-19 18:44:41 +02:00
|
|
|
});
|
2023-05-30 19:25:26 +02:00
|
|
|
html.find('.roll-skill-confront').click((event) => {
|
|
|
|
let categKey = $(event.currentTarget).data("category-key")
|
|
|
|
let skillKey = $(event.currentTarget).data("skill-key")
|
|
|
|
this.actor.rollSkillConfront(categKey, skillKey)
|
2023-07-21 18:57:41 +02:00
|
|
|
});
|
|
|
|
html.find('.roll-cephaly').click((event) => {
|
|
|
|
let skillKey = $(event.currentTarget).data("skill-key")
|
|
|
|
this.actor.rollCephalySkillConfront(skillKey)
|
|
|
|
});
|
2023-06-28 11:12:51 +02:00
|
|
|
html.find('.roll-weapon-confront').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item")
|
|
|
|
let weaponId = li.data("item-id");
|
|
|
|
this.actor.rollWeaponConfront(weaponId)
|
|
|
|
});
|
2023-05-30 19:25:26 +02:00
|
|
|
|
2023-05-30 22:22:52 +02:00
|
|
|
html.find('.impact-modify').click((event) => {
|
|
|
|
let impactType = $(event.currentTarget).data("impact-type")
|
|
|
|
let impactLevel = $(event.currentTarget).data("impact-level")
|
|
|
|
let modifier = Number($(event.currentTarget).data("impact-modifier"))
|
|
|
|
this.actor.modifyImpact(impactType, impactLevel, modifier)
|
|
|
|
});
|
|
|
|
|
2023-04-28 09:39:18 +02:00
|
|
|
html.find('.roll-weapon').click((event) => {
|
2023-04-19 18:44:41 +02:00
|
|
|
const armeId = $(event.currentTarget).data("arme-id")
|
|
|
|
this.actor.rollArme(armeId)
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.lock-unlock-sheet').click((event) => {
|
|
|
|
this.options.editScore = !this.options.editScore;
|
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
html.find('.item-equip').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
this.actor.equipItem( li.data("item-id") );
|
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
html.find('.update-field').change(ev => {
|
|
|
|
const fieldName = $(ev.currentTarget).data("field-name");
|
|
|
|
let value = Number(ev.currentTarget.value);
|
|
|
|
this.actor.update( { [`${fieldName}`]: value } );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
setPosition(options = {}) {
|
|
|
|
const position = super.setPosition(options);
|
|
|
|
const sheetBody = this.element.find(".sheet-body");
|
|
|
|
const bodyHeight = position.height - 192;
|
|
|
|
sheetBody.css("height", bodyHeight);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
_updateObject(event, formData) {
|
|
|
|
// Update the Actor
|
|
|
|
return this.object.update(formData);
|
|
|
|
}
|
|
|
|
}
|