Gestion des singularites
This commit is contained in:
		| @@ -154,7 +154,7 @@ export class Imperium5ActorSheet extends ActorSheet { | ||||
|       this.render(true); | ||||
|     });     | ||||
|     html.find('.item-link a').click((event) => { | ||||
|       const itemId = $(event.currentTarget).data("item-id"); | ||||
|       const itemId = $(event.currentTarget).data("item-id") | ||||
|       const item = this.actor.getOwnedItem(itemId); | ||||
|       item.sheet.render(true); | ||||
|     });     | ||||
|   | ||||
| @@ -50,13 +50,33 @@ export class Imperium5Utility { | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static registerSettings() { | ||||
|     game.settings.register("fvtt-imperium5", "use-entropie-reussite", { | ||||
|       name: "Utilisation du dé d'Entropie dans les réussites", | ||||
|       hint: "Si coché, ajoute 1 succès au joueur sur un 2, et 1 succés au MJ sur un 7.", | ||||
|       scope: "world", | ||||
|       config: true, | ||||
|       default: false, | ||||
|       type: Boolean | ||||
|     }) | ||||
|     game.settings.register("fvtt-imperium5", "use-singularite", { | ||||
|       name: "Utilisation complémentaire des Singularités", | ||||
|       hint: "Si coché, les Singularités peuvent permettre de réduire de 1 la valeur d'un dé", | ||||
|       scope: "world", | ||||
|       config: true, | ||||
|       default: false, | ||||
|       type: Boolean | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static pushInitiativeOptions(html, options) { | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async ready() { | ||||
|  | ||||
|     this.registerSettings() | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
| @@ -90,14 +110,19 @@ export class Imperium5Utility { | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async chatListeners(html) { | ||||
|  | ||||
|     html.on("click", '.button-apply-paradigme', event => { | ||||
|       let paraKey = $(event.currentTarget).data("para-key") | ||||
|     html.on("change", '.select-apply-paradigme', event => { | ||||
|       let paraKey = event.currentTarget.value | ||||
|       let rollData = this.getRollDataFromMessage(event) | ||||
|       rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget) | ||||
|       this.applyParadigme(rollData, paraKey) | ||||
|     }) | ||||
|  | ||||
|     html.on("click", '.apply-singularite', event => { | ||||
|       let resultIndex = $(event.currentTarget).data("result-index") | ||||
|       let rollData = this.getRollDataFromMessage(event) | ||||
|       rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget) | ||||
|       this.applySingularite(rollData, resultIndex) | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
| @@ -292,11 +317,21 @@ export class Imperium5Utility { | ||||
|   /* -------------------------------------------- */ | ||||
|   static computeReussites(rollData) { | ||||
|     let myRoll = rollData.roll | ||||
|     rollData.successPC = myRoll.terms[0].results.filter(res => res.result <= rollData.seuil).length | ||||
|     rollData.successGM = myRoll.terms[4].results.filter(res => res.result <= rollData.seuil).length | ||||
|     // Calcul des réussites sur les 2 pools | ||||
|     rollData.successPC = rollData.resultsPC.filter(res => res.result <= rollData.seuil).length | ||||
|     rollData.successGM = myRoll.terms[4].results.filter(res => res.result <= 2).length | ||||
|     // Calcul du présage | ||||
|     rollData.bonPresage = myRoll.terms[2].results[0].result == 1 | ||||
|     rollData.mauvaisPresage = myRoll.terms[2].results[0].result == 8 | ||||
|     rollData.nbUnitesNarration = Math.max( rollData.successPC-1, 0) | ||||
|     // gestion règle optionnelle de l'Entropie | ||||
|     if (rollData.useEntropieReussite && myRoll.terms[2].results[0].result == 2) { | ||||
|       rollData.successPC++ | ||||
|     } | ||||
|     if (rollData.useEntropieReussite && myRoll.terms[2].results[0].result == 7) { | ||||
|       rollData.successGM++ | ||||
|     } | ||||
|     // Calcul unité de narration | ||||
|     rollData.nbUnitesNarration = Math.max(rollData.successPC - 1, 0) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
| @@ -305,16 +340,16 @@ export class Imperium5Utility { | ||||
|     // Karma management | ||||
|     let actor = game.actors.get(rollData.actorId) | ||||
|     rollData.nbKarma = 0 | ||||
|     if ( rollData.useKarma ) { | ||||
|     if (rollData.useKarma) { | ||||
|       actor.incDecKarma(-1) | ||||
|       rollData.nbKarma++ | ||||
|     } | ||||
|     if ( rollData.usedCapacite != "none" ) { | ||||
|     if (rollData.usedCapacite != "none") { | ||||
|       actor.incDecKarma(-1) | ||||
|       rollData.nbKarma++ | ||||
|     } | ||||
|  | ||||
|     let nbAmeDice = this.computeDiceReserve( rollData )  | ||||
|     let nbAmeDice = this.computeDiceReserve(rollData) | ||||
|     let diceFormula = `${nbAmeDice}d8[green] + 1d8[blue] + ${rollData.realiteDice}d8[red]` | ||||
|     let humanFormula = `${nbAmeDice}d8, 1d8, ${rollData.realiteDice}d8` | ||||
|     // Performs roll | ||||
| @@ -326,7 +361,8 @@ export class Imperium5Utility { | ||||
|       rollData.diceFormula = diceFormula | ||||
|       rollData.humanFormula = humanFormula | ||||
|     } | ||||
|  | ||||
|     // local copy of results to allow changes | ||||
|     rollData.resultsPC = duplicate(myRoll.terms[0].results) | ||||
|     // Calcul réussites | ||||
|     this.computeReussites(rollData) | ||||
|  | ||||
| @@ -334,20 +370,39 @@ export class Imperium5Utility { | ||||
|       content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData) | ||||
|     }) | ||||
|     msg.setFlag("world", "imperium5-roll-data", rollData) | ||||
|     console.log("Final rollData", rollData) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------  ------------------- */ | ||||
|   static async processParadigmeRoll(rollData) { | ||||
|   /* -------------------------------------------- */ | ||||
|   static async applyParadigme(rollData, paraKey) { | ||||
|     let actor = game.actors.get(rollData.actorId) | ||||
|     let para = actor.system.paradigmes[paraKey] | ||||
|     rollData.seuil = para.value | ||||
|     rollData.usedParadigme = para.label | ||||
|     actor.setParadigmeUsed(paraKey) | ||||
|  | ||||
|     this.computeReussites(rollData) | ||||
|     rollData.paradigmes = [] | ||||
|     let msg = await this.createChatWithRollMode(rollData.alias, { | ||||
|       content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData) | ||||
|     }) | ||||
|     msg.setFlag("world", "imperium5-roll-data", rollData) | ||||
|  | ||||
|     this.removeChatMessageId(rollData.previousMessageId) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async applySingularite(rollData, resultIndex) { | ||||
|     let res = rollData.resultsPC[resultIndex] | ||||
|     res.result = (res.result > 1) ? res.result-1 : res.result | ||||
|     this.computeReussites(rollData) | ||||
|     rollData.useSingularites = false | ||||
|     rollData.singulariteApplied = true | ||||
|     let msg = await this.createChatWithRollMode(rollData.alias, { | ||||
|       content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData) | ||||
|     }) | ||||
|     msg.setFlag("world", "imperium5-roll-data", rollData) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------  ------------------- */ | ||||
|   static async updateRoll(rollData) { | ||||
|  | ||||
| @@ -474,22 +529,14 @@ export class Imperium5Utility { | ||||
|       useAide: false, | ||||
|       useKarma: false, | ||||
|       usedCapacite: "none", | ||||
|       seuil: 2 | ||||
|       seuil: 2, | ||||
|       useSingularites: game.settings.get("fvtt-imperium5", "use-singularite"), | ||||
|       useEntropieReussite: game.settings.get("fvtt-imperium5", "use-entropie-reussite") | ||||
|     } | ||||
|     Imperium5Utility.updateWithTarget(rollData) | ||||
|     return rollData | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static applyParadigme(rollData, paraKey) { | ||||
|     let actor = game.actors.get(rollData.actorId) | ||||
|     let para = actor.system.paradigmes[paraKey] | ||||
|     rollData.seuil = para.value | ||||
|     rollData.usedParadigme = para.label | ||||
|     actor.setParadigmeUsed(paraKey) | ||||
|      | ||||
|     this.processParadigmeRoll(rollData) | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static updateWithTarget(rollData) { | ||||
|   | ||||
| @@ -1165,7 +1165,7 @@ ul, li { | ||||
| .common-button { | ||||
|   box-shadow: inset 0px 1px 0px 0px #a6827e; | ||||
|   background: linear-gradient(to bottom, #B8A799F0 5%, #80624af0 100%); | ||||
|   background-color: #B8A799F0; /*#7d5d3b00;*/ | ||||
|   background-color: #80624af0; /*#7d5d3b00;*/ | ||||
|   border-radius: 4px; | ||||
|   opacity: 60%; | ||||
|   border: 2px ridge #846109; | ||||
| @@ -1177,6 +1177,11 @@ ul, li { | ||||
|   position: relative; | ||||
| } | ||||
|  | ||||
| .common-button option { | ||||
|   background: linear-gradient(to bottom, #B8A799F0 5%, #80624af0 100%); | ||||
|   background-color: #80624af0; /*#7d5d3b00;*/ | ||||
| } | ||||
|  | ||||
| .common-button:hover { | ||||
|   background: linear-gradient(to bottom, #97B5AEFF 5%, rgb(101, 167, 151) 100%); | ||||
|   background-color: #97B5AEFF; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|       "flags": {} | ||||
|     } | ||||
|   ], | ||||
|   "version": "10.0.4", | ||||
|   "version": "10.0.5", | ||||
|   "compatibility": { | ||||
|     "minimum": "10", | ||||
|     "verified": "10", | ||||
| @@ -67,5 +67,5 @@ | ||||
|   "background": "images/ui/imperium5_welcome_page.webp", | ||||
|   "url": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5", | ||||
|   "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/raw/branch/master/system.json", | ||||
|   "download": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/archive/fvtt-imperium5-v10.0.4.zip" | ||||
|   "download": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/archive/fvtt-imperium5-v10.0.5.zip" | ||||
| } | ||||
| @@ -15,8 +15,12 @@ | ||||
|         <li>Réserve : {{humanFormula}}</li> | ||||
|         <li>Score :  | ||||
|             ( | ||||
|               {{#each roll.terms.0.results as |r k|}} | ||||
|               {{#each resultsPC as |r k|}} | ||||
|               {{#if @root.useSingularites}} | ||||
|                 <a class="apply-singularite common-button" data-result-index="{{k}}">{{r.result}}</a> | ||||
|               {{else}} | ||||
|                 {{r.result}} | ||||
|               {{/if}} | ||||
|               {{/each}} | ||||
|             ) | ||||
|             ( | ||||
| @@ -30,13 +34,34 @@ | ||||
|               {{/each}} | ||||
|             ) | ||||
|         </li> | ||||
|          | ||||
|         {{#if singulariteApplied}} | ||||
|         <li>Une Singularité a réduit de 1 le résultat du dé</li> | ||||
|         {{/if}} | ||||
|  | ||||
|         {{#if usedParadigme}} | ||||
|         <li>Paradigme utilisé : {{usedParadigme}}</li> | ||||
|         {{/if}} | ||||
|         <li>Seuil : {{seuil}}</li> | ||||
|          | ||||
|         <li>Seuil : {{seuil}} | ||||
|           {{#if (count paradigmes)}} | ||||
|             <select class="common-button select-apply-paradigme" type="text" value="{{selectedParadigme}}" data-dtype="String"> | ||||
|             {{#select selectedParadigme}} | ||||
|             <option value="none">Pas de paradigme</option> | ||||
|             {{#each paradigmes as |para key|}} | ||||
|             <option value="{{para.key}}">{{para.label}} ({{para.value}})</option> | ||||
|             {{/each}} | ||||
|             {{/select}} | ||||
|           </select>     | ||||
|           {{/if}}   | ||||
|         </li> | ||||
|  | ||||
|         <li>Succés : {{successPC}}</li> | ||||
|          | ||||
|         <li>Succés de Réalité : {{successGM}}</li> | ||||
|          | ||||
|         <li>Unités de narration : {{nbUnitesNarration}}</li> | ||||
|          | ||||
|         {{#if nbKarma}} | ||||
|         <li>Points de Karma utilisés : {{nbKarma}}</li> | ||||
|         {{/if}} | ||||
| @@ -48,14 +73,6 @@ | ||||
|         <li>Mauvais Présage !</li> | ||||
|         {{/if}} | ||||
|  | ||||
|         {{#if (count paradigmes)}} | ||||
|         <li class="li-button-paradigme"> | ||||
|           {{#each paradigmes as |para key|}} | ||||
|           <button class="common-button chat-card-button button-apply-paradigme" data-para-key="{{para.key}}">Utiliser {{para.label}} ({{para.value}})</button> | ||||
|           {{/each}} | ||||
|         </li> | ||||
|         {{/if}} | ||||
|  | ||||
|       </ul>   | ||||
|     </div> | ||||
|  | ||||
|   | ||||
| @@ -3,14 +3,11 @@ | ||||
|     {{#if img}} | ||||
|     <img class="actor-icon" src="{{img}}" data-edit="img" title="{{name}}" /> | ||||
|     {{/if}} | ||||
|     <h1 class="dialog-roll-title roll-dialog-header">{{title}}</h1> | ||||
|     <h1 class="dialog-roll-title roll-dialog-header">{{ame.label}} ({{ame.value}})</h1> | ||||
|   </header> | ||||
|  | ||||
|   <div class="flexcol"> | ||||
|  | ||||
|     <div class="flexrow"> | ||||
|       <span class="roll-dialog-label">Ame : {{ame.label}} ({{ame.value}})</span> | ||||
|     </div> | ||||
|     <div class="flexrow"> | ||||
|       <span class="roll-dialog-label">Malus : {{ameMalus}}</span> | ||||
|     </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user