96 lines
2.9 KiB
JavaScript
96 lines
2.9 KiB
JavaScript
import { RdDItemSort } from "./item-sort.js";
|
|
import { RdDUtility } from "./rdd-utility.js";
|
|
|
|
/**
|
|
* Extend the basic ItemSheet with some very simple modifications
|
|
* @extends {ItemSheet}
|
|
*/
|
|
export class RdDItemSheet extends ItemSheet {
|
|
|
|
/** @override */
|
|
static get defaultOptions() {
|
|
return mergeObject(super.defaultOptions, {
|
|
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
|
|
template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html",
|
|
width: 520,
|
|
height: 480
|
|
//tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
|
|
});
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @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;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
async getData() {
|
|
let data = super.getData();
|
|
|
|
if ( data.item.type == 'tache' || data.item.type == 'livre') {
|
|
data.caracList = duplicate(game.system.model.Actor.personnage.carac);
|
|
data.competenceList = await RdDUtility.getCompetenceList( 'foundryvtt-reve-de-dragon.competences' );
|
|
}
|
|
if ( this.actor ) {
|
|
data.isOwned = true;
|
|
data.actorId = this.actor._id;
|
|
}
|
|
data.bonusCaseList = RdDItemSort.getBonusCaseList(data, true);
|
|
data.isGM = game.user.isGM; // Pour vérouiller certaines éditions
|
|
|
|
return data;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
/** @override */
|
|
activateListeners(html) {
|
|
super.activateListeners(html);
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
if (!this.options.editable) return;
|
|
|
|
// Select competence categorie
|
|
html.find("#categorie").on("click", this._onClickSelectCategorie.bind(this) );
|
|
|
|
html.find('#creer-tache-livre').click((event) => {
|
|
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
|
let actor = game.actors.get( actorId );
|
|
actor.creerTacheDepuisLivre( this.item );
|
|
});
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
async _onClickSelectCategorie(event) {
|
|
event.preventDefault();
|
|
|
|
const category = event.currentTarget.value;
|
|
let level = CONFIG.RDD.level_category[category];
|
|
this.object.data.data.base = level;
|
|
$("#base").val( level );
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
get template()
|
|
{
|
|
let type = this.item.type;
|
|
return `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
_updateObject(event, formData) {
|
|
|
|
// Données de bonus de cases ?
|
|
formData = RdDItemSort.buildBonusCaseStringFromFormData( formData );
|
|
|
|
return this.object.update(formData);
|
|
}
|
|
}
|