This commit is contained in:
2020-09-05 22:56:33 +02:00
parent 4a5beeea36
commit b7471e0c97
4 changed files with 13 additions and 16 deletions

View File

@ -298,21 +298,12 @@ export class RdDActor extends Actor {
let troncList = RdDUtility.isTronc( compName );
let maxNiveau = compValue;
if ( troncList ) {
let troncCompValue = (compValue > 0) ? 0 : compValue; // Clamp it to 0
let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : ";
for(let troncName of troncList) {
if ( troncName != compName) {
console.log("Update competence tronc", troncName, compValue);
let comp2 = RdDUtility.findCompetence( this.data.items, troncName);
if (comp2.data.niveau > maxNiveau) maxNiveau = comp2.data.niveau;
if ( comp2.data.niveau <= 0 && comp2.data.niveau < troncCompValue ) { // Update only of below 0
const update = {_id: comp2._id, 'data.niveau': compValue };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
}
}
}
if ( compValue < maxNiveau) { // Manage case when someone set a value below
compValue = (maxNiveau > 0) ? 0 : maxNiveau;
message += "<br>" + troncName;
}
ChatMessage.create( { title : "Compétence Tron",
content: message } );
}
const update = {_id: comp._id, 'data.niveau': maxNiveau };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity