forked from public/foundryvtt-reve-de-dragon
		
	#191 - Ajout de la commande stress
This commit is contained in:
		| @@ -872,6 +872,12 @@ export class RdDActor extends Actor { | ||||
|     await this.update({ [`data.compteurs.${fieldName}.value`]: fieldValue }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async addCompteurValue(fieldName, fieldValue) { | ||||
|     let oldValue = (Misc.templateData(this)).compteurs[fieldName].value; | ||||
|     await this.update({ [`data.compteurs.${fieldName}.value`]: Number(oldValue) + Number(fieldValue) } ); | ||||
|   } | ||||
|    | ||||
|   /* -------------------------------------------- */ | ||||
|   async updateAttributeValue(fieldName, fieldValue) { | ||||
|     await this.update({ [`data.attributs.${fieldName}.value`]: fieldValue }); | ||||
| @@ -1245,7 +1251,7 @@ export class RdDActor extends Actor { | ||||
|   } | ||||
|   /* -------------------------------------------- */ | ||||
|   async cacheTMRetMessage() { | ||||
|     await this.reinsertionAleatoire(); | ||||
|     await this.reinsertionAleatoire("Action MJ"); | ||||
|     await this.cacheTMR(); | ||||
|     game.socket.emit("system.foundryvtt-reve-de-dragon", { | ||||
|       msg: "msg_tmr_move", data: { | ||||
| @@ -2877,7 +2883,6 @@ export class RdDActor extends Actor { | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   refreshTMRView(tmrData) { | ||||
|     console.log("REFRESH !!!!"); | ||||
|     if (this.currentTMR) { | ||||
|       this.currentTMR.externalRefresh(tmrData) | ||||
|     } | ||||
|   | ||||
| @@ -94,6 +94,14 @@ export class RdDCommands { | ||||
|         descr: "Supprime les signes draconiques éphémères" | ||||
|       }); | ||||
|  | ||||
|       rddCommands.registerCommand({ | ||||
|         path: ["/stress"], func: (content, msg, params) => RdDUtility.distribuerStress(params[0], params[1], params[2]), | ||||
|         descr: `Distribue du stress aux personnages. Exemples: | ||||
|           <br><strong>/stress 6</strong> : Distribue 6 points des Stress à tout les personnages joueurs, sans raison renseignée | ||||
|           <br><strong>/stress 6 Tigre</strong> : Distribue 6 points des Stress à tout les personnages joueurs, à cause d'un Tigre Vert | ||||
|           <br><strong>/stress 6 Glou Paulo</strong> : Distribue 6 points de Stres à l'acteur connecté au joueur Paulo, à cause d'un Glou` | ||||
|       }); | ||||
|  | ||||
|       game.system.rdd.commands = rddCommands; | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -779,6 +779,28 @@ export class RdDUtility { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /*-------------------------------------------- */ | ||||
|   static distribuerStress( stressValue, raison = 'Inconnu', nomJoueur = undefined) { | ||||
|     if (game.user.isGM) { | ||||
|       if( nomJoueur == undefined) { | ||||
|         for (let actor of game.actors) { | ||||
|           if (actor.hasPlayerOwner) { | ||||
|             actor.addCompteurValue('stress', stressValue); | ||||
|             ui.notifications.info(`${actor.name} a reçu ${stressValue} points de Stress (raison : ${raison})`); | ||||
|           } | ||||
|         } | ||||
|       } else { | ||||
|         //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); | ||||
|         ui.notifications.info(`${joueur.character.name} a reçu ${stressValue} points de Stress (raison : ${raison})`); | ||||
|       } | ||||
|     } else { | ||||
|       ui.notifications.warn("Seul le MJ est autorisé à utiliser la commande /stress"); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /*-------------------------------------------- */ | ||||
|   static async onRenderChatMessage(app, html, msg) { | ||||
|     // TODO  | ||||
|   | ||||
| @@ -2,11 +2,11 @@ | ||||
|   "name": "foundryvtt-reve-de-dragon", | ||||
|   "title": "Rêve de Dragon", | ||||
|   "description": "Rêve de Dragon RPG for FoundryVTT", | ||||
|   "version": "1.4.4", | ||||
|   "version": "1.4.6", | ||||
|   "manifestPlusVersion": "1.0.0", | ||||
|   "minimumCoreVersion": "0.8.0", | ||||
|   "compatibleCoreVersion": "0.8.1", | ||||
|   "templateVersion": 114, | ||||
|   "templateVersion": 115, | ||||
|   "author": "LeRatierBretonnien", | ||||
|   "authors": [ | ||||
|     {  | ||||
|   | ||||
| @@ -24,7 +24,8 @@ | ||||
|       "sexe": "", | ||||
|       "age": 0, | ||||
|       "beaute": 10, | ||||
|       "main": "droitier" | ||||
|       "main": "droitier", | ||||
|       "experiencelog": [] | ||||
|     }, | ||||
|     "vehicule": { | ||||
|       "categorie": "", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user