Ajout QoL
This commit is contained in:
		| @@ -71,6 +71,28 @@ export class VadentisActorSheet extends ActorSheet { | ||||
|       VadentisUtility.confirmDelete(this, li); | ||||
|     }); | ||||
|      | ||||
|     html.find('.munition-moins').click(event => { | ||||
|       const li = $(event.currentTarget).parents(".item"); | ||||
|       const item = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.decrementeMunition( item ); | ||||
|     } ); | ||||
|     html.find('.munition-plus').click(event => { | ||||
|       const li = $(event.currentTarget).parents(".item"); | ||||
|       const item = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.incrementeMunition( item ); | ||||
|     } ); | ||||
|  | ||||
|     html.find('.argent-moins').click(event => { | ||||
|       const li = $(event.currentTarget).parents(".item"); | ||||
|       const item = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.decrementeArgent( item ); | ||||
|     } ); | ||||
|     html.find('.argent-plus').click(event => { | ||||
|       const li = $(event.currentTarget).parents(".item"); | ||||
|       const item = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.incrementeArgent( item ); | ||||
|     } ); | ||||
|  | ||||
|     html.find('.combat-label a').click((event) => { | ||||
|       let combatName = event.currentTarget.attributes.name.value; | ||||
|       this.actor.rollCombat(combatName); | ||||
| @@ -119,6 +141,16 @@ export class VadentisActorSheet extends ActorSheet { | ||||
|       const weapon = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.rollDamage(weapon, 'criticaldamage'); | ||||
|     }); | ||||
|     html.find('.sort-damage').click((event) => { | ||||
|       const li = $(event.currentTarget).parents(".item"); | ||||
|       const weapon = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.rollSortDevotionDamage(weapon, 'damage'); | ||||
|     }); | ||||
|     html.find('.sort-damage-critical').click((event) => { | ||||
|       const li = $(event.currentTarget).parents(".item"); | ||||
|       const weapon = this.actor.getOwnedItem(li.data("item-id")); | ||||
|       this.actor.rollSortDevotionDamage(weapon, 'damagecritical'); | ||||
|     }); | ||||
|      | ||||
|     html.find('.competence-base').change((event) => { | ||||
|       let skillName = event.currentTarget.attributes.skillname.value; | ||||
|   | ||||
| @@ -108,6 +108,12 @@ export class VadentisActor extends Actor { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   buildListeActionsCombat( ) { | ||||
|     let armes = []; | ||||
|  | ||||
|   } | ||||
|    | ||||
|   /* -------------------------------------------- */ | ||||
|   calculerSommeStats( ) { | ||||
|     for (const key in this.data.data.combat) { | ||||
| @@ -144,7 +150,9 @@ export class VadentisActor extends Actor { | ||||
|       let maintain = (devotionSort.data.ismaintain)?"Oui":"Non"; | ||||
|       let complex  = (devotionSort.data.complexactions)?"Oui":"Non"; | ||||
|       msgData.msg += `<br>Peut être maintenu: ${maintain}<br>Actions complexes : ${complex}`; | ||||
|       if ( !devotionSort.data.notes)  devotionSort.data.notes  = ""; | ||||
|       msgData.msg += `<br><strong>Description : </strong>${devotionSort.data.notes.replace(/<\/?[^>]+(>|$)/g, "")}`; | ||||
|  | ||||
|       let newEnergie = this.data.data.stats.pointsenergie.value - devotionSort.data.pe; | ||||
|       await this.update( {'data.stats.pointsenergie.value': newEnergie }); | ||||
|       if (myRoll.results[0] >= devotionSort.data.valuecritical ) { // Critique ? | ||||
| @@ -158,10 +166,10 @@ export class VadentisActor extends Actor { | ||||
|       if ( devotionSort.data.damage != "") { | ||||
|         let formula = devotionSort.data.damage; | ||||
|         if (myRoll.results[0] >= devotionSort.data.valuecritical ) { // Critique ? | ||||
|           msgData.msg += `<br>Et provoque les dégats critiques suivants : `; | ||||
|           msgData.msg += `<br>Et provoque les dégats critiques suivants : [[/roll ${devotionSort.data.damagecritical}]]`; | ||||
|           formula = devotionSort.data.damagecritical; | ||||
|         } else { | ||||
|           msgData.msg += `<br>Et provoque les dégats suivants : `; | ||||
|           msgData.msg += `<br>Et provoque les dégats suivants : [[/roll ${devotionSort.data.damage}]]`; | ||||
|         } | ||||
|       } | ||||
|       if ( newEnergie < 0) { | ||||
| @@ -199,6 +207,23 @@ export class VadentisActor extends Actor { | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async rollSortDevotionDamage( sort, damageType ) { | ||||
|     let formula = VadentisUtility.processDamageString( sort.data.data[damageType], this ); | ||||
|     let degatsRoll = await VadentisUtility.processRoll( formula ); | ||||
|     let msgData = { | ||||
|       alias: this.name,  | ||||
|       img: "systems/foundryvtt-vadentis/images/icons/tchat_dégâts_infligés.webp", | ||||
|       title: `Dégâts de ${sort.name}`, | ||||
|       msg: `Le sort ${sort.name} produit <strong>${degatsRoll.total} Points de Dégâts</strong> (${formula}).` | ||||
|     } | ||||
|     ChatMessage.create({ | ||||
|       //whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), | ||||
|       content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData) | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|    | ||||
|   /* -------------------------------------------- */ | ||||
|   async applyDamage( damageValue ) { | ||||
|     let pvData = this.data.data.stats.pointsvie; | ||||
| @@ -278,6 +303,13 @@ export class VadentisActor extends Actor { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   rollSortOuDevotion( sortId ) { | ||||
|     let sort = this.data.items.find( item => item._id == sortId ); | ||||
|     this.processSortDevotion( sort.type, sort); | ||||
|   } | ||||
|  | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async rollTechnique( techniqueId ) { | ||||
|     let technique = this.data.items.find( item => item.type == 'technique' && item._id == techniqueId ); | ||||
| @@ -383,11 +415,38 @@ export class VadentisActor extends Actor { | ||||
|     this.genericRoll( stat, magieName ); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async incrementeArgent( arme ) { | ||||
|     let monnaie = this.data.items.find( item => item.type == 'monnaie' && item.name == arme.name); | ||||
|     if (monnaie) { | ||||
|       let newValeur = monnaie.data.nombre + 1; | ||||
|       await this.updateOwnedItem( { _id: monnaie._id, 'data.nombre': newValeur } ); | ||||
|     } | ||||
|   } | ||||
|   /* -------------------------------------------- */ | ||||
|   async decrementeArgent( arme ) { | ||||
|     let monnaie = this.data.items.find( item => item.type == 'monnaie' && item.name == arme.name); | ||||
|     if (monnaie) { | ||||
|       let newValeur = monnaie.data.nombre - 1; | ||||
|       newValeur = (newValeur <= 0) ? 0 : newValeur; | ||||
|       await this.updateOwnedItem( { _id: monnaie._id, 'data.nombre': newValeur } ); | ||||
|     } | ||||
|   } | ||||
|    | ||||
|   /* -------------------------------------------- */ | ||||
|   async incrementeMunition( arme ) { | ||||
|     let armeTir = this.data.items.find( item => item.type == 'tir' && item.name == arme.name); | ||||
|     if (armeTir) { | ||||
|       let newMunition = armeTir.data.munition + 1; | ||||
|       await this.updateOwnedItem( { _id: armeTir._id, 'data.munition': newMunition } ); | ||||
|     } | ||||
|   } | ||||
|   /* -------------------------------------------- */ | ||||
|   async decrementeMunition( arme ) { | ||||
|     let armeTir = this.data.items.find( item => item.type == 'tir' && item.name == arme.name); | ||||
|     if (armeTir) { | ||||
|       let newMunition = armeTir.data.munition - 1; | ||||
|       newMunition = (newMunition <= 0) ? 0 : newMunition; | ||||
|       await this.updateOwnedItem( { _id: armeTir._id, 'data.munition': newMunition } ); | ||||
|     } | ||||
|   } | ||||
|   | ||||
							
								
								
									
										95
									
								
								modules/vadentis-hud.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								modules/vadentis-hud.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,95 @@ | ||||
| /* -------------------------------------------- */ | ||||
| import { VadentisUtility } from "./vadentis-utility.js"; | ||||
|  | ||||
| /* -------------------------------------------- */ | ||||
| export class VadentisTokenHud { | ||||
|  | ||||
|   static init(){ | ||||
|       // Integration du TokenHUD | ||||
|     Hooks.on('renderTokenHUD', (app, html, data) => { VadentisTokenHud.addTokenHudExtensions(app, html, data._id) }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async removeExtensionHud( app, html, tokenId) { | ||||
|     let combat = html.find('.control-icon.vadentis-combat'); | ||||
|     combat.remove(); | ||||
|     let sort = html.find('.control-icon.vadentis-sort'); | ||||
|     sort.remove(); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async addExtensionHud( app, html, tokenId ) { | ||||
|  | ||||
|     let token = canvas.tokens.get(tokenId); | ||||
|     let actor = token.actor; | ||||
|     let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id); | ||||
|     app.hasExtension = true; | ||||
|  | ||||
|     let armesList = combatant.actor.getArmes() ; | ||||
|     let sortsList = combatant.actor.getSorts().concat( combatant.actor.getDevotions() ); | ||||
|     const hudData = { combatant: combatant, armes: armesList, sorts: sortsList }  | ||||
|  | ||||
|     // sort | ||||
|     await VadentisTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-vadentis/templates/hud-actor-sort.html', hudData, | ||||
|       (event) => { | ||||
|         let combatantId = event.currentTarget.attributes['data-combatant-id'].value; | ||||
|         const combatant = game.combat.getCombatant(combatantId);         | ||||
|         let sortId = event.currentTarget.attributes['data-sort-id'].value; | ||||
|         combatant.actor.rollSortOuDevotion( sortId ); | ||||
|       }); | ||||
|  | ||||
|     // combat | ||||
|     await VadentisTokenHud._configureSubMenu(html.find('.control-icon.target'), 'systems/foundryvtt-vadentis/templates/hud-actor-attaque.html', hudData, | ||||
|       (event) => { | ||||
|         let armeId = event.currentTarget.attributes['data-arme-id'].value; | ||||
|         actor.rollArme(armeId); | ||||
|       }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async addTokenHudExtensions(app, html, tokenId) { | ||||
|  | ||||
|     html.find('.control-icon.combat').click(event => { | ||||
|       if ( event.currentTarget.className.includes('active')) { | ||||
|         VadentisTokenHud.removeExtensionHud( app, html, tokenId); | ||||
|       } else { | ||||
|         setTimeout( function() { RdDTokenHud.addExtensionHud( app, html, tokenId) } , 200 ); | ||||
|       } | ||||
|     } ); | ||||
|  | ||||
|     let combatIcon  = html.find('.control-icon.combat'); | ||||
|     if ( combatIcon[0].className.includes('active') ) { | ||||
|       VadentisTokenHud.addExtensionHud( app, html, tokenId); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static _showControlWhen(control, condition) { | ||||
|     if (condition) { | ||||
|       control.show(); | ||||
|     } | ||||
|     else { | ||||
|       control.hide(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) { | ||||
|     const hud = $(await renderTemplate(template, hudData)); | ||||
|     const imgHud = hud.find('img.vadentis-hud-togglebutton'); | ||||
|     const list = hud.find('div.vadentis-hud-list'); | ||||
|  | ||||
|     hud.toggleClass('active'); | ||||
|     VadentisTokenHud._showControlWhen(list, hud.hasClass('active')); | ||||
|  | ||||
|     imgHud.click(event => { | ||||
|       hud.toggleClass('active'); | ||||
|       VadentisTokenHud._showControlWhen(list, hud.hasClass('active')); | ||||
|     }); | ||||
|  | ||||
|     list.find('.vadentis-hud-menu').click(onMenuItem); | ||||
|  | ||||
|     insertionPoint.after(hud); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @@ -13,6 +13,7 @@ import { VadentisItemSheet } from "./vadentis-item-sheet.js"; | ||||
| import { VadentisActorSheet } from "./vadentis-actor-sheet.js"; | ||||
| import { VadentisUtility } from "./vadentis-utility.js"; | ||||
| import { VadentisCombat } from "./vadentis-combat.js"; | ||||
| import { VadentisTokenHud } from "./vadentis-hud.js"; | ||||
|  | ||||
| /* -------------------------------------------- */ | ||||
| /*  Foundry VTT Initialization                  */ | ||||
| @@ -61,6 +62,8 @@ Hooks.once("init", async function () { | ||||
|     VadentisUtility.updateCombat(combat, round, diff, id); | ||||
|   }); | ||||
|  | ||||
|   VadentisTokenHud.init(); | ||||
|    | ||||
| }); | ||||
|  | ||||
| /* -------------------------------------------- */ | ||||
|   | ||||
| @@ -10,7 +10,9 @@ export class VadentisUtility extends Entity { | ||||
|     const templatePaths = [ | ||||
|       'systems/foundryvtt-vadentis/templates/actor-sheet.html', | ||||
|       'systems/foundryvtt-vadentis/templates/item-sheet.html', | ||||
|       'systems/foundryvtt-vadentis/templates/editor-notes-gm.html' | ||||
|       'systems/foundryvtt-vadentis/templates/editor-notes-gm.html', | ||||
|       'systems/foundryvtt-vadentis/templates/hud-actor-attaque.html', | ||||
|       'systems/foundryvtt-vadentis/templates/hud-actor-sort.html' | ||||
|     ] | ||||
|     return loadTemplates(templatePaths);     | ||||
|   } | ||||
|   | ||||
| @@ -742,7 +742,7 @@ ul, li { | ||||
| .control-icon.tokenhudicon.right { | ||||
|   margin-left: 8px; | ||||
| } | ||||
| .rdd-hud-menu label { | ||||
| .vadentis-hud-menu label { | ||||
|   font-size: 0.75rem; | ||||
| } | ||||
| #token-hud .status-effects.active{ | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|   "name": "foundryvtt-vadentis", | ||||
|   "title": "Vadentis", | ||||
|   "description": "Système Vadentis pour FoundryVTT", | ||||
|   "version": "0.1.6", | ||||
|   "version": "0.1.7", | ||||
|   "manifestPlusVersion": "1.0.0", | ||||
|   "minimumCoreVersion": "0.7.5", | ||||
|   "compatibleCoreVersion": "0.7.9", | ||||
|   | ||||
| @@ -291,6 +291,7 @@ | ||||
|                   <img class="sheet-competence-img" src="{{sort.img}}"/> | ||||
|                   <span class="sort-label"><a>{{sort.name}}</a></span> | ||||
|                   <span class="sort-difficulty"><a>{{sort.data.difficulty}}</a></span> | ||||
|                   <span class="generic-label"><a class="sort-damage">{{sort.data.damage}}</a> / <a class="sort-damage-critical">{{sort.data.damagecritical}}</a></span> | ||||
|                   <div class="item-controls"> | ||||
|                     <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a> | ||||
|                     <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a> | ||||
| @@ -306,6 +307,7 @@ | ||||
|                   <img class="sheet-competence-img" src="{{devotion.img}}"/> | ||||
|                   <span class="devotion-label"><a>{{devotion.name}}</a></span> | ||||
|                   <span class="sort-difficulty"><a>{{devotion.data.difficulty}}</a></span> | ||||
|                   <span class="generic-label"><a class="sort-damage">{{devotion.data.damage}}</a> / <a class="sort-damage-critical">{{devotion.data.damagecritical}}</a></span> | ||||
|                   <div class="item-controls"> | ||||
|                     <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a> | ||||
|                     <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a> | ||||
| @@ -324,8 +326,11 @@ | ||||
|             {{#each monnaies as |monnaie key|}} | ||||
|             <li class="item flexrow list-item" data-item-id="{{monnaie._id}}"> | ||||
|               <img class="sheet-competence-img" src="{{monnaie.img}}"/> | ||||
|               <span class="arme-label">{{monnaie.name}}</span> | ||||
|               <span class="arme-label">{{monnaie.data.nombre}}</span> | ||||
|               <span class="generic-label">{{monnaie.name}}</span> | ||||
|               <span class="generic-label">{{monnaie.data.nombre}} | ||||
|                   (<a class="argent-moins">-</a>/<a class="argent-plus">+</a>) | ||||
|               </span>   | ||||
|               </span>               | ||||
|               <div class="item-controls"> | ||||
|                 <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a> | ||||
|                 <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a> | ||||
| @@ -338,7 +343,12 @@ | ||||
|             {{#each armes as |arme key|}} | ||||
|             <li class="item flexrow list-item" data-item-id="{{arme._id}}"> | ||||
|               <img class="sheet-competence-img" src="{{arme.img}}"/> | ||||
|               <span class="arme-label">{{arme.name}} {{#if (eq arme.type "tir")}}({{arme.data.munition}}){{/if}}</span> | ||||
|               <span class="arme-label"><a>{{arme.name}}</a></span>                 | ||||
|               <span class=""> | ||||
|                 {{#if (eq arme.type "tir")}}({{arme.data.munition}}  | ||||
|                 <a class="munition-moins">-</a>/<a class="munition-plus">+</a>) | ||||
|                 {{/if}} | ||||
|               </span> | ||||
|               <div class="item-controls"> | ||||
|                 <a class="item-control item-equip" title="Equipé">{{#if arme.data.equipee}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a> | ||||
|                 <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a> | ||||
|   | ||||
							
								
								
									
										12
									
								
								templates/hud-actor-attaque.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								templates/hud-actor-attaque.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| <div class="control-icon rdd-combat "> | ||||
|   <img class="vadentis-hud-togglebutton" src="systems/foundryvtt-vadentis/images/icons/icone_item_armes_cac.webp" width="36" height="36" title="Attaque"/> | ||||
|   <div class="vadentis-hud-list tokenhudext left"> | ||||
|     {{#each armes as |arme key|}} | ||||
|     {{#if arme.data.equipee}} | ||||
|     <div class="control-icon tokenhudicon vadentis-hud-menu vadentis-attaque" data-combatant-id="{{../combatant._id}}" data-arme-id="{{arme._id}}"  title="{{arme.name}}"> | ||||
|       <label>C:{{arme.name}}</label> | ||||
|     </div> | ||||
|     {{/if}} | ||||
|     {{/each}} | ||||
|   </div> | ||||
| </div> | ||||
							
								
								
									
										10
									
								
								templates/hud-actor-sort.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								templates/hud-actor-sort.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <div class="control-icon vadentis-sort "> | ||||
|   <img class="vadentis-hud-togglebutton" src="systems/foundryvtt-vadentis/images/icons/icone_item_sorts_élémentaires.webp" width="36" height="36" title="Sorts"/> | ||||
|   <div class="vadentis-hud-list tokenhudext right"> | ||||
|     {{#each sorts as |sort key|}} | ||||
|     <div class="control-icon tokenhudicon vadentis-hud-menu vadentis-attaque" data-combatant-id="{{../combatant._id}}" data-sort-id="{{sort._id}}"  title="{{sort.name}}"> | ||||
|       <label>S:{{sort.name}}</label> | ||||
|     </div> | ||||
|     {{/each}} | ||||
|   </div> | ||||
| </div> | ||||
		Reference in New Issue
	
	Block a user