Gestion preliminaire de l'XP
This commit is contained in:
@ -272,6 +272,7 @@ export class RdDActor extends Actor {
|
||||
data: defenseMsg
|
||||
} );
|
||||
} else {
|
||||
defenseMsg.whisper = [ game.user];
|
||||
ChatMessage.create( defenseMsg );
|
||||
}
|
||||
}
|
||||
@ -294,7 +295,26 @@ export class RdDActor extends Actor {
|
||||
{
|
||||
let comp = RdDUtility.findCompetence( this.data.items, compName);
|
||||
if ( comp ) {
|
||||
const update = {_id: comp._id, 'data.niveau': compValue };
|
||||
let troncList = RdDUtility.isTronc( compName );
|
||||
let maxNiveau = compValue;
|
||||
if ( troncList ) {
|
||||
let troncCompValue = (compValue > 0) ? 0 : compValue; // Clamp it to 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;
|
||||
}
|
||||
}
|
||||
const update = {_id: comp._id, 'data.niveau': maxNiveau };
|
||||
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
} else {
|
||||
console.log("Competence not found", compName);
|
||||
|
Reference in New Issue
Block a user