#191 - Ajout de la commande stress
This commit is contained in:
parent
3621a4e09d
commit
04d631e2b4
@ -868,14 +868,30 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompteurValue(fieldName, fieldValue) {
|
||||
await this.update({ [`data.compteurs.${fieldName}.value`]: fieldValue });
|
||||
async updateExperienceLog( mode, valeur, raison) {
|
||||
let d = new Date();
|
||||
let expLog = duplicate( (Misc.templateData(this)).experiencelog );
|
||||
expLog.push( { mode: Misc.upperFirst(mode), valeur: valeur, raison: Misc.upperFirst(raison),
|
||||
daterdd : game.system.rdd.calendrier.getDateFromIndex(), datereel: `${d.getDate()}/${d.getMonth()+1}/${d.getFullYear()}` } );
|
||||
await this.update({ [`data.experiencelog`]: expLog } );
|
||||
console.log("Add XP log", expLog);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addCompteurValue(fieldName, fieldValue) {
|
||||
async updateCompteurValue(fieldName, fieldValue, raison = 'Inconnue') {
|
||||
await this.update({ [`data.compteurs.${fieldName}.value`]: fieldValue });
|
||||
if ( fieldName == 'stress') {
|
||||
await this.updateExperienceLog('stress', raison, fieldValue);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addCompteurValue(fieldName, fieldValue, raison = 'Inconnue') {
|
||||
let oldValue = (Misc.templateData(this)).compteurs[fieldName].value;
|
||||
await this.update({ [`data.compteurs.${fieldName}.value`]: Number(oldValue) + Number(fieldValue) } );
|
||||
if ( fieldName == 'stress') {
|
||||
await this.updateExperienceLog('stress', raison, fieldValue);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -785,7 +785,7 @@ export class RdDUtility {
|
||||
if( nomJoueur == undefined) {
|
||||
for (let actor of game.actors) {
|
||||
if (actor.hasPlayerOwner) {
|
||||
actor.addCompteurValue('stress', stressValue);
|
||||
actor.addCompteurValue('stress', stressValue, raison);
|
||||
ui.notifications.info(`${actor.name} a reçu ${stressValue} points de Stress (raison : ${raison})`);
|
||||
}
|
||||
}
|
||||
@ -793,7 +793,7 @@ export class RdDUtility {
|
||||
//console.log(stressValue, nomJoueur);
|
||||
let joueur = game.users.find( user => user.name.toLowerCase() == nomJoueur.toLowerCase() );
|
||||
//console.log("Player", joueur, joueur.character );
|
||||
joueur.character.addCompteurValue('stress', stressValue);
|
||||
joueur.character.addCompteurValue('stress', stressValue, raison);
|
||||
ui.notifications.info(`${joueur.character.name} a reçu ${stressValue} points de Stress (raison : ${raison})`);
|
||||
}
|
||||
} else {
|
||||
|
@ -726,6 +726,21 @@
|
||||
<div class="form-group editor">
|
||||
{{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
<h3>Journal d'Experience</h3>
|
||||
<div class="form-group editor">
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.experiencelog as |xp key|}}
|
||||
<li class="item flexrow list-item">
|
||||
<label class="description-label competence-label">{{xp.mode}} </label>
|
||||
<label class="description-label competence-label">{{xp.valeur}} </label>
|
||||
<label class="description-label competence-label">{{xp.raison}} </label>
|
||||
<label class="description-label competence-label">{{xp.daterdd}} </label>
|
||||
<label class="description-label competence-label">{{xp.datereel}} </label>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{{>"systems/foundryvtt-reve-de-dragon/templates/actor-sheet-editor-notes-mj.html"}}
|
||||
</article>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user