Utilisation de system dans les Item/Actor Sheet
Utilisation de system dans les data de formulaire pour tous les Item/Actor (à la base, ou les sous-éléments) Corrections sur les sorts en réserve (ce ne sont pas des Item) Petites améliorations: * `actor.itemTypes[type]` revient à faire (sans besoin de filtrer) `actor.items.filter(it => it.type == type)` * dans les ItemSheet, this.object et this.document remplacés par this.item * dans les ActorSheet, this.object et this.document remplacés par this.actor Quelques corrections en plus: * parade ne marchait pas * problèmes sur le commerce
This commit is contained in:
@ -32,7 +32,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
let buttons = super._getHeaderButtons();
|
||||
// Add "Post to chat" button
|
||||
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
|
||||
if ("cout" in this.object.system && this.object.isVideOuNonConteneur()) {
|
||||
if ("cout" in this.item.system && this.item.isVideOuNonConteneur()) {
|
||||
buttons.unshift({
|
||||
class: "vendre",
|
||||
icon: "fas fa-comments-dollar",
|
||||
@ -61,22 +61,24 @@ export class RdDItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
let formData = {
|
||||
id: this.object.id,
|
||||
title: this.object.name,
|
||||
type: this.object.type,
|
||||
img: this.object.img,
|
||||
name: this.object.name,
|
||||
data: this.object.system,
|
||||
id: this.item.id,
|
||||
title: this.item.name,
|
||||
type: this.item.type,
|
||||
img: this.item.img,
|
||||
name: this.item.name,
|
||||
system: this.item.system,
|
||||
// TODO: v10 remove
|
||||
data: this.item.system,
|
||||
isGM: game.user.isGM,
|
||||
actorId: this.actor?.id,
|
||||
owner: this.document.isOwner,
|
||||
owner: this.item.isOwner,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
isSoins: false
|
||||
}
|
||||
if (this.actor) {
|
||||
formData.isOwned = true;
|
||||
if (this.object.type == 'conteneur') {
|
||||
if (this.item.type == 'conteneur') {
|
||||
this.prepareConteneurData(formData);
|
||||
}
|
||||
}
|
||||
@ -92,15 +94,15 @@ export class RdDItemSheet extends ItemSheet {
|
||||
console.log(formData.competences)
|
||||
}
|
||||
if (formData.type == 'recettealchimique') {
|
||||
RdDAlchimie.processManipulation(this.object, this.actor && this.actor.id);
|
||||
RdDAlchimie.processManipulation(this.item, this.actor && this.actor.id);
|
||||
}
|
||||
if (formData.type == 'gemme') {
|
||||
formData.gemmeTypeList = RdDGemme.getGemmeTypeOptionList();
|
||||
RdDGemme.calculDataDerivees(formData.data);
|
||||
RdDGemme.calculDataDerivees(this.item);
|
||||
}
|
||||
if (formData.type == 'potion') {
|
||||
if (this.dateUpdated) {
|
||||
formData.data.prdate = this.dateUpdated;
|
||||
formData.system.prdate = this.dateUpdated;
|
||||
this.dateUpdated = undefined;
|
||||
}
|
||||
RdDHerbes.updatePotionData(formData);
|
||||
@ -119,7 +121,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
RdDUtility.filterEquipementParType(formData)
|
||||
|
||||
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
||||
formData.subItems = formData.conteneurs.find(it => it._id == this.object.id)?.subItems;
|
||||
formData.subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems;
|
||||
|
||||
}
|
||||
|
||||
@ -128,15 +130,15 @@ export class RdDItemSheet extends ItemSheet {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
if (this.object.type == 'conteneur') {
|
||||
if (this.item.type == 'conteneur') {
|
||||
this.form.ondragstart = (event) => this._onDragStart(event);
|
||||
this.form.ondrop = (event) => this._onDrop(event);
|
||||
}
|
||||
|
||||
let itemSheetDialog = this;
|
||||
|
||||
HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.object.isOwned);
|
||||
HtmlUtility._showControlWhen($(".item-magique"), this.object.isMagique());
|
||||
HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned);
|
||||
HtmlUtility._showControlWhen($(".item-magique"), this.item.isMagique());
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
@ -145,8 +147,8 @@ export class RdDItemSheet extends ItemSheet {
|
||||
html.find(".categorie").change(event => this._onSelectCategorie(event));
|
||||
|
||||
html.find('.sheet-competence-xp').change((event) => {
|
||||
if (this.object.type == 'competence') {
|
||||
RdDUtility.checkThanatosXP(this.object.name);
|
||||
if (this.item.type == 'competence') {
|
||||
RdDUtility.checkThanatosXP(this.item.name);
|
||||
}
|
||||
});
|
||||
|
||||
@ -219,16 +221,16 @@ export class RdDItemSheet extends ItemSheet {
|
||||
async _onSelectCategorie(event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (this.object.isCompetence()) {
|
||||
if (this.item.isCompetence()) {
|
||||
let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value);
|
||||
this.object.system.base = level;
|
||||
this.item.system.base = level;
|
||||
$("#base").val(level);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
get template() {
|
||||
let type = this.object.type
|
||||
let type = this.item.type
|
||||
return `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`;
|
||||
}
|
||||
|
||||
@ -239,7 +241,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
// Données de bonus de cases ?
|
||||
formData = RdDItemSort.buildBonusCaseStringFromFormData(formData);
|
||||
|
||||
return this.object.update(formData);
|
||||
return this.item.update(formData);
|
||||
}
|
||||
|
||||
async _onDragStart(event) {
|
||||
@ -252,28 +254,28 @@ export class RdDItemSheet extends ItemSheet {
|
||||
const dragData = {
|
||||
actorId: this.actor.id,
|
||||
type: "Item",
|
||||
data: item
|
||||
data: item.system
|
||||
};
|
||||
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
// Try to extract the data
|
||||
let data;
|
||||
// Try to extract the dragData
|
||||
let dragData;
|
||||
try {
|
||||
data = JSON.parse(event.dataTransfer.getData('text/plain'));
|
||||
dragData = JSON.parse(event.dataTransfer.getData('text/plain'));
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const allowed = Hooks.call("dropActorSheetData", this.actor, this, data);
|
||||
const allowed = Hooks.call("dropActorSheetData", this.actor, this, dragData);
|
||||
if (allowed === false) return;
|
||||
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
// Handle different dragData types
|
||||
switch (dragData.type) {
|
||||
case "Item":
|
||||
return this._onDropItem(event, data);
|
||||
return this._onDropItem(event, dragData);
|
||||
}
|
||||
return super._onDrop(event);
|
||||
}
|
||||
@ -281,7 +283,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
async _onDropItem(event, dragData) {
|
||||
if (this.actor) {
|
||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.object.id, this.actor.id, dragData, this.objetVersConteneur);
|
||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor.id, dragData, this.objetVersConteneur);
|
||||
await this.actor.processDropItem(dropParams);
|
||||
await this.render(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user