#122 Gestion d'acturs liés à une fiche de perso
This commit is contained in:
parent
e54de9f080
commit
d02b5ac88c
@ -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 = "<p>Etes vous certain de vouloir supprimer cet objet ?";
|
||||
let buttons = { delete: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Supprimer l'objet",
|
||||
callback: () => {
|
||||
console.log("Delete : ", itemId);
|
||||
this.actor.deleteOwnedItem( itemId );
|
||||
li.slideUp(200, () => this.render(false));
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Annuler"
|
||||
}
|
||||
}
|
||||
if ( objet.data.type == 'conteneur' && objet.data.data.contenu.length > 0) {
|
||||
msgTxt += "<br>Cet objet est aussi un conteneur avec du contenu : choisissez l'option de suppression";
|
||||
buttons['deleteall'] = {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Supprimer le conteneur et tout son contenu",
|
||||
callback: () => {
|
||||
console.log("Delete : ", itemId);
|
||||
this.actor.deleteAllConteneur( itemId );
|
||||
li.slideUp(200, () => this.render(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
msgTxt += "</p>";
|
||||
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,7 +191,11 @@ 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 => {
|
||||
@ -314,6 +280,14 @@ 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) => {
|
||||
|
@ -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
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -838,4 +842,75 @@ export class RdDUtility {
|
||||
|
||||
return chatData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static confirmerSuppressionSubacteur(actorSheet, li ) {
|
||||
let actorId = li.data("actor-id");
|
||||
let actor = game.actors.get( actorId );
|
||||
let msgTxt = "<p>Etes vous certain de vouloir supprimer le lien vers ce véhicule/monture/suivant : " + actor.data.name +" ?</p>";
|
||||
let buttons = {
|
||||
delete: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Supprimer le lien",
|
||||
callback: () => {
|
||||
console.log("Delete : ", actorId);
|
||||
actorSheet.actor.removeSubacteur( actorId );
|
||||
li.slideUp(200, () => actorSheet.render(false));
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
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 = "<p>Etes vous certain de vouloir supprimer cet objet ?";
|
||||
let buttons = { delete: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Supprimer l'objet",
|
||||
callback: () => {
|
||||
console.log("Delete : ", itemId);
|
||||
actorSheet.actor.deleteOwnedItem( itemId );
|
||||
li.slideUp(200, () => actorSheet.render(false));
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Annuler"
|
||||
}
|
||||
}
|
||||
if ( objet.data.type == 'conteneur' && objet.data.data.contenu.length > 0) {
|
||||
msgTxt += "<br>Cet objet est aussi un conteneur avec du contenu : choisissez l'option de suppression";
|
||||
buttons['deleteall'] = {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Supprimer le conteneur et tout son contenu",
|
||||
callback: () => {
|
||||
console.log("Delete : ", itemId);
|
||||
actorSheet.actor.deleteAllConteneur( itemId );
|
||||
li.slideUp(200, () => actorSheet.render(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
msgTxt += "</p>";
|
||||
let d = new Dialog({
|
||||
title: "Confirmer la suppression",
|
||||
content: msgTxt,
|
||||
buttons: buttons,
|
||||
default: "cancel"
|
||||
});
|
||||
d.render(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -647,6 +647,7 @@ ul, li {
|
||||
.competence-label,
|
||||
.astrologie-label,
|
||||
.tache-label,
|
||||
.subacteur-label,
|
||||
.description-label {
|
||||
flex-grow: 2;
|
||||
}
|
||||
|
@ -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"],
|
||||
|
@ -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" ]
|
||||
|
@ -660,7 +660,7 @@
|
||||
|
||||
{{!-- Equipment Tab --}}
|
||||
<div class="tab items" data-group="primary" data-tab="items">
|
||||
<span class="item-name">Argent et Monnaies</b></span> -
|
||||
<span class="item-name"><h4>Argent et Monnaies</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.monnaie as |piece id|}}
|
||||
<li class="item flexrow list-item" data-item-id="{{piece._id}}">
|
||||
@ -675,6 +675,8 @@
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<span class="item-name"><h4>Equipement porté</h4></span>
|
||||
<span class="item-name">Encombrement total/max : {{numberFormat data.encTotal decimals=1}} / {{data.attributs.encombrement.value}} <b>{{data.surEncombrementMessage}}</b></span> -
|
||||
<span class="item-name"><a id="creer-un-objet">Créer un objet</a></span>
|
||||
{{#if data.isGM}}
|
||||
@ -704,11 +706,53 @@
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
{{#each data.conteneurs as |conteneur id|}}
|
||||
{{buildConteneur this}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<span class="item-name"><h4>Montures</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.monturesList as |monture id|}}
|
||||
<li class="item flexrow list-item" data-actor-id="{{monture.id}}">
|
||||
<img class="sheet-competence-img" src="{{monture.img}}" title="{{monture.name}}"/>
|
||||
<span class="competence-title subacteur-label"><a>{{monture.name}}</a></span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control subacteur-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<span class="item-name"><h4>Véhicules</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.vehiculesList as |vehicule id|}}
|
||||
<li class="item flexrow list-item" data-actor-id="{{vehicule.id}}">
|
||||
<img class="sheet-competence-img" src="{{vehicule.img}}" title="{{vehicule.name}}"/>
|
||||
<span class="competence-title subacteur-label"><a>{{vehicule.name}}</a></span>
|
||||
<span class="competence-title">{{vehicule.categorie}}</span>
|
||||
<span class="competence-title">{{vehicule.structure}}</span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control subacteur-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<span class="item-name"><h4>Suivants</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.suivantsList as |suivant id|}}
|
||||
<li class="item flexrow list-item" data-actor-id="{{suivant.id}}">
|
||||
<img class="sheet-competence-img" src="{{suivant.img}}" title="{{suivant.name}}"/>
|
||||
<span class="competence-title subacteur-label"><a>{{suivant.name}}</a></span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control subacteur-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
{{!-- Biography Tab --}}
|
||||
|
Loading…
Reference in New Issue
Block a user