Utiliser EmbeddedDocuments
les méthodes Entity son deprecated/à ne plus utiliser
This commit is contained in:
parent
31204cbf51
commit
3735377a20
@ -681,7 +681,7 @@ export class RdDActor extends Actor {
|
||||
else
|
||||
update['data.carac_value'] = compValue;
|
||||
//console.log(update);
|
||||
const updated = await this.updateEmbeddedEntity("Item", update); // Updates one EmbeddedEntity
|
||||
const updated = await this.updateEmbeddedDocuments("Item", update); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
|
||||
@ -702,7 +702,7 @@ export class RdDActor extends Actor {
|
||||
});
|
||||
}
|
||||
const update = { _id: comp.id, 'data.niveau': nouveauNiveau };
|
||||
await this.updateEmbeddedEntity("Item", update); // Updates one EmbeddedEntity
|
||||
await this.updateEmbeddedDocuments("Item", update); // Updates one EmbeddedEntity
|
||||
} else {
|
||||
console.log("Competence not found", compName);
|
||||
}
|
||||
@ -715,7 +715,7 @@ export class RdDActor extends Actor {
|
||||
compValue = compValue ?? 0;
|
||||
this.checkCompetenceXP(compName, compValue);
|
||||
const update = { _id: comp.id, 'data.xp': compValue };
|
||||
await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
await this.updateEmbeddedDocuments("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
} else {
|
||||
console.log("Competence not found", compName);
|
||||
}
|
||||
@ -728,7 +728,7 @@ export class RdDActor extends Actor {
|
||||
if (comp) {
|
||||
compValue = compValue ?? 0;
|
||||
const update = { _id: comp.id, 'data.xp_sort': compValue };
|
||||
await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
await this.updateEmbeddedDocuments("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
} else {
|
||||
console.log("Competence not found", compName);
|
||||
}
|
||||
@ -740,7 +740,7 @@ export class RdDActor extends Actor {
|
||||
if (comp) {
|
||||
compValue = compValue ?? 0;
|
||||
const update = { _id: comp.id, 'data.niveau_archetype': compValue };
|
||||
await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
await this.updateEmbeddedDocuments("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
} else {
|
||||
console.log("Competence not found", compName);
|
||||
}
|
||||
@ -876,7 +876,7 @@ export class RdDActor extends Actor {
|
||||
contenu.splice(index, 1);
|
||||
index = contenu.indexOf(itemId);
|
||||
}
|
||||
await this.updateEmbeddedEntity("OwnedItem", data2use);
|
||||
await this.updateEmbeddedDocuments("OwnedItem", data2use);
|
||||
}
|
||||
}
|
||||
|
||||
@ -888,7 +888,7 @@ export class RdDActor extends Actor {
|
||||
if (conteneur?.type == 'conteneur') {
|
||||
let data2use = duplicate(Misc.data(conteneur));
|
||||
data2use.data.contenu.push(itemId);
|
||||
await this.updateEmbeddedEntity("OwnedItem", data2use);
|
||||
await this.updateEmbeddedDocuments("OwnedItem", data2use);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2071,7 +2071,7 @@ export class RdDActor extends Actor {
|
||||
async _tacheResult(rollData) {
|
||||
// Mise à jour de la tache
|
||||
rollData.tache.data.points_de_tache_courant += rollData.rolled.ptTache;
|
||||
this.updateEmbeddedEntity("OwnedItem", rollData.tache);
|
||||
this.updateEmbeddedDocuments("OwnedItem", rollData.tache);
|
||||
this.santeIncDec("fatigue", rollData.tache.data.fatigue);
|
||||
|
||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html');
|
||||
@ -2080,7 +2080,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
_tacheETotal(rollData) {
|
||||
rollData.tache.data.difficulte--;
|
||||
this.updateEmbeddedEntity("OwnedItem", rollData.tache);
|
||||
this.updateEmbeddedDocuments("OwnedItem", rollData.tache);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -2245,7 +2245,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
_meditationETotal(meditationData) {
|
||||
meditationData.meditation.data.malus--;
|
||||
this.updateEmbeddedEntity("OwnedItem", meditationData.meditation);
|
||||
this.updateEmbeddedDocuments("OwnedItem", meditationData.meditation);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -2348,7 +2348,7 @@ export class RdDActor extends Actor {
|
||||
xpComp = xp - xpCarac;
|
||||
competence = duplicate(competence);
|
||||
competence.data.xp = Misc.toInt(competence.data.xp) + xpComp;
|
||||
await this.updateEmbeddedEntity("OwnedItem", competence);
|
||||
await this.updateEmbeddedDocuments("OwnedItem", competence);
|
||||
} else {
|
||||
xpCarac = Math.max(xpCarac, 1);
|
||||
}
|
||||
@ -2382,12 +2382,12 @@ export class RdDActor extends Actor {
|
||||
name: "Nombre Astral", type: "nombreastral", data:
|
||||
{ value: data.nbAstral, istrue: data.isvalid, jourindex: Number(data.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex(Number(data.date)) }
|
||||
};
|
||||
await this.createEmbeddedEntity("OwnedItem", item);
|
||||
await this.createEmbeddedDocuments("OwnedItem", [item]);
|
||||
|
||||
// Suppression des anciens nombres astraux
|
||||
let toDelete = this.data.items.filter(it => it.data.jourindex < game.system.rdd.calendrier.getCurrentDayIndex());
|
||||
const deletions = toDelete.map(it => it._id);
|
||||
await this.deleteEmbeddedEntity("OwnedItem", deletions);
|
||||
await this.deleteEmbeddedDocuments("OwnedItem", deletions);
|
||||
|
||||
// Affichage Dialog
|
||||
this.astrologieNombresAstraux();
|
||||
@ -2551,7 +2551,7 @@ export class RdDActor extends Actor {
|
||||
let itemData = Misc.itemData(item);
|
||||
const isEquipe = !itemData.data.equipe;
|
||||
let update = { _id: item._id, "data.equipe": isEquipe };
|
||||
await this.updateEmbeddedEntity("OwnedItem", update);
|
||||
await this.updateEmbeddedDocuments("OwnedItem", update);
|
||||
this.computeEncombrementTotalEtMalusArmure(); // Mise à jour encombrement
|
||||
this.computePrixTotalEquipement(); // Mis à jour du prix total de l'équipement
|
||||
if (isEquipe)
|
||||
@ -2608,7 +2608,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
ChatMessage.create({ content: "Votre armure s'est détériorée, elle protège maintenant de " + itemData.data.protection });
|
||||
}
|
||||
this.updateEmbeddedEntity("OwnedItem", itemData);
|
||||
this.updateEmbeddedDocuments("OwnedItem", itemData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -2862,7 +2862,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
for (const [valeur, nombre] of Object.entries(fortune)) {
|
||||
let piece = parValeur[valeur];
|
||||
await this.updateEmbeddedEntity("OwnedItem", { _id: piece._id, 'data.quantite': nombre });
|
||||
await this.updateEmbeddedDocuments("OwnedItem", { _id: piece._id, 'data.quantite': nombre });
|
||||
}
|
||||
}
|
||||
|
||||
@ -2912,7 +2912,7 @@ export class RdDActor extends Actor {
|
||||
let monnaie = this.getMonnaie(id);
|
||||
if (monnaie) {
|
||||
const quantite = Math.max(0, Misc.templateData(monnaie).quantite + value);
|
||||
await this.updateEmbeddedEntity("OwnedItem", { _id: monnaie.id, 'data.quantite': quantite });
|
||||
await this.updateEmbeddedDocuments("OwnedItem", { _id: monnaie.id, 'data.quantite': quantite });
|
||||
}
|
||||
}
|
||||
|
||||
@ -3140,11 +3140,11 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateEmbeddedEntity(embeddedName, data, options) {
|
||||
if (data && data['data.defaut_carac'] && data['data.xp']) { // C'est une compétence
|
||||
async updateEmbeddedDocuments(embeddedName, data, options) {
|
||||
if (data?.type == 'competence' && data['data.defaut_carac'] && data['data.xp']) { // C'est une compétence
|
||||
this.checkCompetenceXP(data['name'], data['data.xp']);
|
||||
}
|
||||
return super.updateEmbeddedDocuments("Item", [data], options);
|
||||
return super.updateEmbeddedDocuments(embeddedName, [data], options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -106,7 +106,7 @@ export class RdDItemSort extends Item {
|
||||
// Sauvegarde/update
|
||||
let bonuscase = StringList.toString();
|
||||
//console.log("Bonus cae :", bonuscase);
|
||||
actor.updateEmbeddedEntity("OwnedItem", { _id: sort._id, 'data.bonuscase': bonuscase } );
|
||||
actor.updateEmbeddedDocuments("OwnedItem", { _id: sort._id, 'data.bonuscase': bonuscase } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -104,7 +104,7 @@ export class RdDCombatManager extends Combat {
|
||||
const roll = super._getInitiativeRoll(c, rollFormula);
|
||||
if (roll.total <= 0) roll.total = 0.00;
|
||||
console.log("Compute init for", rollFormula, roll.total);
|
||||
await this.updateEmbeddedEntity("Combatant", { _id: c._id, initiative: roll.total });
|
||||
await this.updateEmbeddedDocuments("Combatant", { _id: c._id, initiative: roll.total });
|
||||
|
||||
// Send a chat message
|
||||
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
|
||||
@ -1130,7 +1130,7 @@ export class RdDCombat {
|
||||
resistance -= perteResistance;
|
||||
defenderRoll.show.deteriorationArme = resistance <= 0 ? 'brise' : 'perte';
|
||||
defenderRoll.show.perteResistance = perteResistance;
|
||||
this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance });
|
||||
this.defender.updateEmbeddedDocuments("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1147,7 +1147,7 @@ export class RdDCombat {
|
||||
resistance -= dmg;
|
||||
defenderRoll.show.deteriorationArme = resistance <= 0 ? 'brise' : 'perte';
|
||||
defenderRoll.show.perteResistance = dmg;
|
||||
this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance });
|
||||
this.defender.updateEmbeddedDocuments("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance });
|
||||
}
|
||||
}
|
||||
// Si l'arme de parade n'est pas un bouclier, jet de désarmement (p.132)
|
||||
|
Loading…
Reference in New Issue
Block a user