12.0.7 - La propriété d'Astrobazzarh #709
| @@ -10,6 +10,8 @@ | |||||||
| - Les messages pour résister aux possessions/conjuration sont envoyées | - Les messages pour résister aux possessions/conjuration sont envoyées | ||||||
|   au défenseur |   au défenseur | ||||||
| - Les messages pour résister aux empoignades sont envoyées au défenseur | - Les messages pour résister aux empoignades sont envoyées au défenseur | ||||||
|  | - la commande /voyage affiche maintenant le total de fatigue pour chaque voyageur | ||||||
|  | - la commande /voyage affiche maintenant les compétences liées au terrain | ||||||
|  |  | ||||||
| ## 12.0.6 - Le bazar d'Astrobazzarh | ## 12.0.6 - Le bazar d'Astrobazzarh | ||||||
| - Corrections de l'inventaire en bazar: | - Corrections de l'inventaire en bazar: | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| import { TYPES } from "../item.js" | import { TYPES } from "../item.js" | ||||||
| import { RdDItemCompetence } from "../item-competence.js" | import { RdDItemCompetence } from "../item-competence.js" | ||||||
| import { ChatUtility } from "../chat-utility.js" | import { ChatUtility } from "../chat-utility.js" | ||||||
|  | import { Misc } from "../misc.js" | ||||||
|  |  | ||||||
| const CODES_COMPETENCES_VOYAGE = ['Extérieur', 'Forêt', 'Montagne', 'Marais', 'Glace', 'Equitation'] | const CODES_COMPETENCES_VOYAGE = ['Extérieur', 'Forêt', 'Montagne', 'Marais', 'Glace', 'Equitation'] | ||||||
| const TABLEAU_FATIGUE_MARCHE = [ | const TABLEAU_FATIGUE_MARCHE = [ | ||||||
| @@ -36,7 +37,7 @@ export class DialogFatigueVoyage extends Dialog { | |||||||
|       const parameters = { |       const parameters = { | ||||||
|         tableauFatigueMarche: TABLEAU_FATIGUE_MARCHE, |         tableauFatigueMarche: TABLEAU_FATIGUE_MARCHE, | ||||||
|         playerActors: game.actors.filter(actor => actor.isPersonnageJoueur()) |         playerActors: game.actors.filter(actor => actor.isPersonnageJoueur()) | ||||||
|           .map(actor => DialogFatigueVoyage.prepareActor(actor)), |           .map(actor => DialogFatigueVoyage.prepareActorParameters(actor)), | ||||||
|         nombreHeures: 1, |         nombreHeures: 1, | ||||||
|       } |       } | ||||||
|       DialogFatigueVoyage.setModeDeplacement(parameters, undefined, undefined) |       DialogFatigueVoyage.setModeDeplacement(parameters, undefined, undefined) | ||||||
| @@ -53,21 +54,37 @@ export class DialogFatigueVoyage extends Dialog { | |||||||
|     parameters.typeTerrain = ligneFatigueMarche |     parameters.typeTerrain = ligneFatigueMarche | ||||||
|     parameters.vitesseDeplacement = rythme.vitesse |     parameters.vitesseDeplacement = rythme.vitesse | ||||||
|     parameters.fatigueHoraire = rythme.fatigue |     parameters.fatigueHoraire = rythme.fatigue | ||||||
|  |     parameters.playerActors.forEach(voyageur => | ||||||
|  |       DialogFatigueVoyage.selectSurvie(voyageur, parameters.typeTerrain.code) | ||||||
|  |     ) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static prepareActor(actor) { |   static prepareActorParameters(actor) { | ||||||
|     const competencesVoyage = {} |     const actorParameters = { | ||||||
|     CODES_COMPETENCES_VOYAGE.forEach(codeSurvie => |       id: actor.id, | ||||||
|       competencesVoyage[codeSurvie] = RdDItemCompetence.findCompetence(actor.itemTypes[TYPES.competence], codeSurvie, { onMessage: () => { } }) |  | ||||||
|     ) |  | ||||||
|     return { |  | ||||||
|       actor: actor, |       actor: actor, | ||||||
|       selected: true, |       selected: true, | ||||||
|       ajustementFatigue: 0, |       ajustementFatigue: 0, | ||||||
|       competencesVoyage: competencesVoyage |       survies: {} | ||||||
|     } |     } | ||||||
|  |     const competencesVoyage = {} | ||||||
|  |     CODES_COMPETENCES_VOYAGE.forEach(codeSurvie => { | ||||||
|  |       competencesVoyage[codeSurvie] = RdDItemCompetence.findCompetence(actor.itemTypes[TYPES.competence], codeSurvie, { onMessage: () => { } }) | ||||||
|  |     }) | ||||||
|  |     TABLEAU_FATIGUE_MARCHE.forEach(terrain => { | ||||||
|  |       actorParameters.survies[terrain.code] = Misc.join( | ||||||
|  |         terrain.survies.map(survie => { | ||||||
|  |           const niveau = competencesVoyage[survie]?.system.niveau | ||||||
|  |           return `${survie}: ${niveau}` | ||||||
|  |         }), | ||||||
|  |         ', ') | ||||||
|  |     }) | ||||||
|  |     return actorParameters | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   static selectSurvie(actorParameters, code) { | ||||||
|  |     actorParameters.survieCourante = actorParameters.survies[code] | ||||||
|  |   } | ||||||
|  |  | ||||||
|   constructor(html, parameters) { |   constructor(html, parameters) { | ||||||
|     const options = { |     const options = { | ||||||
| @@ -97,6 +114,7 @@ export class DialogFatigueVoyage extends Dialog { | |||||||
|     this.html.find('select[name="code-terrain"]').change(event => this.changeParameters()) |     this.html.find('select[name="code-terrain"]').change(event => this.changeParameters()) | ||||||
|     this.html.find('select[name="vitesse-deplacement"]').change(event => this.changeParameters()) |     this.html.find('select[name="vitesse-deplacement"]').change(event => this.changeParameters()) | ||||||
|     this.html.find('input[name="nombre-heures"]').change(event => this.changeParameters()) |     this.html.find('input[name="nombre-heures"]').change(event => this.changeParameters()) | ||||||
|  |     this.html.find('.list-item input[name="ajustement-fatigue"]').change(event => this.changeParameters()) | ||||||
|     this.html.find('button[name="appliquer-fatigue"]').click(event => this.appliquerFatigue()) |     this.html.find('button[name="appliquer-fatigue"]').click(event => this.appliquerFatigue()) | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -118,6 +136,10 @@ export class DialogFatigueVoyage extends Dialog { | |||||||
|         selectVitesseDeplacement.append(await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/voyage/option-vitesse-fatigue.hbs', rythme)) |         selectVitesseDeplacement.append(await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/voyage/option-vitesse-fatigue.hbs', rythme)) | ||||||
|       }) |       }) | ||||||
|       selectVitesseDeplacement.val(this.parameters.vitesseDeplacement).change() |       selectVitesseDeplacement.val(this.parameters.vitesseDeplacement).change() | ||||||
|  |  | ||||||
|  |       Promise.all(this.getActorRows() | ||||||
|  |         .map(async row => row.find('label.voyage-liste-survies').text(this.$extractActorParameters(row).survieCourante) | ||||||
|  |         )) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -132,16 +154,24 @@ export class DialogFatigueVoyage extends Dialog { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   async setFatigue() { |   async setFatigue() { | ||||||
|     this.html.find('input[name="base-fatigue"]').val(this.parameters.nombreHeures * this.parameters.fatigueHoraire) |     const baseFatigue = this.parameters.nombreHeures * this.parameters.fatigueHoraire | ||||||
|  |     this.html.find('input[name="base-fatigue"]').val(baseFatigue) | ||||||
|  |     this.updateActorTotalFatigue(baseFatigue) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   async updateActorTotalFatigue(baseFatigue) { | ||||||
|  |     Promise.all(this.getActorRows() | ||||||
|  |       .map(async row => { | ||||||
|  |         const actor = this.$extractActorParameters(row) | ||||||
|  |         row.find('input[name="total-fatigue"]').val(actor.ajustement + baseFatigue) | ||||||
|  |       })) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   async appliquerFatigue() { |   async appliquerFatigue() { | ||||||
|     const fatigueBase = parseInt(this.html.find('input[name="base-fatigue"]').val() ?? 0) |     const fatigueBase = parseInt(this.html.find('input[name="base-fatigue"]').val() ?? 0) | ||||||
|     const actors = jQuery.map( |     this.getActorRows() | ||||||
|       this.html.find('div.fatigue-actors-list li.list-item'), |       .map(row => this.$extractActorParameters(row)) | ||||||
|       it => this.$extractActor(this.html.find(it)) |       .filter(it => it.selected) | ||||||
|     ) |  | ||||||
|     actors.filter(it => it.selected) |  | ||||||
|       .forEach(async it => { |       .forEach(async it => { | ||||||
|         const perteFatigue = fatigueBase + it.ajustement |         const perteFatigue = fatigueBase + it.ajustement | ||||||
|         ChatMessage.create({ |         ChatMessage.create({ | ||||||
| @@ -161,16 +191,24 @@ export class DialogFatigueVoyage extends Dialog { | |||||||
|       }) |       }) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   $extractActor(actorRow) { |   getActorRows() { | ||||||
|     const actor = game.actors.get(actorRow.data('actor-id')) |     return jQuery.map( | ||||||
|  |       this.html.find('div.fatigue-actors-list li.list-item'), | ||||||
|  |       it => this.html.find(it)) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   $extractActorParameters(actorRow) { | ||||||
|  |     const actorId = actorRow.data('actor-id') | ||||||
|  |     const actorParameters = this.parameters.playerActors.find(it => it.id == actorId) | ||||||
|  |     const actor = game.actors.get(actorId) | ||||||
|     if (!actor) { |     if (!actor) { | ||||||
|       ui.notifications.warn(`Acteur ${it.actorId} introuvable`) |       ui.notifications.warn(`Acteur ${it.actorId} introuvable`) | ||||||
|  |       return {} | ||||||
|     } |     } | ||||||
|     return { |     actorParameters.ajustement = parseInt(actorRow.find('input[name="ajustement-fatigue"]').val() ?? 0) | ||||||
|       actor: actor, |     actorParameters.selected = actor && actorRow.find('input[name="selectionner-acteur"]').is(':checked') | ||||||
|       ajustement: parseInt(actorRow.find('input[name="ajustement-fatigue"]').val() ?? 0), |     return actorParameters | ||||||
|       selected: actor && actorRow.find('input[name="selectionner-acteur"]').is(':checked') |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   async close() { |   async close() { | ||||||
|   | |||||||
| @@ -42,7 +42,8 @@ | |||||||
|         <li class="competence-header flexrow"> |         <li class="competence-header flexrow"> | ||||||
|           <span class="flex-grow-2">Personnage</span> |           <span class="flex-grow-2">Personnage</span> | ||||||
|           <span class="flex-grow-2">Survies</span> |           <span class="flex-grow-2">Survies</span> | ||||||
|           <span class="flex-grow-1" data-tooltip="Ajustements à appliquer pour les personnages se reposant (par exemple, à cheval)">Ajustements</span> |           <span class="flex-grow-1" data-tooltip="Ajustements à appliquer (par exemple, repos à cheval)">Ajustements</span> | ||||||
|  |           <span class="flex-grow-1" data-tooltip="Total de fatigue pour le voyageur">Total</span> | ||||||
|         </li> |         </li> | ||||||
|         {{#each playerActors as |selected|}} |         {{#each playerActors as |selected|}} | ||||||
|         {{>'systems/foundryvtt-reve-de-dragon/templates/voyage/fatigue-actor.hbs' voyageur=selected survies=@root.typeTerrain.survies}} |         {{>'systems/foundryvtt-reve-de-dragon/templates/voyage/fatigue-actor.hbs' voyageur=selected survies=@root.typeTerrain.survies}} | ||||||
|   | |||||||
| @@ -8,16 +8,13 @@ | |||||||
|   </span> |   </span> | ||||||
|   <span class="flex-grow-2"> |   <span class="flex-grow-2"> | ||||||
|     <div class="flexcol "> |     <div class="flexcol "> | ||||||
|       <label class="voyage-liste-survies"> |       <label class="voyage-liste-survies">{{voyageur.survieCourante}}</label> | ||||||
|       {{#each voyageur.competencesVoyage as |comp key|}} |  | ||||||
|       {{#if (array-includes ../survies key)}} |  | ||||||
|         {{key}} {{comp.system.niveau}}, |  | ||||||
|       {{/if}} |  | ||||||
|       {{/each}} |  | ||||||
|       </label> |  | ||||||
|     </div> |     </div> | ||||||
|   </span> |   </span> | ||||||
|   <span class="flex-grow-1"> |   <span class="flex-grow-1"> | ||||||
|     <input type="number" name="ajustement-fatigue" class="number-x2 ajustement-fatigue" data-dtype="Number" value="{{voyageur.ajustementFatigue}}" min="-6" max="6"/> |     <input type="number" name="ajustement-fatigue" class="number-x2 ajustement-fatigue" data-dtype="Number" value="{{voyageur.ajustementFatigue}}" min="-6" max="6"/> | ||||||
|   </span> |   </span> | ||||||
|  |   <span class="flex-grow-1"> | ||||||
|  |     <input type="number" name="total-fatigue" class="number-x2 total-fatigue" data-dtype="Number" value="1" min="0" max="24" disabled/> | ||||||
|  |   </span> | ||||||
| </li> | </li> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user