Suppression de sorts en réserve
This commit is contained in:
parent
1251d04860
commit
2232224951
@ -15,6 +15,7 @@ import { DialogSplitItem } from "./dialog-split-item.js";
|
|||||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||||
import { DialogRepos } from "./dialog-repos.js";
|
import { DialogRepos } from "./dialog-repos.js";
|
||||||
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
||||||
|
import { TMRUtility } from "./tmr-utility.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class RdDActorSheet extends ActorSheet {
|
export class RdDActorSheet extends ActorSheet {
|
||||||
@ -180,7 +181,21 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
});
|
});
|
||||||
html.find('.item-delete').click(async event => {
|
html.find('.item-delete').click(async event => {
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
RdDUtility.confirmerSuppression(this, li);
|
const item = this.actor.getObjet(li.data("item-id"));
|
||||||
|
RdDUtility.confirmerSuppressionItem(this, item, li);
|
||||||
|
});
|
||||||
|
html.find('.sort-reserve-delete').click(async event => {
|
||||||
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
|
const index = li.data('index');
|
||||||
|
const sortReserve = this.actor.system.reve.reserve.list[index];
|
||||||
|
RdDUtility.confirmerSuppression(this, li, {
|
||||||
|
supprimer: `le sort en réserve ${sortReserve.sort.name} en ${TMRUtility.getTMR(sortReserve.coord).label}`,
|
||||||
|
deleteLabel: "Supprimer le sort en réserve",
|
||||||
|
onDelete: () => {
|
||||||
|
console.log("Delete : ", sortReserve.name);
|
||||||
|
this.actor.deleteSortReserveKey(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
html.find('.item-vendre').click(async event => {
|
html.find('.item-vendre').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
@ -197,7 +212,11 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
});
|
});
|
||||||
html.find('.subacteur-delete').click(async event => {
|
html.find('.subacteur-delete').click(async event => {
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
RdDUtility.confirmerSuppressionSubacteur(this, li);
|
const actorId = li.data("actor-id");
|
||||||
|
if (actorId) {
|
||||||
|
const subActor = game.actors.get(actorId);
|
||||||
|
RdDUtility.confirmerSuppressionSubacteur(this, subActor, li);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('.encaisser-direct').click(async event => {
|
html.find('.encaisser-direct').click(async event => {
|
||||||
|
@ -104,7 +104,8 @@ export class RdDActorVehiculeSheet extends ActorSheet {
|
|||||||
// Delete Inventory Item
|
// Delete Inventory Item
|
||||||
html.find('.item-delete').click(async event => {
|
html.find('.item-delete').click(async event => {
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
RdDUtility.confirmerSuppression(this, li);
|
const item = this.actor.getObjet(li.data("item-id"));
|
||||||
|
RdDUtility.confirmerSuppressionItem(this, item, li);
|
||||||
});
|
});
|
||||||
html.find('.item-vendre').click(async event => {
|
html.find('.item-vendre').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
@ -432,6 +432,14 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteSortReserveKey(index) {
|
||||||
|
let reserve = duplicate(this.system.reve.reserve);
|
||||||
|
if (index >= 0) {
|
||||||
|
reserve.list.splice(index, 1);
|
||||||
|
await this.update({ "system.reve.reserve": reserve }, { renderSheet: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSurprise(isCombat = undefined) {
|
getSurprise(isCombat = undefined) {
|
||||||
let niveauSurprise = this.getActiveEffects()
|
let niveauSurprise = this.getActiveEffects()
|
||||||
@ -3926,9 +3934,9 @@ export class RdDActor extends Actor {
|
|||||||
let newVehicules = this.system.subacteurs.vehicules.filter(function (obj, index, arr) { return obj.id != actorId });
|
let newVehicules = this.system.subacteurs.vehicules.filter(function (obj, index, arr) { return obj.id != actorId });
|
||||||
let newSuivants = this.system.subacteurs.suivants.filter(function (obj, index, arr) { return obj.id != actorId });
|
let newSuivants = this.system.subacteurs.suivants.filter(function (obj, index, arr) { return obj.id != actorId });
|
||||||
let newMontures = this.system.subacteurs.montures.filter(function (obj, index, arr) { return obj.id != actorId });
|
let newMontures = this.system.subacteurs.montures.filter(function (obj, index, arr) { return obj.id != actorId });
|
||||||
await this.update({ 'system.subacteurs.vehicules': newVehicules });
|
await this.update({ 'system.subacteurs.vehicules': newVehicules }, { renderSheet: false });
|
||||||
await this.update({ 'system.subacteurs.suivants': newSuivants });
|
await this.update({ 'system.subacteurs.suivants': newSuivants }, { renderSheet: false });
|
||||||
await this.update({ 'system.subacteurs.montures': newMontures });
|
await this.update({ 'system.subacteurs.montures': newMontures }, { renderSheet: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -197,7 +197,8 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
});
|
});
|
||||||
html.find('.item-delete').click(async event => {
|
html.find('.item-delete').click(async event => {
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
RdDUtility.confirmerSuppression(this, li);
|
const item = this.actor.getObjet(li.data("item-id"));
|
||||||
|
RdDUtility.confirmerSuppressionItem(this, item, li);
|
||||||
});
|
});
|
||||||
html.find('.item-vendre').click(async event => {
|
html.find('.item-vendre').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
@ -831,21 +831,17 @@ export class RdDUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static confirmerSuppressionSubacteur(actorSheet, li) {
|
static confirmerSuppression(sheet, htmlToDelete, options) {
|
||||||
let actorId = li.data("actor-id");
|
const d = new Dialog({
|
||||||
let actor = game.actors.get(actorId);
|
title: options.title ?? 'Confirmer la suppression',
|
||||||
let msgTxt = "<p>Etes vous certain de vouloir supprimer le lien vers ce véhicule/monture/suivant : " + actor.name + " ?</p>";
|
content: `<p>Etes vous certain de vouloir supprimer ${options.supprimer ?? 'cet objet'} ?</p>`,
|
||||||
let d = new Dialog({
|
|
||||||
title: "Confirmer la suppression du lien",
|
|
||||||
content: msgTxt,
|
|
||||||
buttons: {
|
buttons: {
|
||||||
delete: {
|
delete: {
|
||||||
icon: '<i class="fas fa-check"></i>',
|
icon: '<i class="fas fa-check"></i>',
|
||||||
label: "Supprimer le lien",
|
label: options.deleteLabel ?? 'Supprimer',
|
||||||
callback: () => {
|
callback: () => {
|
||||||
console.log("Delete : ", actorId);
|
options.onDelete();
|
||||||
actorSheet.actor.removeSubacteur(actorId);
|
RdDUtility.slideOnDelete(sheet, htmlToDelete);
|
||||||
li.slideUp(200, () => actorSheet.render(false));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cancel: {
|
cancel: {
|
||||||
@ -859,11 +855,21 @@ export class RdDUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async confirmerSuppression(actorSheet, li) {
|
static confirmerSuppressionSubacteur(sheet, subActor, htmlToDelete) {
|
||||||
let itemId = li.data("item-id");
|
RdDUtility.confirmerSuppression(sheet, htmlToDelete,{
|
||||||
let objet = actorSheet.actor.getObjet(itemId);
|
supprimer: "le lien vers le véhicule/monture/suivant : " + subActor.name,
|
||||||
|
deleteLabel: "Supprimer le lien",
|
||||||
|
onDelete: () => {
|
||||||
|
console.log("Delete : ", subActor.id);
|
||||||
|
sheet.actor.removeSubacteur(subActor.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (Monnaie.isSystemMonnaie(objet, actorSheet.actor.items)) {
|
/* -------------------------------------------- */
|
||||||
|
static async confirmerSuppressionItem(sheet, item, htmlToDelete) {
|
||||||
|
const itemId = item.id;
|
||||||
|
if (Monnaie.isSystemMonnaie(item, sheet.actor.items)) {
|
||||||
ui.notifications.warn("Suppression des monnaies de base impossible");
|
ui.notifications.warn("Suppression des monnaies de base impossible");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -875,8 +881,8 @@ export class RdDUtility {
|
|||||||
label: "Supprimer l'objet",
|
label: "Supprimer l'objet",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
console.log("Delete : ", itemId);
|
console.log("Delete : ", itemId);
|
||||||
actorSheet.actor.deleteEmbeddedDocuments('Item', [itemId]);
|
sheet.actor.deleteEmbeddedDocuments('Item', [itemId]);
|
||||||
li.slideUp(200, () => actorSheet.render(false));
|
RdDUtility.slideOnDelete(sheet, htmlToDelete);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cancel: {
|
cancel: {
|
||||||
@ -884,15 +890,15 @@ export class RdDUtility {
|
|||||||
label: "Annuler"
|
label: "Annuler"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (objet.type == 'conteneur' && objet.system.contenu.length > 0) {
|
if (item.type == 'conteneur' && item.system.contenu.length > 0) {
|
||||||
msgTxt += "<br>Ce conteneur n'est pas vide. Choisissez l'option de suppression";
|
msgTxt += "<br>Ce conteneur n'est pas vide. Choisissez l'option de suppression";
|
||||||
buttons['deleteall'] = {
|
buttons['deleteall'] = {
|
||||||
icon: '<i class="fas fa-check"></i>',
|
icon: '<i class="fas fa-check"></i>',
|
||||||
label: "Supprimer le conteneur et tout son contenu",
|
label: "Supprimer le conteneur et tout son contenu",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
console.log("Delete : ", itemId);
|
console.log("Delete : ", itemId);
|
||||||
actorSheet.actor.deleteAllConteneur(itemId);
|
sheet.actor.deleteAllConteneur(itemId);
|
||||||
li.slideUp(200, () => actorSheet.render(false));
|
RdDUtility.slideOnDelete(sheet, htmlToDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -906,6 +912,10 @@ export class RdDUtility {
|
|||||||
d.render(true);
|
d.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static slideOnDelete(sheet, htmlToDelete) {
|
||||||
|
return htmlToDelete.slideUp(200, () => sheet.render(false));
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static afficherHeuresChanceMalchance(heureNaissance) {
|
static afficherHeuresChanceMalchance(heureNaissance) {
|
||||||
if (game.user.isGM) {
|
if (game.user.isGM) {
|
||||||
|
@ -574,12 +574,12 @@
|
|||||||
<h3>Sorts en Réserve:</h3>
|
<h3>Sorts en Réserve:</h3>
|
||||||
<ul class="item-list alterne-list">
|
<ul class="item-list alterne-list">
|
||||||
{{#each hautreve.sortsReserve as |reserve key|}}
|
{{#each hautreve.sortsReserve as |reserve key|}}
|
||||||
<li class="item list-item flexrow" data-item-id="{{reserve._id}}" data-attribute="{{key}}">
|
<li class="item list-item flexrow" data-index="{{key}}">
|
||||||
<img class="sheet-competence-img" src="{{reserve.sort.img}}" />
|
<img class="sheet-competence-img" src="{{reserve.sort.img}}" />
|
||||||
<span class="display-label">{{reserve.sort.name}} r{{reserve.sort.system.ptreve_reel}}</span>
|
<span class="display-label">{{reserve.sort.name}} r{{reserve.sort.system.ptreve_reel}}</span>
|
||||||
<span>{{reserve.coord}} - {{caseTmr-label reserve.coord}}</span>
|
<span>{{reserve.coord}} - {{caseTmr-label reserve.coord}}</span>
|
||||||
<div class="item-controls flex-shrink">
|
<div class="item-controls flex-shrink">
|
||||||
<a class="item-delete flex-shrink" title="Supprimer"><i class="fas fa-trash"></i></a>
|
<a class="sort-reserve-delete flex-shrink" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
Loading…
Reference in New Issue
Block a user