Sync
This commit is contained in:
		
							
								
								
									
										81
									
								
								module/rdd-herbes.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								module/rdd-herbes.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | |||||||
|  | /* -------------------------------------------- */ | ||||||
|  | import { RdDUtility } from "./rdd-utility.js"; | ||||||
|  | import { Misc } from "./misc.js"; | ||||||
|  | import { RdDCalendrier } from "./rdd-calendrier.js"; | ||||||
|  |  | ||||||
|  | /* -------------------------------------------- */ | ||||||
|  | export class RdDHerbes extends Item { | ||||||
|  |  | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static isHerbeSoin( botaniqueItem ) { | ||||||
|  |     return Misc.templateData(botaniqueItem).categorie == 'Soin'; | ||||||
|  |   } | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static isHerbeRepos( botaniqueItem ) { | ||||||
|  |     return Misc.templateData(botaniqueItem).categorie == 'Repos'; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static async initializeHerbes( ) {   | ||||||
|  |     this.herbesSoins = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.botanique', item => this.isHerbeSoin(item)); | ||||||
|  |     this.herbesRepos = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.botanique', item => this.isHerbeRepos(item)); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static buildHerbesList(listHerbes, max) { | ||||||
|  |     let list = {} | ||||||
|  |     for ( let herbe of listHerbes) { | ||||||
|  |       let herbeData = Misc.templateData(herbe); | ||||||
|  |       let brins = max - herbeData.niveau; | ||||||
|  |       list[herbe.data.name] = `${herbe.data.name} (Bonus: ${herbeData.niveau}, Brins: ${brins})`; | ||||||
|  |     } | ||||||
|  |     list['Autre'] = 'Autre (Bonus: variable, Brins: variable)' | ||||||
|  |     return list; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static updatePotionData( formData ) { | ||||||
|  |     formData.herbesSoins = this.buildHerbesList(this.herbesSoins, 12); | ||||||
|  |     formData.herbesRepos = this.buildHerbesList(this.herbesRepos, 7); | ||||||
|  |     formData.jourMoisOptions = Array(28).fill().map((item, index) => 1 + index); | ||||||
|  |     formData.dateActuelle = game.system.rdd.calendrier.getDateFromIndex(); | ||||||
|  |     formData.splitDate = game.system.rdd.calendrier.getNumericDateFromIndex(formData.data.prdate); | ||||||
|  |  | ||||||
|  |     if (formData.data.categorie.includes('Soin') ) { | ||||||
|  |       formData.isHerbe = true; | ||||||
|  |       this.computeHerbeBonus(formData, this.herbesSoins, 12); | ||||||
|  |     } else if (formData.data.categorie.includes('Repos')) { | ||||||
|  |       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; | ||||||
|  |       }   | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static calculePointsGuerison( data ){ | ||||||
|  |     return data.herbebonus * data.pr; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /* -------------------------------------------- */ | ||||||
|  |   static computeHerbeBonus( formData, herbesList, max) { | ||||||
|  |     if ( Number(formData.data.herbebrins) ) { | ||||||
|  |     let herbe = herbesList.find(item => item.name.toLowerCase() == formData.data.herbe.toLowerCase() ); | ||||||
|  |       if( herbe ) { | ||||||
|  |         let herbeData = Misc.templateData(herbe); | ||||||
|  |         let brinsBase = max - herbeData.niveau; | ||||||
|  |         //console.log(herbeData, brinsBase, formData.data.herbebrins); | ||||||
|  |         formData.data.herbebonus = Math.max(herbeData.niveau - Math.max(brinsBase - formData.data.herbebrins, 0), 0); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }   | ||||||
|  |  | ||||||
|  | }   | ||||||
							
								
								
									
										23
									
								
								templates/chat-appliquer-potion-soin.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								templates/chat-appliquer-potion-soin.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | <img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/competence_botanique.png" alt="potion de soin" /> | ||||||
|  | <h4> | ||||||
|  |   {{#if enchante}} | ||||||
|  |  | ||||||
|  |   {{else}} | ||||||
|  |     {{#if reussiteReve}} | ||||||
|  |     {{alias}} a bu la potion et a échoué son Jet de Résistance (Rêve actuelà -8) : la potion fait effet ! | ||||||
|  |     {{else}} | ||||||
|  |     {{alias}} a bu la potion et a réussi son Jet de Résistance (Rêve actuelà -8) : la potion ne fait pas effet ! | ||||||
|  |     {{/if}} | ||||||
|  |   {{/if}} | ||||||
|  | </h4> | ||||||
|  | <hr> | ||||||
|  | {{#if reussiteReve}} | ||||||
|  | <div> | ||||||
|  |   {{alias}} perd 1 point de rêve (déduit autmatiquement) et s'endort pour {{guerisonMinutes}} minutes. A son réveil, les blessures suivantes seront guéries :  | ||||||
|  |   <ul> | ||||||
|  |     {{#each guerisonData.list as |guerison key|}} | ||||||
|  |     <li>{{guerison}}</li> | ||||||
|  |     {{/each}} | ||||||
|  |   </ul> | ||||||
|  | </div> | ||||||
|  | {{/if}} | ||||||
							
								
								
									
										12
									
								
								templates/chat-consommer-potion-soin.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								templates/chat-consommer-potion-soin.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | <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). | ||||||
|  | </h4> | ||||||
|  | <hr> | ||||||
|  | <div> | ||||||
|  |   {{#if pointsGuerison}} | ||||||
|  |   Elle permet de guérir {{pointsGuerison}} 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). | ||||||
|  |   {{/if}} | ||||||
|  | </div> | ||||||
							
								
								
									
										11
									
								
								templates/enum-herbesoin-ingredient.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								templates/enum-herbesoin-ingredient.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | <option value="Fausse Suppure">Fausse Suppure (Bonus 1, Brins : 11)</option> | ||||||
|  | <option value="Suppure">Suppure (Bonus 2, Brins : 10)</option> | ||||||
|  | <option value="Méritoine">Méritoine (Bonus 3, Brins : 9)</option> | ||||||
|  | <option value="Ortigal">Ortigal (Bonus 4, Brins : 8)</option> | ||||||
|  | <option value="Ortigal Noir">Ortigal Noir (Bonus 5, Brins : 7)</option> | ||||||
|  | <option value="Bélidane">Bélidane (Bonus 6, Brins : 6)</option> | ||||||
|  | <option value="Faux Murus">Faux Murus (Bonus 7, Brins : 5)</option> | ||||||
|  | <option value="Murus">Murus (Bonus 8, Brins : 4)</option> | ||||||
|  | <option value="Tanemiel">Tanemiel (Bonus 9, Brins : 3)</option> | ||||||
|  | <option value="Tanemiel Doré">Tanemiel Doré (Bonus 10, Brins : 2)</option> | ||||||
|  | <option value="Autre">Autre</option> | ||||||
		Reference in New Issue
	
	Block a user