diff --git a/changelog.md b/changelog.md index 88a29d27..5911eb03 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # 12.0 +## 12.0.28 - Les réserves d'Astrobazzarh +- possibilité de mettre en réserve depuis un sort connu + ## 12.0.27 - Les vêtements d'Astrobazzarh - Ajout de la liste des armures dans l'onglet caractéristiques - Ajout d'une option pour choisir une carte des TMR alternatives @@ -115,11 +118,9 @@ - encodage de l'export en windows-1252 - export de l'esquive avec armure et sans armure -## 12.0.10 - Le scriptorium d'Astrobazzarh +## 12.0.9 - 12.0.10 - Le scriptorium d'Astrobazzarh - corrections de l'export scriptarium - -## 12.0.9 - Le scriptorium d'Astrobazzarh -- ajout d'une fonction avancée pour exporter les personnages dans un format csv +- ajout d'une fonction avancée pour un exporter "scriptarium" des personnages ## 12.0.8 - La quincaillerie d'Astrobazzarh - le propriétaire est indiqué dans les feuilles d'équipements/compétences/... diff --git a/module/actor-sheet.js b/module/actor-sheet.js index fe6560d7..a236b19e 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -183,7 +183,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { // Equip Inventory Item this.html.find('.item-equip').click(async event => this.actor.equiperObjet(RdDSheetUtility.getItemId(event))) - this.html.find('.chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle')) + this.html.find('.roll-chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle')) this.html.find('.button-appel-chance').click(async event => this.actor.rollAppelChance()) @@ -214,7 +214,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { // Boutons spéciaux MJs this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ")) this.html.find('.don-de-haut-reve').click(async event => this.actor.addDonDeHautReve()) - this.html.find('.nouveau-sort-reserve').click(async event => this.actor.addSortReserve()) + this.html.find('.sortreserve-add').click(async event => this.actor.addSortReserve(RdDSheetUtility.getItemId(event))) this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible()) } @@ -284,6 +284,8 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { this.html.find('.ptreve-actuel-plus').click(async event => this.actor.reveActuelIncDec(1)) this.html.find('.ptreve-actuel-moins').click(async event => this.actor.reveActuelIncDec(-1)) + this.html.find('.chance-actuelle-plus').click(async event => this.actor.chanceActuelleIncDec(1)) + this.html.find('.chance-actuelle-moins').click(async event => this.actor.chanceActuelleIncDec(-1)) this.html.find('.fatigue-plus').click(async event => this.actor.santeIncDec("fatigue", 1)) this.html.find('.fatigue-moins').click(async event => this.actor.santeIncDec("fatigue", -1)) } diff --git a/module/actor.js b/module/actor.js index 24530d60..ec1f1324 100644 --- a/module/actor.js +++ b/module/actor.js @@ -95,11 +95,14 @@ export class RdDActor extends RdDBaseActorSang { isHautRevant() { return this.system.attributs.hautrevant.value != "" } /* -------------------------------------------- */ - getAgilite() { return this.system.carac.agilite?.value ?? 0 } - getChance() { return this.system.carac.chance?.value ?? 0 } + getAgilite() { return Misc.toInt(this.system.carac.agilite?.value ?? 0) } + getChance() { return Misc.toInt(this.system.carac.chance?.value ?? 0) } - getReveActuel() { return this.system.reve?.reve?.value ?? this.carac.reve.value ?? 0 } - getChanceActuel() { return this.system.compteurs.chance?.value ?? 10 } + getReveActuel() { return Misc.toInt(this.system.reve?.reve?.value) ?? this.carac.reve.value ?? 0 } + getChanceActuel() { + return Number.isNumeric(this.system.compteurs.chance.value) ? + Misc.toInt(this.system.compteurs.chance.value) : this.getChance() + } getMoralTotal() { return this.system.compteurs.moral?.value ?? 0 } getEnduranceMax() { return Math.max(1, Math.max(this.getTaille() + this.getConstitution(), this.getVieMax() + this.getVolonte())) } @@ -991,21 +994,31 @@ export class RdDActor extends RdDBaseActorSang { } } - async addSortReserve() { + async addSortReserve(itemId) { + if (itemId) { + const item = this.items.get(itemId) + if (item.type == ITEM_TYPES.sort && !item.system.isrituel) { + this.$createSortReserve(item) + return + } + } const selectSortReserve = { title: "Créer un sort en réserve", label: "Choisir un sort", list: this.itemTypes[ITEM_TYPES.sort].filter(it => !it.system.isrituel) } - DialogSelect.select(selectSortReserve, sort => - this.createEmbeddedDocuments("Item", - [{ - type: ITEM_TYPES.sortreserve, - name: sort.name, - img: sort.img, - system: { sortid: sort.id, draconic: sort.system.draconic, ptreve: Number(sort.system.ptreve.match(/\d+/)), coord: 'A1', heurecible: 'Vaisseau' } - }], - { renderSheet: true })) + DialogSelect.select(selectSortReserve, sort => this.$createSortReserve(sort)) + } + + $createSortReserve(sort) { + this.createEmbeddedDocuments("Item", + [{ + type: ITEM_TYPES.sortreserve, + name: sort.name, + img: sort.img, + system: { sortid: sort.id, draconic: sort.system.draconic, ptreve: Number(sort.system.ptreve.match(/\d+/)), coord: 'A1', heurecible: 'Vaisseau' } + }], + { renderSheet: true }) } /* -------------------------------------------- */ async reinsertionAleatoire(raison, accessible = tmr => true) { @@ -1070,6 +1083,11 @@ export class RdDActor extends RdDBaseActorSang { await this.update({ "system.reve.reve.value": reve }); } + async chanceActuelleIncDec(value) { + const chance = Math.min(this.getChance(), Math.max(this.getChanceActuel() + value, 0)); + await this.update({ "system.compteurs.chance.value": chance }); + } + /* -------------------------------------------- */ async regainPointDeSeuil() { const seuil = Misc.toInt(this.system.reve.seuil.value); @@ -2254,12 +2272,6 @@ export class RdDActor extends RdDBaseActorSang { } } - /* -------------------------------------------- */ - async chanceActuelleIncDec(value) { - const chance = Math.min(this.getChance(), Math.max(this.getChanceActuel() + value, 0)); - await this.updateCompteurValue("chance", chance); - } - /* -------------------------------------------- */ async appelDestinee(onSuccess = () => { }, onEchec = () => { }) { let destinee = this.system.compteurs.destinee?.value ?? 0; diff --git a/module/actor/base-actor-reve-sheet.js b/module/actor/base-actor-reve-sheet.js index c4ebac2b..996f8f08 100644 --- a/module/actor/base-actor-reve-sheet.js +++ b/module/actor/base-actor-reve-sheet.js @@ -48,6 +48,19 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet { }], { renderSheet: true }) ) + if (this.options.vueDetaillee) { + // On carac change + this.html.find('.carac-value').change(async event => { + let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", ""); + this.actor.updateCarac(caracName, parseInt(event.target.value)); + }); + // On competence change + this.html.find('.competence-value').change(async event => { + let compName = event.currentTarget.attributes.compname.value; + //console.log("Competence changed :", compName); + this.actor.updateCompetence(compName, parseInt(event.target.value)); + }); + } } } diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js index c83106b7..5d88b2f4 100644 --- a/module/actor/base-actor-sheet.js +++ b/module/actor/base-actor-sheet.js @@ -177,21 +177,6 @@ export class RdDBaseActorSheet extends ActorSheet { this.options.vueDetaillee = !this.options.vueDetaillee; this.render(true); }); - - if (this.options.vueDetaillee) { - // On carac change - this.html.find('.carac-value').change(async event => { - let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", ""); - this.actor.updateCarac(caracName, parseInt(event.target.value)); - }); - // On competence change - this.html.find('.competence-value').change(async event => { - let compName = event.currentTarget.attributes.compname.value; - //console.log("Competence changed :", compName); - this.actor.updateCompetence(compName, parseInt(event.target.value)); - }); - } - } _rechercherKeyup(event) { diff --git a/module/actor/export-scriptarium/mapping.js b/module/actor/export-scriptarium/mapping.js index 88912f49..966f4055 100644 --- a/module/actor/export-scriptarium/mapping.js +++ b/module/actor/export-scriptarium/mapping.js @@ -83,6 +83,7 @@ const MAPPING_BASE = [ { column: "protectionarmure", colName: 'Protection', getter: (actor, context) => Mapping.getProtectionArmure(actor, context) }, { column: "malus_armure", getter: (actor, context) => Mapping.getMalusArmure(actor, context) }, { column: "reve_actuel", rollClass: 'roll-reve-actuel', colName: 'Rêve actuel', getter: (actor, context) => actor.system.reve.reve.value }, + { column: "chance_actuel", rollClass: 'roll-chance-actuelle', colName: 'Chance actuelle', getter: (actor, context) => actor.system.compteurs.chance.value }, { column: "vie_actuel", rollClass: 'jet-vie', getter: (actor, context) => actor.system.sante.vie.value }, { column: "endurance_actuel", rollClass: 'jet-endurance', getter: (actor, context) => actor.system.sante.endurance.value }, { column: "esquive", getter: (actor, context) => Mapping.getEsquive(context) }, diff --git a/module/apps/rdd-import-stats.js b/module/apps/rdd-import-stats.js index b1a9f0be..4cff1ab7 100644 --- a/module/apps/rdd-import-stats.js +++ b/module/apps/rdd-import-stats.js @@ -26,7 +26,7 @@ const MANIEMENTS = { 'de lancer': (weapon) => { return { name: weapon.system.lancer, categorie: 'lancer' } }, 'de jet': (weapon) => { return { name: weapon.system.lancer, categorie: 'lancer' } }, 'à une main': (weapon) => { return { name: weapon.system.competence, categorie: 'melee' } }, - 'à deux main': (weapon) => { return { name: weapon.system.competence.replace("à 1 main", "à 2 main"), categorie: 'melee' } }, + 'à deux mains': (weapon) => { return { name: weapon.system.competence.replace("à 1 main", "à 2 mains"), categorie: 'melee' } }, 'mêlée': (weapon) => { return { name: weapon.system.competence, categorie: 'melee' } }, } const XREGEXP_WEAPON_MANIEMENT = "(?(" + Misc.join(Object.keys(MANIEMENTS), '|') + "))" @@ -267,7 +267,7 @@ export class RdDStatBlockParser { } let weapMatch = XRegExp.exec(statString, XRegExp(weapon.name + "(\\s*" + XREGEXP_WEAPON_MANIEMENT + ")?" - + "\\s+(?\\+\\d+)", 'giu')); + + "\\s+(?[\\+\\-]?\\d+)", 'giu')); if (weapMatch) { weapon = weapon.toObject(); weapon.system.equipe = 'true'; @@ -479,12 +479,12 @@ export class RdDStatBlockParser { let namePersonnage = "Importé" if (statString.includes(", né")) { // Name is all string before first comma ',' - namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\s\\d]+),", 'giu')); + namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\-\\s\\d]+),", 'giu')); } else { - namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\s\\d]+)\\s+TAILLE", 'giu')); + namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\-\\s\\d]+)\\s+TAILLE", 'giu')); } if (namePersonnage?.value) { - return Misc.upperFirst(namePersonnage?.value); + return Misc.upperFirst(namePersonnage?.value.toLowerCase()); } } const name = XRegExp.exec(statString, XRegExp("(?.+)\\s+taille", 'giu')); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 8e9ed24a..d3939bc8 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -261,8 +261,25 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html' ]; + + // foundry et options + Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path]) + Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name)); + Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option)); + Handlebars.registerHelper('plusMoins', diff => (diff > 0 ? '+' : '') + Math.round(diff)) + + // Handle v12 removal of this helper + Handlebars.registerHelper('select', function (selected, options) { + const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected)); + const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']'); + const html = options.fn(this); + return html.replace(rgx, "$& selected"); + }) + + // logic Handlebars.registerHelper('either', (a, b) => a ?? b); + // string manipulation Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null')); Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null')); Handlebars.registerHelper('uppercase', str => str?.toUpperCase() ?? ''); @@ -271,48 +288,53 @@ export class RdDUtility { Handlebars.registerHelper('grammar-apostrophe', (article, str) => Grammar.apostrophe(article, str)); Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str)); Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args)); - - Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path]) + + // math + Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1))); + Handlebars.registerHelper('repeat', function(n, block) { + let accum = ''; + for(let i = 0; i < n; ++i){ + accum += block.fn(i) + } + return accum + }) + + // tableaux, listes + Handlebars.registerHelper('array-includes', (array, value) => array.includes(value)); + Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length); + Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name))); + + // table de résolution Handlebars.registerHelper('computeResolutionScore', (row, col) => RdDResolutionTable.computePercentage(row, col)); Handlebars.registerHelper('computeResolutionChances', (row, col) => RdDResolutionTable.computeChances(row, col)); - Handlebars.registerHelper('buildLigneInventaire', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildLigneInventaire(item, options)); }); - Handlebars.registerHelper('buildInventaireConteneur', (actorId, itemId, options) => { return new Handlebars.SafeString(RdDUtility.buildInventaireConteneur(actorId, itemId, options)); }); - Handlebars.registerHelper('buildContenuConteneur', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildContenuConteneur(item, options)); }); - Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant()); - Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord)); - Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord)); - Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type)); - Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord)); + // gestion des dates et heures Handlebars.registerHelper('timestamp-imgSigneHeure', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigneHeure(heure)) }); Handlebars.registerHelper('timestamp-imgSigne', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigne(heure)) }); Handlebars.registerHelper('timestamp-extract', timestamp => new RdDTimestamp(timestamp).toCalendrier()); Handlebars.registerHelper('timestamp-formulesDuree', () => RdDTimestamp.formulesDuree()); Handlebars.registerHelper('timestamp-formulesPeriode', () => RdDTimestamp.formulesPeriode()); - + + // informations sur les acteurs Handlebars.registerHelper('actor-default', (actorType, ...path) => RdDBaseActor.getDefaultValue(actorType, path.slice(0, -1))); - - Handlebars.registerHelper('array-includes', (array, value) => array.includes(value)); - Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1))); - Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length); - Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option)); - Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name))); Handlebars.registerHelper('filtreTriCompetences', competences => RdDItemCompetence.triVisible(competences)); - Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name)); + Handlebars.registerHelper('experienceLog-topic', topic => ExperienceLog.labelTopic(topic)); + + // inventaire et marchands + Handlebars.registerHelper('buildLigneInventaire', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildLigneInventaire(item, options)); }); + Handlebars.registerHelper('buildInventaireConteneur', (actorId, itemId, options) => { return new Handlebars.SafeString(RdDUtility.buildInventaireConteneur(actorId, itemId, options)); }); + Handlebars.registerHelper('buildContenuConteneur', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildContenuConteneur(item, options)); }); + Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant()); Handlebars.registerHelper('uniteQuantite', (itemId, actorId) => RdDUtility.getItem(itemId, actorId)?.getUniteQuantite()); Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field)); + // Items Handlebars.registerHelper('rarete-getChamp', (rarete, field) => RdDRaretes.getChamp(rarete, field)); - - Handlebars.registerHelper('plusMoins', diff => (diff > 0 ? '+' : '') + Math.round(diff)) - Handlebars.registerHelper('experienceLog-topic', topic => ExperienceLog.labelTopic(topic)); - - // Handle v12 removal of this helper - Handlebars.registerHelper('select', function (selected, options) { - const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected)); - const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']'); - const html = options.fn(this); - return html.replace(rgx, "$& selected"); - }); + + // TMRs + Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord)); + Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord)); + Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type)); + Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord)); return loadTemplates(templatePaths); } diff --git a/styles/simple.css b/styles/simple.css index 37d15512..6b1949fe 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -816,12 +816,12 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) { .competence-list .item-controls.hidden-controls { display: none !important; } -.item-controls i:is(.fas, .fa, .fa-solid) { +.item-controls i:is(.fas, .fa, .fa-solid, .fa-regular) { font-size: 0.8em; color: var(--color-controls); } -.item-controls i:is(.fas, .far, .fa-solid):hover { - opacity: 0.7 ; +.item-controls i:is(.fas, .far, .fa-solid, .fa-regular):hover { + opacity: 0.6; } .rdd-roll-dialog .description-sort { diff --git a/templates/actor/carac-derivee.html b/templates/actor/carac-derivee.html index bfe92d70..bee167b2 100644 --- a/templates/actor/carac-derivee.html +++ b/templates/actor/carac-derivee.html @@ -37,7 +37,7 @@
  • - +
  • diff --git a/templates/actor/export-scriptarium/actor-encart-sheet.hbs b/templates/actor/export-scriptarium/actor-encart-sheet.hbs index b98f27e9..bb10bcc2 100644 --- a/templates/actor/export-scriptarium/actor-encart-sheet.hbs +++ b/templates/actor/export-scriptarium/actor-encart-sheet.hbs @@ -54,7 +54,7 @@ {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs" carac=export.empathie}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs" carac=export.intellect}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-compteur.hbs" carac=export.reve actuel=export.reve_actuel button-name='ptreve-actuel'}} - {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs" carac=export.chance}} + {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-compteur.hbs" carac=export.chance actuel=export.chance_actuel button-name='chance-actuelle'}}
    {{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-derivee.hbs" carac=export.melee}} diff --git a/templates/actor/hr-sorts-reserve.html b/templates/actor/hr-sorts-reserve.html index eaa7a13c..ed9bd240 100644 --- a/templates/actor/hr-sorts-reserve.html +++ b/templates/actor/hr-sorts-reserve.html @@ -1,6 +1,7 @@ {{#if sortsReserve.length}} -

    Sorts en Réserve{{#if options.isGM}} - {{/if}} +

    Sorts en Réserve{{#if options.isGM}} + +{{/if}}

      {{#each (trier sortsReserve) as |sort key|}} diff --git a/templates/actor/hr-sorts.html b/templates/actor/hr-sorts.html index 7cb9249f..0f9d1c72 100644 --- a/templates/actor/hr-sorts.html +++ b/templates/actor/hr-sorts.html @@ -2,19 +2,28 @@

      Sorts

        {{#each (trier sorts) as |sort key|}} -
      • +
      • {{itemSort-shortDraconic sort.system.draconic}} - {{sort.name}}{{#if sort.system.isrituel}} - {{/if}} + {{sort.name}} + {{#if sort.system.isrituel}}{{/if}} + {{#if sort.system.coutseuil}} + {{#repeat sort.system.coutseuil}}{{/repeat}} + {{/if}} + {{#if sort.system.caseTMRspeciale}}{{sort.system.caseTMRspeciale}}{{else}}{{upperFirst sort.system.caseTMR}}{{/if}} - + R{{itemSort-spaceIfText sort.system.difficulte}} r{{itemSort-spaceIfText sort.system.ptreve}}
        + {{#if (and @root.options.isGM (not sort.system.isrituel))}} + + + + {{/if}}
      • {{/each}}