Merge branch 'v1.4-fix' into 'v1.4'

Fix: commandes /rdd

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!260
This commit is contained in:
Leratier Bretonnien 2021-05-29 21:35:36 +00:00
commit 8e7835c44d
4 changed files with 17 additions and 4 deletions

View File

@ -172,6 +172,7 @@ export class RdDActor extends Actor {
// Initialize empty items // Initialize empty items
RdDCarac.computeCarac(actorData.data); RdDCarac.computeCarac(actorData.data);
this.computeIsHautRevant(); this.computeIsHautRevant();
await this.cleanupConteneurs();
await this.computeEncombrementTotalEtMalusArmure(); await this.computeEncombrementTotalEtMalusArmure();
this.computePrixTotalEquipement(); this.computePrixTotalEquipement();
this.computeEtatGeneral(); this.computeEtatGeneral();
@ -179,6 +180,16 @@ export class RdDActor extends Actor {
await this.checkMonnaiePresence(actorData.items); await this.checkMonnaiePresence(actorData.items);
} }
/* -------------------------------------------- */
async cleanupConteneurs() {
let updates = this.listItemsData('conteneur')
.filter(c => c.data.contenu.filter(id => this.getObjet(id) == undefined).length > 0)
.map(c => { return { _id: c._id, 'data.contenu': c.data.contenu.filter(id => this.getObjet(id) != undefined) } });
if (updates.length > 0) {
await this.updateEmbeddedDocuments("Item", updates)
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async checkMonnaiePresence(items) { // Ajout opportuniste si les pièces n'existent pas. async checkMonnaiePresence(items) { // Ajout opportuniste si les pièces n'existent pas.
if (!items) return; // Sanity check during import if (!items) return; // Sanity check during import
@ -4060,7 +4071,7 @@ export class RdDActor extends Actor {
notifyGestionTeteSouffleQueue(item, manualMessage = true) { notifyGestionTeteSouffleQueue(item, manualMessage = true) {
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
content: `${this.name} a reçu un/une ${item.type}: ${item.name}, qui ${manualMessage ? "n'est pas" : "est"} géré automatiquement. ${manualMessage ?? ''}` content: `${this.name} a reçu un/une ${item.type}: ${item.name}, qui ${manualMessage ? "n'est pas" : "est"} géré(e) automatiquement. ${manualMessage ? manualMessage : ''}`
}); });
} }
} }

View File

@ -13,7 +13,7 @@ import { RdDUtility } from "./rdd-utility.js";
import { TMRRencontres } from "./tmr-rencontres.js"; import { TMRRencontres } from "./tmr-rencontres.js";
import { TMRUtility } from "./tmr-utility.js"; import { TMRUtility } from "./tmr-utility.js";
const rddRollNumeric = /$(\d+)\s*([\+\-]?\d+)?\s*(s)?/; const rddRollNumeric = /^(\d+)\s*([\+\-]?\d+)?\s*(s)?/;
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDCommands { export class RdDCommands {

View File

@ -29,6 +29,7 @@ export class RdDRollResolutionTable extends Dialog {
finalLevel: 0, finalLevel: 0,
diffConditions: 0, diffConditions: 0,
diffLibre: 0, diffLibre: 0,
use: { conditions:true, libre:true }
} }
mergeObject(rollData, defRollData, { overwrite: false }); mergeObject(rollData, defRollData, { overwrite: false });
for (let i = 1; i < 21; i++) { for (let i = 1; i < 21; i++) {

View File

@ -357,7 +357,8 @@ export class RdDUtility {
static calculEncContenu(conteneur, objets) { static calculEncContenu(conteneur, objets) {
const itemData = Misc.data(conteneur); const itemData = Misc.data(conteneur);
const contenuDatas = (itemData.data.contenu ?? []).filter(id => id != undefined) const contenuDatas = (itemData.data.contenu ?? []).filter(id => id != undefined)
.map(id => Misc.data(objets.find(it => (id == it._id)))); .map(id => Misc.data(objets.find(it => (id == it._id))))
.filter(it => it);
let enc = Number(itemData.data.encombrement ?? 0) * Number(itemData.data.quantite ?? 1); let enc = Number(itemData.data.encombrement ?? 0) * Number(itemData.data.quantite ?? 1);
for (let itemData of contenuDatas){ for (let itemData of contenuDatas){
if (itemData.type == 'conteneur') { if (itemData.type == 'conteneur') {