diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 8045dcc9..1cca5819 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -123,6 +123,9 @@ export class RdDActorSheet extends ActorSheet {
data.data.caseSpeciales = data.itemsByType['casetmr'];
RdDUtility.buildArbreDeConteneur(this, data);
data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
+ data.data.vehiculesList = this.actor.buildVehiculesList();
+ data.data.monturesList = this.actor.buildMonturesList();
+ data.data.suivantsList = this.actor.buildSuivantsList();
return data;
}
@@ -135,47 +138,6 @@ export class RdDActorSheet extends ActorSheet {
}
}
- /* -------------------------------------------- */
- async confirmerSuppression(li) {
- let itemId = li.data("item-id");
- let objet = this.actor.items.find( item => item._id == itemId );
- let msgTxt = "
Etes vous certain de vouloir supprimer cet objet ?";
- let buttons = { delete: {
- icon: '',
- label: "Supprimer l'objet",
- callback: () => {
- console.log("Delete : ", itemId);
- this.actor.deleteOwnedItem( itemId );
- li.slideUp(200, () => this.render(false));
- }
- },
- cancel: {
- icon: '',
- label: "Annuler"
- }
- }
- if ( objet.data.type == 'conteneur' && objet.data.data.contenu.length > 0) {
- msgTxt += "
Cet objet est aussi un conteneur avec du contenu : choisissez l'option de suppression";
- buttons['deleteall'] = {
- icon: '',
- label: "Supprimer le conteneur et tout son contenu",
- callback: () => {
- console.log("Delete : ", itemId);
- this.actor.deleteAllConteneur( itemId );
- li.slideUp(200, () => this.render(false));
- }
- }
- }
- msgTxt += "
";
- let d = new Dialog({
- title: "Confirmer la suppression",
- content: msgTxt,
- buttons: buttons,
- default: "cancel"
- });
- d.render(true);
- }
-
/* -------------------------------------------- */
async createEmptyTache() {
await this.actor.createOwnedItem({ name: 'Nouvelle tache', type: 'tache' }, { renderSheet: true });
@@ -229,9 +191,13 @@ export class RdDActorSheet extends ActorSheet {
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
- this.confirmerSuppression(li);
+ RdDUtility.confirmerSuppression(this, li);
});
-
+ html.find('.subacteur-delete').click(ev => {
+ const li = $(ev.currentTarget).parents(".item");
+ RdDUtility.confirmerSuppressionSubacteur(this, li);
+ });
+
html.find('#encaisser-direct').click(ev => {
this.actor.encaisser();
});
@@ -314,7 +280,15 @@ export class RdDActorSheet extends ActorSheet {
let meditationId = li.data('item-id');
this.actor.rollMeditation(meditationId);
});
-
+ html.find('.subacteur-label a').click((event) => {
+ const li = $(event.currentTarget).parents(".item");
+ let actorId = li.data('actor-id');
+ let actor = game.actors.get( actorId) ;
+ if ( actor ) {
+ actor.sheet.render(true);
+ }
+ });
+
// Points de reve actuel
html.find('.ptreve-actuel a').click((event) => {
this.actor.rollCarac('reve-actuel');
diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js
index b33c2d74..b9136a2b 100644
--- a/module/actor-vehicule-sheet.js
+++ b/module/actor-vehicule-sheet.js
@@ -74,12 +74,10 @@ export class RdDActorVehiculeSheet extends ActorSheet {
const item = this.actor.getOwnedItem(li.data("itemId"));
item.sheet.render(true);
});
-
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
- this.actor.deleteOwnedItem(li.data("itemId"));
- li.slideUp(200, () => this.render(false));
+ RdDUtility.confirmerSuppression(this, li);
});
// Display info about queue
diff --git a/module/actor.js b/module/actor.js
index 11e03da1..7f5a9ec7 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -2506,6 +2506,77 @@ export class RdDActor extends Actor {
_alchimieResult(rollData) {
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html');
}
+
+ /* -------------------------------------------- */
+ buildVehiculesList() {
+ let myArray = [];
+ for (let vehiculeLink of this.data.data.subacteurs.vehicules) {
+ let vehicule = game.actors.get( vehiculeLink.id );
+ myArray.push( { id: vehiculeLink.id, name: vehicule.data.name, categorie: vehicule.data.data.categorie,
+ structure: vehicule.data.data.structure, img: vehicule.data.img } );
+
+ }
+ return myArray;
+ }
+
+ /* -------------------------------------------- */
+ buildSuivantsList() {
+ let myArray = [];
+ for (let suivantLink of this.data.data.subacteurs.suivants) {
+ let suivant = game.actors.get( suivantLink.id );
+ myArray.push( { id: suivantLink.id, name: suivant.data.name, img: suivant.data.img } );
+ }
+ return myArray;
+ }
+
+ /* -------------------------------------------- */
+ buildMonturesList() {
+ let myArray = [];
+ for (let montureLink of this.data.data.subacteurs.montures) {
+ let monture = game.actors.get( montureLink.id );
+ myArray.push( { id: montureLink.id, name: monture.data.name, img: monture.data.img } );
+ }
+ return myArray;
+ }
+
+ /* -------------------------------------------- */
+ async pushSubacteur( actor, dataArray, dataPath, dataName ) {
+ let alreadyPresent = dataArray.find( attached => attached.id == actor.data._id);
+ if ( !alreadyPresent ) {
+ let newArray = duplicate(dataArray);
+ newArray.push( { id: actor.data._id });
+ await this.update( { [dataPath]: newArray });
+ } else {
+ ui.notifications.warn(dataName+" est déja attaché à ce Personnage.");
+ }
+ }
+
+ /* -------------------------------------------- */
+ addSubacteur( actorId ) {
+ let actor = game.actors.get( actorId );
+ //console.log("Ajout acteur : ", actor, this);
+ if (actor && actor.owner ) {
+ if (actor.data.type == 'vehicule') {
+ this.pushSubacteur( actor, this.data.data.subacteurs.vehicules, 'data.subacteurs.vehicules', 'Ce Véhicule' );
+ } else if (actor.data.type == 'creature') {
+ this.pushSubacteur( actor, this.data.data.subacteurs.montures, 'data.subacteurs.montures', 'Cette Monture' );
+ } else if (actor.data.type == 'personnage') {
+ this.pushSubacteur( actor, this.data.data.subacteurs.suivants, 'data.subacteurs.suivants', 'Ce Suivant' );
+ }
+ } else {
+ ui.notifications.warn("Vous n'avez pas les droits sur l'acteur que vous attachez.")
+ }
+ }
+
+ /* -------------------------------------------- */
+ async removeSubacteur( actorId ) {
+ let newVehicules = this.data.data.subacteurs.vehicules.filter(function(obj, index, arr){ return obj.id != actorId } );
+ let newSuivants = this.data.data.subacteurs.suivants.filter(function(obj, index, arr){ return obj.id != actorId } );
+ let newMontures = this.data.data.subacteurs.montures.filter(function(obj, index, arr){ return obj.id != actorId } );
+ await this.update( { 'data.subacteurs.vehicules': newVehicules });
+ await this.update( { 'data.subacteurs.suivants': newSuivants });
+ await this.update( { 'data.subacteurs.montures': newMontures });
+ }
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index 0dc497e7..af8dee23 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -269,20 +269,24 @@ export class RdDUtility {
console.log(dragData, actorSheet.actor._id);
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
let objetId = dragData.id || dragData.data._id;
- if ( dropID ) { // Dropped over an item !!!
- if (actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) {
- if (actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID)) {
- await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]);
- await actorSheet.actor.ajouterAConteneur(objetId, dropID);
+ if ( dragData.type == 'Item') {
+ if ( dropID ) { // Dropped over an item !!!
+ if (actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) {
+ if (actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID)) {
+ await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]);
+ await actorSheet.actor.ajouterAConteneur(objetId, dropID);
+ }
}
}
+ if (dragData.actorId && dragData.actorId != actorSheet.actor._id ) { // Un acteur est à l'origine de l'item -> deplacement
+ console.log("Moving objects");
+ actorSheet.actor.moveItemsBetweenActors( objetId, dragData.actorId);
+ return false;
+ }
+ actorSheet.actor.computeEncombrementTotalEtMalusArmure();
+ } else if ( dragData.type == "Actor" ) {
+ actorSheet.actor.addSubacteur( objetId );
}
- if (dragData.actorId && dragData.actorId != actorSheet.actor._id ) { // Un acteur est à l'origine de l'item -> deplacement
- console.log("Moving objects");
- actorSheet.actor.moveItemsBetweenActors( objetId, dragData.actorId);
- return false;
- }
- actorSheet.actor.computeEncombrementTotalEtMalusArmure();
return true;
}
@@ -836,6 +840,77 @@ export class RdDUtility {
chatData["whisper"] = ChatMessage.getWhisperRecipients(forceWhisper);
}
- return chatData;
+ return chatData;
}
+
+ /* -------------------------------------------- */
+ static confirmerSuppressionSubacteur(actorSheet, li ) {
+ let actorId = li.data("actor-id");
+ let actor = game.actors.get( actorId );
+ let msgTxt = "Etes vous certain de vouloir supprimer le lien vers ce véhicule/monture/suivant : " + actor.data.name +" ?
";
+ let buttons = {
+ delete: {
+ icon: '',
+ label: "Supprimer le lien",
+ callback: () => {
+ console.log("Delete : ", actorId);
+ actorSheet.actor.removeSubacteur( actorId );
+ li.slideUp(200, () => actorSheet.render(false));
+ }
+ },
+ cancel: {
+ icon: '',
+ label: "Annuler"
+ }
+ }
+ let d = new Dialog({
+ title: "Confirmer la suppression du lien",
+ content: msgTxt,
+ buttons: buttons,
+ default: "cancel"
+ });
+ d.render(true);
+ }
+
+ /* -------------------------------------------- */
+ static async confirmerSuppression(actorSheet, li) {
+ let itemId = li.data("item-id");
+ let objet = actorSheet.actor.items.find( item => item._id == itemId );
+ let msgTxt = "Etes vous certain de vouloir supprimer cet objet ?";
+ let buttons = { delete: {
+ icon: '',
+ label: "Supprimer l'objet",
+ callback: () => {
+ console.log("Delete : ", itemId);
+ actorSheet.actor.deleteOwnedItem( itemId );
+ li.slideUp(200, () => actorSheet.render(false));
+ }
+ },
+ cancel: {
+ icon: '',
+ label: "Annuler"
+ }
+ }
+ if ( objet.data.type == 'conteneur' && objet.data.data.contenu.length > 0) {
+ msgTxt += "
Cet objet est aussi un conteneur avec du contenu : choisissez l'option de suppression";
+ buttons['deleteall'] = {
+ icon: '',
+ label: "Supprimer le conteneur et tout son contenu",
+ callback: () => {
+ console.log("Delete : ", itemId);
+ actorSheet.actor.deleteAllConteneur( itemId );
+ li.slideUp(200, () => actorSheet.render(false));
+ }
+ }
+ }
+ msgTxt += "
";
+ let d = new Dialog({
+ title: "Confirmer la suppression",
+ content: msgTxt,
+ buttons: buttons,
+ default: "cancel"
+ });
+ d.render(true);
+ }
+
}
diff --git a/styles/simple.css b/styles/simple.css
index 1ccbbce2..f1d91e6f 100644
--- a/styles/simple.css
+++ b/styles/simple.css
@@ -647,6 +647,7 @@ ul, li {
.competence-label,
.astrologie-label,
.tache-label,
+.subacteur-label,
.description-label {
flex-grow: 2;
}
diff --git a/system.json b/system.json
index 9ae3ff4f..3bc5f57b 100644
--- a/system.json
+++ b/system.json
@@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
- "version": "1.2.12",
+ "version": "1.2.15",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.8",
- "templateVersion": 81,
+ "templateVersion": 83,
"author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"],
diff --git a/template.json b/template.json
index 79d37dd7..79da80cb 100644
--- a/template.json
+++ b/template.json
@@ -6,6 +6,13 @@
"description": "Description ...",
"notesmj": "Notes du MJ"
},
+ "subacteurs": {
+ "subacteurs": {
+ "suivants": [],
+ "montures": [],
+ "vehicules": []
+ }
+ },
"background": {
"biographie": "Histoire personnelle...",
"notes": "Notes",
@@ -541,7 +548,7 @@
}
},
"personnage": {
- "templates": [ "background", "common"]
+ "templates": [ "background", "common", "subacteurs" ]
},
"creature": {
"templates": [ "creature", "description" ]
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index d6cf48b8..35d3cac3 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -660,7 +660,7 @@
{{!-- Equipment Tab --}}
-
Argent et Monnaies -
+
Argent et Monnaies
{{#each data.monnaie as |piece id|}}
-
@@ -675,6 +675,8 @@
{{/each}}
+
+
Equipement porté
Encombrement total/max : {{numberFormat data.encTotal decimals=1}} / {{data.attributs.encombrement.value}} {{data.surEncombrementMessage}} -
Créer un objet
{{#if data.isGM}}
@@ -704,11 +706,53 @@
{{/if}}
{{/unless}}
- {{/each}}
+ {{/each}}
{{#each data.conteneurs as |conteneur id|}}
{{buildConteneur this}}
{{/each}}
+
+
Montures
+
+ {{#each data.monturesList as |monture id|}}
+ -
+
+ {{monture.name}}
+
+
+ {{/each}}
+
+
+
Véhicules
+
+ {{#each data.vehiculesList as |vehicule id|}}
+ -
+
+ {{vehicule.name}}
+ {{vehicule.categorie}}
+ {{vehicule.structure}}
+
+
+ {{/each}}
+
+
+
Suivants
+
+ {{#each data.suivantsList as |suivant id|}}
+ -
+
+ {{suivant.name}}
+
+
+ {{/each}}
+
+
{{!-- Biography Tab --}}