Séparer les piles d'éléments #169
This commit is contained in:
@ -12,6 +12,7 @@ import { Misc } from "./misc.js";
|
||||
import { RdDCombatManager } from "./rdd-combat.js";
|
||||
import { RdDCarac } from "./rdd-carac.js";
|
||||
import { RdDItem } from "./item.js";
|
||||
import { DialogSplitItem } from "./dialog-split-item.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDActorSheet extends ActorSheet {
|
||||
@ -49,20 +50,20 @@ export class RdDActorSheet extends ActorSheet {
|
||||
// // Entity data
|
||||
// formData.actor = formData.entity;
|
||||
// formData.data = formData.entity.data;
|
||||
|
||||
|
||||
// // Owned items
|
||||
// formData.items = formData.actor.items;
|
||||
// formData.items.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
||||
|
||||
|
||||
// -------------- version 0.8.0
|
||||
|
||||
|
||||
// // Copy and sort Items
|
||||
// items.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
||||
// data.items = items;
|
||||
|
||||
|
||||
// // Copy Active Effects
|
||||
// data.effects = effects;
|
||||
|
||||
|
||||
// // Return template data
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@ -203,7 +204,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
});
|
||||
d.render(true);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async selectTypeOeuvre() {
|
||||
let typeOeuvres = RdDItem.getTypesOeuvres();
|
||||
@ -240,6 +241,11 @@ export class RdDActorSheet extends ActorSheet {
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
html.find('.item-split').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.items.get(li.data("item-id"));
|
||||
this.splitItem(item);
|
||||
});
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.items.get(li.data("item-id"));
|
||||
@ -632,4 +638,20 @@ export class RdDActorSheet extends ActorSheet {
|
||||
// Update the Actor
|
||||
return this.object.update(formData);
|
||||
}
|
||||
|
||||
async splitItem(item) {
|
||||
const dialog = await DialogSplitItem.create(item, (item, split) => this._onSplitItem(item, split));
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
async _onSplitItem(item, split) {
|
||||
const itemData = Misc.data(item);
|
||||
if (split >= 1 && split < itemData.data.quantite) {
|
||||
await item.diminuerQuantite(split);
|
||||
itemData.data.quantite = split;
|
||||
itemData.id = undefined;
|
||||
await this.actor.createEmbeddedDocuments('Item', [itemData])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user