From 208a394b3e33c930a0d9b5471f2fdbab31a1e3df Mon Sep 17 00:00:00 2001 From: sladecraven Date: Tue, 15 Dec 2020 22:44:49 +0100 Subject: [PATCH] =?UTF-8?q?#67=20Ajout=20d'un=20bouton=20de=20cr=C3=A9atio?= =?UTF-8?q?n=20d'objet=20sur=20les=20fiches=20de=20personnage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor-sheet.js | 33 ++++++++++++++++++++++++++++++++- module/actor.js | 1 - templates/actor-sheet.html | 3 ++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 9efb56ac..7a902cfd 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -199,6 +199,34 @@ export class RdDActorSheet extends ActorSheet { await this.actor.createOwnedItem( { name: 'Nouvelle tache', type: 'tache'}, { renderSheet: true } ); } + /* -------------------------------------------- */ + async creerObjet( ) { + let itemType = $("#creer-equipement").val(); + await this.actor.createOwnedItem( { name: 'Nouveau '+itemType, type: itemType}, { renderSheet: true } ); + } + + /* -------------------------------------------- */ + async selectObjetType( ) { + let itemType = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "monnaie"]; + let options = 'Selectionnez le type d\'équipement'; + let d = new Dialog( { + title: "Créer un équipement", + content: options, + buttons: { + one: { + icon: '', + label: "Créer l'objet", + callback: () => this.creerObjet() + } + } + }); + d.render(true); + } + /* -------------------------------------------- */ /** @override */ activateListeners(html) { @@ -234,7 +262,10 @@ export class RdDActorSheet extends ActorSheet { html.find('#creer-tache').click(ev => { this.createEmptyTache(); }); - + html.find('#creer-un-objet').click(ev => { + this.selectObjetType(); + }); + // Blessure control html.find('.blessure-control').click(ev => { const li = $(ev.currentTarget).parents(".item"); diff --git a/module/actor.js b/module/actor.js index d91608ca..c027b355 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1496,7 +1496,6 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async creerTacheDepuisLivre( item ) { - console.log("FROM ITEM", item); let tache = { name: "Lire " + item.name, type: 'tache', data: { carac: 'intellect', diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 7770e99d..dec727be 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -573,7 +573,8 @@ {{!-- Equipment Tab --}}
- Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}} {{data.surEncombrementMessage}} + Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}} {{data.surEncombrementMessage}} - + Créer un objet