39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
import { ITEM_TYPES } from "../constants.js";
|
|
import { DialogEnchanter } from "../enchantement/dialog-enchanter.js";
|
|
import { RdDTimestamp } from "../time/rdd-timestamp.js";
|
|
import { RdDItemGemme } from "./gemme.js";
|
|
import { RdDItemInventaireSheet } from "./sheet-base-inventaire.js";
|
|
|
|
export class RdDGemmeItemSheet extends RdDItemInventaireSheet {
|
|
|
|
static get ITEM_TYPE() { return ITEM_TYPES.gemme };
|
|
|
|
async getData() {
|
|
const formData = foundry.utils.mergeObject(await super.getData(),
|
|
{
|
|
inertie: this.item.inertie,
|
|
enchantabilite: this.item.enchantabilite,
|
|
isEnchantementPossible: this.item.isEnchantementPossible,
|
|
gemmeTypeList: RdDItemGemme.getGemmeTypeOptionList(),
|
|
dateActuelle: game.system.rdd.calendrier.dateCourante(),
|
|
enchantement: RdDTimestamp.splitIndexDate(this.item.system.prdate)
|
|
})
|
|
return formData
|
|
}
|
|
|
|
activateListeners(html) {
|
|
super.activateListeners(html);
|
|
|
|
this.html.find('.item-enchanter').click((event) => DialogEnchanter.enchanter(this.item))
|
|
|
|
this.html.find('.date-enchantement').change((event) => {
|
|
const jour = Number(this.html.find('input.date-enchantement[name="enchantement.jour"]').val())
|
|
const mois = RdDTimestamp.definition(this.html.find('select.date-enchantement[name="enchantement.mois"]').val())
|
|
const indexDate = game.system.rdd.calendrier.getIndexFromDate(jour, mois.heure)
|
|
this.item.update({ 'system.prdate': indexDate })
|
|
console.warn(`Date d'enchantement modifiée ${jour}/${mois.heure}: ${indexDate}`)
|
|
});
|
|
|
|
}
|
|
}
|