Gestion des signes draconiques #455
| @@ -257,11 +257,11 @@ export class RdDActorSheet extends ActorSheet { | ||||
|       const li = $(ev.currentTarget).parents(".item"); | ||||
|       RdDUtility.confirmerSuppression(this, li); | ||||
|     }); | ||||
|     html.find('.item-consommer').click(ev => { | ||||
|     html.find('.item-action').click(ev => { | ||||
|       const li = $(ev.currentTarget).parents(".item"); | ||||
|       const itemId = li.data("item-id"); | ||||
|       const item = this.actor.getObjet(itemId); | ||||
|       this.actor.consommerDialog(item); | ||||
|       this.actor.actionItem(item); | ||||
|     }); | ||||
|     html.find('.subacteur-delete').click(ev => { | ||||
|       const li = $(ev.currentTarget).parents(".item"); | ||||
|   | ||||
| @@ -27,7 +27,6 @@ import { EffetsDraconiques } from "./tmr/effets-draconiques.js"; | ||||
| import { Draconique } from "./tmr/draconique.js"; | ||||
| import { RdDCarac } from "./rdd-carac.js"; | ||||
| import { Monnaie } from "./item-monnaie.js"; | ||||
| import { RdDHerbes } from "./rdd-herbes.js"; | ||||
| import { DialogConsommer } from "./dialog-consommer.js"; | ||||
| import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; | ||||
|  | ||||
| @@ -313,7 +312,7 @@ export class RdDActor extends Actor { | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async verifierPotionsEnchantees() { | ||||
|     let potionsEnchantees = this.filterItemsData(it => it.type == 'potion' && it.data.categorie.toLowerCase().includes('enchante')); | ||||
|     let potionsEnchantees = this.filterItemsData(it => it.type == 'potion' && it.data.isEnchante); | ||||
|     for (let potion of potionsEnchantees) { | ||||
|       if (!potion.prpermanent) { | ||||
|         console.log(potion); | ||||
| @@ -743,7 +742,6 @@ export class RdDActor extends Actor { | ||||
|   /* -------------------------------------------- */ | ||||
|   async updateCreatureCompetence(compName, fieldName, compValue) { | ||||
|     let comp = this.getCompetence(compName); | ||||
|     //console.log(comp); | ||||
|     if (comp) { | ||||
|       const update = { _id: comp.id } | ||||
|       if (fieldName == "niveau") | ||||
| @@ -752,7 +750,6 @@ export class RdDActor extends Actor { | ||||
|         update['data.dommages'] = compValue; | ||||
|       else | ||||
|         update['data.carac_value'] = compValue; | ||||
|       //console.log(update); | ||||
|       const updated = await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity | ||||
|     } | ||||
|   } | ||||
| @@ -1610,8 +1607,8 @@ export class RdDActor extends Actor { | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async consommerDialog(item) { | ||||
|     if (!item.isConsommable()) return; | ||||
|   async actionItem(item) { | ||||
|     if (!item.getActionPrincipale()) return; | ||||
|     const dialog = await DialogConsommer.create(this, item); | ||||
|     dialog.render(true) | ||||
|   } | ||||
| @@ -1648,7 +1645,7 @@ export class RdDActor extends Actor { | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async manger(item, doses, options = { diminuerQuantite: true }) { | ||||
|     if (!item.isConsommable()) return; | ||||
|     if (!item.getActionPrincipale()) return; | ||||
|     await this.apprecierCuisine(item); | ||||
|     const sust = Misc.templateData(item).sust; | ||||
|     if (sust > 0) { | ||||
| @@ -1656,10 +1653,10 @@ export class RdDActor extends Actor { | ||||
|     } | ||||
|     await item.diminuerQuantite(doses, options); | ||||
|   } | ||||
|  | ||||
|    | ||||
|   /* -------------------------------------------- */ | ||||
|   async boire(item, doses, options = { diminuerQuantite: true }) { | ||||
|     if (!item.isConsommable()) return; | ||||
|     if (!item.getActionPrincipale()) return; | ||||
|     const tplData = Misc.templateData(item); | ||||
|     const desaltere = tplData.desaltere; | ||||
|     if (desaltere > 0) { | ||||
| @@ -3278,10 +3275,7 @@ export class RdDActor extends Actor { | ||||
|   async consommerPotionSoin(potionData) { | ||||
|     potionData.alias = this.name; | ||||
|  | ||||
|     if (potionData.data.categorie.includes('Enchante')) { | ||||
|       potionData.pointsGuerison = RdDHerbes.calculePointsGuerison(potionData.data); | ||||
|       potionData.enchanteTexte = "enchantée"; | ||||
|       potionData.isEnchante = true; | ||||
|     if (potionData.data.isEnchante) { | ||||
|       ChatMessage.create({ | ||||
|         whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|         content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-soin.html`, potionData) | ||||
| @@ -3291,7 +3285,7 @@ export class RdDActor extends Actor { | ||||
|       potionData.reussiteReve = false; | ||||
|       if (!rolled.isSuccess) { | ||||
|         await this.reveActuelIncDec(-1); | ||||
|         potionData.guerisonData = await this.buildPotionGuerisonList(potionData.pointsGuerison); | ||||
|         potionData.guerisonData = await this.buildPotionGuerisonList(potionData.data.puissance); | ||||
|         potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5; | ||||
|         potionData.reussiteReve = true; | ||||
|       } | ||||
| @@ -3300,8 +3294,6 @@ export class RdDActor extends Actor { | ||||
|         content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData) | ||||
|       }); | ||||
|     } else { | ||||
|       potionData.enchanteTexte = ""; | ||||
|       potionData.isEnchante = false; | ||||
|       ChatMessage.create({ | ||||
|         whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|         content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData) | ||||
| @@ -3314,10 +3306,7 @@ export class RdDActor extends Actor { | ||||
|   async consommerPotionRepos(potionData) { | ||||
|     potionData.alias = this.name; | ||||
|  | ||||
|     if (potionData.data.categorie.includes('Enchante')) { | ||||
|       potionData.casesRepos = RdDHerbes.calculePointsRepos(potionData.data); | ||||
|       potionData.enchanteTexte = "enchantée"; | ||||
|       potionData.isEnchante = true; | ||||
|     if (potionData.data.isEnchante) { | ||||
|       ChatMessage.create({ | ||||
|         whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|         content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-repos.html`, potionData) | ||||
| @@ -3328,7 +3317,7 @@ export class RdDActor extends Actor { | ||||
|       if (!rolled.isSuccess) { | ||||
|         await this.reveActuelIncDec(-1); | ||||
|         let fatigueActuelle = this.getFatigueActuelle(); | ||||
|         potionData.caseFatigueReel = (fatigueActuelle >= potionData.casesRepos) ? potionData.casesRepos : fatigueActuelle; | ||||
|         potionData.caseFatigueReel = Math.min(fatigueActuelle, potionData.data.puissance); | ||||
|         potionData.guerisonDureeUnite = (potionData.data.reposalchimique) ? "rounds" : "minutes"; | ||||
|         potionData.guerisonDureeValue = (potionData.data.reposalchimique) ? potionData.caseFatigueReel : potionData.caseFatigueReel * 5; | ||||
|         potionData.reussiteReve = true; | ||||
| @@ -3346,8 +3335,6 @@ export class RdDActor extends Actor { | ||||
|         content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-repos.html`, potionData) | ||||
|       }); | ||||
|     } else { | ||||
|       potionData.enchanteTexte = ""; | ||||
|       potionData.isEnchante = false; | ||||
|       ChatMessage.create({ | ||||
|         whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|         content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-repos.html`, potionData) | ||||
| @@ -3386,13 +3373,7 @@ export class RdDActor extends Actor { | ||||
|       nbBrinsPotion: herbeData.nbBrins, | ||||
|       nbBrinsReste: newQuantite | ||||
|     } | ||||
|     // TODO:  | ||||
|     if (newQuantite == 0) { | ||||
|       await this.deleteEmbeddedDocuments('Item', [herbeData._id]); | ||||
|     } else { | ||||
|       let update = { _id: herbeData._id, 'data.quantite': newQuantite }; | ||||
|       await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity   | ||||
|     } | ||||
|     this.getObjet(herbeData._id).diminuerQuantite(herbeData.nbBrins); | ||||
|     ChatMessage.create({ | ||||
|       whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|       content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html`, messageData) | ||||
| @@ -3404,13 +3385,6 @@ export class RdDActor extends Actor { | ||||
|   async consommerPotionGenerique(potionData) { | ||||
|     potionData.alias = this.name; | ||||
|  | ||||
|     if (potionData.data.categorie.includes('Enchante')) { | ||||
|       potionData.enchanteTexte = "enchantée"; | ||||
|       potionData.isEnchante = true; | ||||
|     } else { | ||||
|       potionData.enchanteTexte = ""; | ||||
|       potionData.isEnchante = false; | ||||
|     } | ||||
|     ChatMessage.create({ | ||||
|       whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|       content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potionData) | ||||
|   | ||||
| @@ -48,7 +48,7 @@ export class DialogConsommer extends Dialog { | ||||
|         consommerData.buttonName = itemData.data.boisson ? "Boire" : "Manger"; | ||||
|         break; | ||||
|       case 'potion': | ||||
|         buttonName.title = `${itemData.name}: boire la potion`; | ||||
|         consommerData.title = `${itemData.name}: boire la potion`; | ||||
|         consommerData.buttonName = "Boire"; | ||||
|         break; | ||||
|     } | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| import { Grammar } from "./grammar.js"; | ||||
| import { Misc } from "./misc.js"; | ||||
| import { RdDUtility } from "./rdd-utility.js"; | ||||
|  | ||||
| @@ -17,9 +18,26 @@ export class RdDItem extends Item { | ||||
|  | ||||
|   prepareDerivedData() { | ||||
|     super.prepareDerivedData(); | ||||
|     if (RdDItem.getTypeObjetsEquipement().includes(Misc.data(this).type)) { | ||||
|     const itemData = Misc.data(this); | ||||
|     if (RdDItem.getTypeObjetsEquipement().includes(itemData.type)) { | ||||
|       this._calculsEquipement(); | ||||
|     } | ||||
|     if (itemData.type == 'potion') { | ||||
|       this.prepareDataPotion() | ||||
|     } | ||||
|     itemData.data.actionPrincipale = this.getActionPrincipale({ warnIfNot: false }); | ||||
|  | ||||
|   } | ||||
|  | ||||
|   prepareDataPotion() { | ||||
|     const tplData = Misc.templateData(this); | ||||
|     const categorie = Grammar.toLowerCaseNoAccent(tplData.categorie); | ||||
|     tplData.isEnchante = categorie.includes('enchante'); | ||||
|     if (tplData.isEnchante) { | ||||
|       if (categorie.includes('soin') || categorie.includes('repos')) { | ||||
|         tplData.puissance = tplData.herbebonus * tplData.pr; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   _calculsEquipement() { | ||||
| @@ -36,32 +54,30 @@ export class RdDItem extends Item { | ||||
|  | ||||
|   getEnc() { | ||||
|     const itemData = Misc.data(this); | ||||
|     switch (itemData.type) | ||||
|     { | ||||
|     switch (itemData.type) { | ||||
|       case 'herbe': | ||||
|         return encBrin; | ||||
|     } | ||||
|     return itemData.data.encombrement | ||||
|   } | ||||
|  | ||||
|   isConsommable(options = { warnIfNot: true }) { | ||||
|   getActionPrincipale(options = { warnIfNot: true }) { | ||||
|     const itemData = Misc.data(this); | ||||
|     if ((itemData.data.quantite ?? 0) <= 0) { | ||||
|       if (options.warnIfNot) { | ||||
|         ui.notifications.warn(`Vous n'avez plus de ${itemData.name}.`); | ||||
|       } | ||||
|       return false; | ||||
|       return undefined; | ||||
|     } | ||||
|  | ||||
|     switch (itemData.type) { | ||||
|       case 'nourritureboisson': | ||||
|       case 'potion': | ||||
|         return true; | ||||
|       case 'nourritureboisson': return itemData.data.boisson ? 'Boire' : 'Manger'; | ||||
|       case 'potion': return 'Boire'; | ||||
|     } | ||||
|     if (options.warnIfNot) { | ||||
|       ui.notifications.warn(`Impossible de consommer un ${itemData.name}, ce n'est pas commestible.`); | ||||
|       ui.notifications.warn(`Impossible d'utilise un ${itemData.name}, aucune action associée définie.`); | ||||
|     } | ||||
|     return false; | ||||
|  | ||||
|     return undefined; | ||||
|   } | ||||
|  | ||||
|   isAlcool() { | ||||
|   | ||||
| @@ -48,16 +48,6 @@ export class RdDHerbes extends Item { | ||||
|       formData.isRepos = true; | ||||
|       this.computeHerbeBonus(formData, this.herbesRepos, 7); | ||||
|     } | ||||
|  | ||||
|     if (formData.data.categorie.includes('Enchante') ) { | ||||
|       formData.isEnchante = true; | ||||
|       if ( formData.isHerbe) { | ||||
|         formData.pointsGuerison = this.calculePointsGuerison( formData.data ); | ||||
|       }   | ||||
|       if ( formData.isRepos) { | ||||
|         formData.caseRepos = formData.data.herbebonus * formData.data.pr; | ||||
|       }   | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   | ||||
| @@ -14,8 +14,8 @@ | ||||
|     {{/unless}} | ||||
|     <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a> | ||||
|     <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a> | ||||
|     {{#if (eq item.type 'nourritureboisson')}} | ||||
|     <a class="item-name item-consommer">Consommer</a> | ||||
|     {{#if item.data.actionPrincipale}} | ||||
|     <a class="item-name item-action">{{item.data.actionPrincipale}}</a> | ||||
|     {{/if}} | ||||
|   </div> | ||||
| </li> | ||||
|   | ||||
| @@ -1,9 +1,9 @@ | ||||
| <img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/competence_botanique.png" alt="potion de repos" /> | ||||
| <h4> | ||||
|   {{alias}} consomme sa Potion {{enchanteTexte}} de {{name}}. | ||||
|   {{alias}} consomme sa <b>Potion {{#if data.isEnchante}}enchantée{{/if}}</b> de {{name}}. | ||||
| </h4> | ||||
| <hr> | ||||
| <div> | ||||
|   Les effets de la potions sont à gérer manuellement, en fonction de sa nature{{#if isEnchante}} et de son enchantement ({{data.pr}} Points de Rêve){{/if}}. | ||||
|   Les effets de la potions sont à gérer manuellement, en fonction de sa nature{{#if data.isEnchante}} et de son enchantement ({{data.pr}} Points de Rêve){{/if}}. | ||||
|   <br>La potion a été supprimée de l'équipement. | ||||
| </div> | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| <img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/competence_botanique.png" alt="potion de repos" /> | ||||
| <h4> | ||||
|   {{alias}} consomme sa Potion de Repos {{enchanteTexte}} de {{name}} ({{data.herbe}}, {{data.herbebrins}} brins). | ||||
|   {{alias}} consomme sa <b>Potion de Repos {{#if data.isEnchante}}enchantée{{/if}}</b> de {{name}} ({{data.herbe}}, {{data.herbebrins}} brins). | ||||
| </h4> | ||||
| <hr> | ||||
| <div> | ||||
|   {{#if casesRepos}} | ||||
|   Elle permet de récupérer jusqu'à {{casesRepos}} cases de repos. | ||||
|   {{#if data.isEnchante}} | ||||
|   Elle permet de récupérer jusqu'à {{data.puissance}} cases de repos. | ||||
|   {{else}} | ||||
|   Une fois consommée vers fin Lyre, elle vous octroie un bonus de {{data.herbebonus}} segments de fatigue récupérés en plus à la fin de Chateau Dormant (à gérer manuellement). | ||||
|   <br>La potion a également été supprimée de l'équipement. | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| <img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/competence_botanique.png" alt="potion de soin" /> | ||||
| <h4> | ||||
|   {{alias}} consomme sa Potion de Soins {{enchanteTexte}} de {{name}} ({{data.herbe}}, {{data.herbebrins}} brins). | ||||
|   {{alias}} consomme sa <b>Potion de soins {{#if data.isEnchante}}enchantée{{/if}}</b> de {{name}} ({{data.herbe}}, {{data.herbebrins}} brins). | ||||
| </h4> | ||||
| <hr> | ||||
| <div> | ||||
|   {{#if pointsGuerison}} | ||||
|   Elle permet de guérir {{pointsGuerison}} Points de Guérison. | ||||
|   {{#if data.isEnchante}} | ||||
|   Elle permet de guérir {{data.puissance}} Points de Guérison. | ||||
|   {{else}} | ||||
|   Lors de votre prochain jet de récupération à Chateau Dormant, vous bénéficierez d'un bonus de {{data.herbebonus}} (appliqué automatiquement). | ||||
|   <br>La potion a également été supprimée de l'équipement. | ||||
|   | ||||
							
								
								
									
										14
									
								
								templates/consommer/dialog-potion.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								templates/consommer/dialog-potion.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| <form class="rdddialog"> | ||||
|   <img class="chat-icon" src="{{item.img}}" alt="{{oeuvre.data.competence}}" /> | ||||
|   <div class="form-group"> | ||||
|     <label>Boire une dose de {{item.name}}</label> | ||||
|   </div> | ||||
|   <div> | ||||
|     {{#if (eq item.data.categorie 'SoinEnchante')}} | ||||
|       <p>C'est une potion enchantée de {{item.data.herbe}} de {{item.data.pr}} points de rêve, | ||||
|         sa puissance de guérison est de {{data.puissance}} </p> | ||||
|     {{/if}} | ||||
|  | ||||
|   </div> | ||||
|  | ||||
| </form> | ||||
| @@ -5,7 +5,7 @@ | ||||
|       <h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1> | ||||
|       {{#if isOwned}} | ||||
|       <div class="form-group"> | ||||
|         <span for="xp"><a class="fabriquer-potion chat-card-button" data-actor-id="{{actorId}}">Consommer cette potion et appliquer ses effets</a></span> | ||||
|         <span for="xp"><a class="consommer-potion chat-card-button" data-actor-id="{{actorId}}">Consommer cette potion et appliquer ses effets</a></span> | ||||
|       </div> | ||||
|       {{/if}}   | ||||
|     </div> | ||||
| @@ -77,7 +77,7 @@ | ||||
|       <input class="attribute-value" type="checkbox" name="data.reposalchimique"  {{#if data.reposalchimique}}checked{{/if}}/> | ||||
|     </div> | ||||
|     {{/if}} | ||||
|     {{#if isEnchante}} | ||||
|     {{#if data.isEnchante}} | ||||
|     <div class="form-group"> | ||||
|       <label>Points de rêve</label> | ||||
|       <input class="attribute-value" type="text" name="data.pr" value="{{data.pr}}" data-dtype="Number" /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user