diff --git a/changelog.md b/changelog.md index 19244f02..e1d942a5 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ - boutons pour ajuster les compteurs - visualisation des blessures - click sur blessure pour ajouter/enlever + - gestion des armes ## 12.0.13 - La Chance d'Astrobazzarh - Fix: jets de caractéristiques diff --git a/module/actor-sheet.js b/module/actor-sheet.js index faf3e52f..5e2ff8b6 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -220,7 +220,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { // Points de reve actuel this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', true)) this.html.find('.empoignade-label a').click(async event => RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor))) - this.html.find('.arme-label a').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)))) + this.html.find('.roll-arme').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)))) // Initiative pour l'arme this.html.find('.arme-initiative a').click(async event => { diff --git a/module/actor/export-scriptarium/actor-encart-sheet.js b/module/actor/export-scriptarium/actor-encart-sheet.js index cfd478a8..86670656 100644 --- a/module/actor/export-scriptarium/actor-encart-sheet.js +++ b/module/actor/export-scriptarium/actor-encart-sheet.js @@ -39,7 +39,8 @@ export class RdDActorExportSheet extends RdDActorSheet { async getData() { const formData = await super.getData() // Add any structured, precomputed list of data - formData.export = this.getMappingValues(); + formData.context = Mapping.prepareContext(this.actor) + formData.export = this.getMappingValues(formData.context, this.actor) formData.competences = this.getCompetences(CATEGORIES_COMPETENCES) formData.draconic = this.getCompetences(CATEGORIES_DRACONIC) const legeres = this.actor.nbBlessuresLegeres() @@ -59,13 +60,12 @@ export class RdDActorExportSheet extends RdDActorSheet { return formData } - getMappingValues() { - const context = Mapping.prepareContext(this.actor) + getMappingValues(context, actor) { return Object.fromEntries(Mapping.getMapping().map(it => [it.column, { colName: it.colName ?? it.column, column: it.column, rollClass: it.rollClass, - value: String(it.getter(this.actor, context)) + value: String(it.getter(actor, context)) }])) } diff --git a/module/actor/export-scriptarium/mapping.js b/module/actor/export-scriptarium/mapping.js index 3ffa059c..99a14084 100644 --- a/module/actor/export-scriptarium/mapping.js +++ b/module/actor/export-scriptarium/mapping.js @@ -142,11 +142,11 @@ export class Mapping { const armes = actor.items.filter(it => it.type == ITEM_TYPES.arme) return armes.map(arme => [ - arme.system.tir != "" ? Mapping.prepareArme(actor, arme, 'tir') : undefined, - arme.system.lancer = "" ? Mapping.prepareArme(actor, arme, 'lancer') : undefined, arme.system.unemain ? Mapping.prepareArme(actor, arme, 'unemain') : undefined, arme.system.deuxmains ? Mapping.prepareArme(actor, arme, 'deuxmains') : undefined, - !(arme.system.unemain || arme.system.deuxmains) ? Mapping.prepareArme(actor, arme, 'competence') : undefined + !(arme.system.unemain || arme.system.deuxmains) ? Mapping.prepareArme(actor, arme, 'competence') : undefined, + arme.system.lancer != "" ? Mapping.prepareArme(actor, arme, 'lancer') : undefined, + arme.system.tir != "" ? Mapping.prepareArme(actor, arme, 'tir') : undefined ] .filter(it => it != undefined) ).reduce((a, b) => a.concat(b), []) @@ -160,14 +160,27 @@ export class Mapping { } const dmgArme = RdDItemArme.dommagesReels(arme, maniement) const dommages = dmgArme + RdDBonus.bonusDmg(actor, maniement, dmgArme) + const categorie = Mapping.complementCategorie(arme, maniement) return { - name: arme.name, + name: arme.name + categorie, niveau: Misc.toSignedString(competence.system.niveau), init: Mapping.calculBaseInit(actor, competence.system.categorie) + competence.system.niveau, - dommages: Misc.toSignedString(dommages) + dommages: Misc.toSignedString(dommages), + competence: competence, + arme: arme } } + static complementCategorie(arme, maniement) { + switch (maniement) { + case 'unemain': return (arme.system.deuxmains) ? ' 1 main' : (arme.system.lancer||arme.system.tir) ? ' mêlée': '' + case 'deuxmains': return (arme.system.unemain) ? ' 2 mains' : (arme.system.lancer||arme.system.tir) ? ' mêlée': '' + case 'lancer': return (arme.system.unemain || arme.system.deuxmains || arme.system.tir) ? ' jet' : '' + case 'tir': return (arme.system.unemain || arme.system.deuxmains || arme.system.lancer) ? ' tir' : '' + } + return '' + } + static calculBaseInit(actor, categorie) { const mapping = MAPPING_BASE.find(it => it.column == categorie) if (mapping) { diff --git a/templates/actor/combat.html b/templates/actor/combat.html index 874bf475..776f2b34 100644 --- a/templates/actor/combat.html +++ b/templates/actor/combat.html @@ -13,7 +13,7 @@ data-competence-name="{{arme.system.competence}}" data-tooltip="{{arme.name}}: niveau {{plusMoins arme.system.niveau}}"> - + {{#if arme.img}} {{/if}} diff --git a/templates/actor/export-scriptarium/actor-encart-sheet.hbs b/templates/actor/export-scriptarium/actor-encart-sheet.hbs index e060e44d..3ef6e289 100644 --- a/templates/actor/export-scriptarium/actor-encart-sheet.hbs +++ b/templates/actor/export-scriptarium/actor-encart-sheet.hbs @@ -71,16 +71,12 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=' ' niveau='Niv' init='Init' dommages='+dom'}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_0.value niveau=export.arme_niveau_0.value init=export.arme_init_0.value dommages=export.arme_dommages_0.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_1.value niveau=export.arme_niveau_1.value init=export.arme_init_1.value dommages=export.arme_dommages_1.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_2.value niveau=export.arme_niveau_2.value init=export.arme_init_2.value dommages=export.arme_dommages_2.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_3.value niveau=export.arme_niveau_3.value init=export.arme_init_3.value dommages=export.arme_dommages_3.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_4.value niveau=export.arme_niveau_4.value init=export.arme_init_4.value dommages=export.arme_dommages_4.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_5.value niveau=export.arme_niveau_5.value init=export.arme_init_5.value dommages=export.arme_dommages_5.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_6.value niveau=export.arme_niveau_6.value init=export.arme_init_6.value dommages=export.arme_dommages_6.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_7.value niveau=export.arme_niveau_7.value init=export.arme_init_7.value dommages=export.arme_dommages_7.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_8.value niveau=export.arme_niveau_8.value init=export.arme_init_8.value dommages=export.arme_dommages_8.value}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" name=export.arme_name_9.value niveau=export.arme_niveau_9.value init=export.arme_init_9.value dommages=export.arme_dommages_9.value}} + {{#each context.armes as |arme|}} + {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs" + name=arme.name niveau=arme.niveau init=arme.init dommages=arme.dommages + arme=arme.arme competence=arme.competence + }} + {{/each}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/esquive.hbs" name='Esquive' niveau=export.esquive.value}} {{#if (gt export.malue_armure.value 0)}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/esquive.hbs" name='Esquive (avec armure)' niveau=export.esquive_armure.value}} diff --git a/templates/actor/export-scriptarium/arme.hbs b/templates/actor/export-scriptarium/arme.hbs index dee9e508..ea3a63a3 100644 --- a/templates/actor/export-scriptarium/arme.hbs +++ b/templates/actor/export-scriptarium/arme.hbs @@ -1,6 +1,9 @@ {{#if name}} -