diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js index eabaf828..ce0d51a2 100644 --- a/module/actor-entite-sheet.js +++ b/module/actor-entite-sheet.js @@ -22,13 +22,6 @@ export class RdDActorEntiteSheet extends ActorSheet { }); } - /* -------------------------------------------- */ - _checkNull(items) { - if (items && items.length) { - return items; - } - return []; - } /* -------------------------------------------- */ async getData() { diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js index 43b20810..e6cf1fbc 100644 --- a/module/actor-vehicule-sheet.js +++ b/module/actor-vehicule-sheet.js @@ -25,14 +25,6 @@ export class RdDActorVehiculeSheet extends ActorSheet { }); } - /* -------------------------------------------- */ - _checkNull(items) { - if (items && items.length) { - return items; - } - return []; - } - /* -------------------------------------------- */ async getData() { const objectData = Misc.data(this.object); diff --git a/module/actor.js b/module/actor.js index 5e97c81e..7bb90623 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2838,20 +2838,19 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async _meditationResult(meditationData) { + async _meditationResult(meditationRoll) { this.santeIncDec("fatigue", 2); - const signeData = RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditationData.meditation, meditationData.rolled) - if (signeData) { - await this.createEmbeddedDocuments("Item", [signeData]); + if (meditationRoll.rolled.isSuccess) { + await this.createEmbeddedDocuments("Item", [RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditationRoll.meditation, meditationRoll.rolled)]); } - await RdDResolutionTable.displayRollData(meditationData, this.name, 'chat-resultat-meditation.html'); + await RdDResolutionTable.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.html'); } /* -------------------------------------------- */ - _meditationEPart(meditationData) { - this.updateEmbeddedDocuments('Item', [{ _id: meditationData._id, 'data.malus': meditationData.meditation.data.malus - 1 }]); + _meditationEPart(meditationRoll) { + this.updateEmbeddedDocuments('Item', [{ _id: meditationRoll.meditation._id, 'data.malus': meditationRoll.meditation.data.malus - 1 }]); } @@ -3278,11 +3277,11 @@ export class RdDActor extends Actor { protection = Math.max(protection - penetration, 0); protection += this.getProtectionNaturelle(); // Gestion des cas particuliers sur la fenêtre d'encaissement - if (attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "noarmure") { + if (attackerRoll.dmg.encaisserSpecial == "noarmure") { protection = 0; } - if (attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "chute" && Number(protection) > 2) { - protection = 2; + if (attackerRoll.dmg.encaisserSpecial == "chute") { + protection = Math.min(protection, 2); } console.log("Final protect", protection, attackerRoll); return protection; @@ -3290,20 +3289,25 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ _deteriorerArmure(item, dmg) { - if (!ReglesOptionelles.isUsing('deteriorationArmure')) { + let itemData = duplicate(Misc.data(item)); + if (!ReglesOptionelles.isUsing('deteriorationArmure') || itemData.data.protection == '0') { return; } - let itemData = duplicate(Misc.data(item)); itemData.data.deterioration = (itemData.data.deterioration ?? 0) + dmg; if (itemData.data.deterioration >= 10) { - itemData.data.deterioration = 0; - let res = /\d+/.exec(itemData.data.protection); - if (!res) { - itemData.data.protection = "1d" + itemData.data.protection; + itemData.data.deterioration -= 10; + let res = /(\d+)?d(\d+)(\-\d+)?/.exec(itemData.data.protection); + if (res) { + let malus = Misc.toInt(res[3]) - 1; + let armure = Misc.toInt(res[2]); + if (armure+malus <= 0){ + itemData.data.protection = 0; + } else { + itemData.data.protection = '' + (res[1]??'1') + 'd' + armure + malus; + } } - else if (res = /(\d+d\d+)(\-\d+)?/.exec(itemData.data.protection)) { - let malus = Misc.toInt(res[2]) - 1; - itemData.data.protection = res[1] + malus; + else if (/\d+/.exec(itemData.data.protection)) { + itemData.data.protection = "1d" + itemData.data.protection; } else { ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`); diff --git a/module/item-meditation.js b/module/item-meditation.js index 7ba0b076..fb77f098 100644 --- a/module/item-meditation.js +++ b/module/item-meditation.js @@ -3,7 +3,7 @@ export class RdDItemMeditation { static calculDifficulte(rollData) { if (rollData.meditation) { // Malus permanent éventuel - let diff = -rollData.meditation.data.malus ?? 0; + let diff = rollData.meditation.data.malus ?? 0; if (!rollData.conditionMeditation.isHeure) diff -= 2; if (!rollData.conditionMeditation.isVeture) diff -= 2; if (!rollData.conditionMeditation.isComportement) diff -= 2; diff --git a/module/item-signedraconique.js b/module/item-signedraconique.js index 6e6e75c0..b540a9aa 100644 --- a/module/item-signedraconique.js +++ b/module/item-signedraconique.js @@ -13,25 +13,24 @@ const tableSignesIndicatifs = [ ] +const DIFFICULTE_LECTURE_SIGNE_MANQUE = +11; + export class RdDItemSigneDraconique { static prepareSigneDraconiqueMeditation(meditation, rolled) { - if (rolled.isSuccess != undefined) { - meditation = Misc.data(meditation); - return { - name: "de la " + meditation.name, - type: "signedraconique", - img: meditation.img, - data: { - typesTMR: [TMRUtility.typeTmrName(meditation.data.tmr)], - difficulte: RdDItemSigneDraconique.getDiffSigneMeditation(rolled.code), - ephemere: true, - duree: "1 round", - valeur: { "norm": 3, "sign": 5, "part": 10 } - } - }; - } - return undefined; + meditation = Misc.data(meditation); + return { + name: "de la " + meditation.name, + type: "signedraconique", + img: meditation.img, + data: { + typesTMR: [TMRUtility.typeTmrName(meditation.data.tmr)], + difficulte: rolled.isSuccess ? RdDItemSigneDraconique.getDiffSigneMeditation(rolled.code) : DIFFICULTE_LECTURE_SIGNE_MANQUE, + ephemere: true, + duree: "1 round", + valeur: rolled.isSuccess ? { "norm": 3, "sign": 5, "part": 10 } : { "norm": 0, "sign": 0, "part": 0 } + } + }; } static getDiffSigneMeditation(code) { @@ -44,7 +43,7 @@ export class RdDItemSigneDraconique { } static getXpSortSigneDraconique(code, signe) { - return Misc.data(signe).data.valeur[code] ?? 0; + return Misc.toInt(Misc.data(signe).data.valeur[code] ?? 0); } static calculValeursXpSort(qualite, valeur, avant) { diff --git a/module/rdd-combat.js b/module/rdd-combat.js index ea574f09..1f42618e 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -465,15 +465,15 @@ export class RdDCombat { } /* -------------------------------------------- */ - static onMsgEncaisser(data) { - let defender = canvas.tokens.get(data.defenderTokenId).actor; + static onMsgEncaisser(msg) { + let defender = canvas.tokens.get(msg.defenderTokenId).actor; if (Misc.isOwnerPlayerOrUniqueConnectedGM()) { - let attackerRoll = data.attackerRoll; - let attacker = data.attackerId ? game.actors.get(data.attackerId) : null; + let attackerRoll = msg.attackerRoll; + let attacker = msg.attackerId ? game.actors.get(msg.attackerId) : null; defender.encaisserDommages(attackerRoll, attacker); - RdDCombat._deleteDefense(attackerRoll.passeArme); - RdDCombat._deleteAttaque(data.attackerId); + const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); + rddCombat?.removeChatMessageActionsPasseArme(attackerRoll.passeArme); } } @@ -482,11 +482,8 @@ export class RdDCombat { let defenderToken = canvas.tokens.get(msg.defenderTokenId); if (defenderToken && Misc.isUniqueConnectedGM()) { const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); - if (rddCombat) { - const defenderRoll = msg.defenderRoll; - rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme); - rddCombat._chatMessageDefense(msg.paramChatDefense, msg.defenderRoll); - } + rddCombat?.removeChatMessageActionsPasseArme(msg.defenderRoll.passeArme); + rddCombat?._chatMessageDefense(msg.paramChatDefense, msg.defenderRoll); } } @@ -1005,8 +1002,7 @@ export class RdDCombat { await this.computeRecul(defenderRoll); await this.computeDeteriorationArme(defenderRoll); await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html'); - - RdDCombat._deleteDefense(defenderRoll.passeArme); + this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); } /* -------------------------------------------- */ @@ -1077,7 +1073,7 @@ export class RdDCombat { async _onEsquiveNormale(defenderRoll) { console.log("RdDCombat._onEsquiveNormal >>>", defenderRoll); await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-esquive.html'); - RdDCombat._deleteDefense(defenderRoll.passeArme); + this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); } /* -------------------------------------------- */ @@ -1217,7 +1213,6 @@ export class RdDCombat { } }); } - RdDCombat._deleteDefense(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 1c43cdc8..786ad9b1 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -326,8 +326,8 @@ export class RdDUtility { } /* -------------------------------------------- */ - static checkNull(items) { - if (items && items.length) { + static arrayOrEmpty(items) { + if (items?.length) { return items; } return []; @@ -360,44 +360,44 @@ export class RdDUtility { RdDUtility.filterEquipementParType(formData); - formData.sorts = this.checkNull(formData.itemsByType['sort']); - formData.signesdraconiques = this.checkNull(formData.itemsByType['signedraconique']); - formData.queues = this.checkNull(formData.itemsByType['queue']); - formData.souffles = this.checkNull(formData.itemsByType['souffle']); - formData.ombres = this.checkNull(formData.itemsByType['ombre']); - formData.tetes = this.checkNull(formData.itemsByType['tete']); - formData.taches = this.checkNull(formData.itemsByType['tache']); - formData.meditations = this.checkNull(formData.itemsByType['meditation']); - formData.chants = this.checkNull(formData.itemsByType['chant']); - formData.danses = this.checkNull(formData.itemsByType['danse']); - formData.musiques = this.checkNull(formData.itemsByType['musique']); - formData.oeuvres = this.checkNull(formData.itemsByType['oeuvre']); - formData.jeux = this.checkNull(formData.itemsByType['jeu']); + formData.sorts = this.arrayOrEmpty(formData.itemsByType['sort']); + formData.signesdraconiques = this.arrayOrEmpty(formData.itemsByType['signedraconique']); + formData.queues = this.arrayOrEmpty(formData.itemsByType['queue']); + formData.souffles = this.arrayOrEmpty(formData.itemsByType['souffle']); + formData.ombres = this.arrayOrEmpty(formData.itemsByType['ombre']); + formData.tetes = this.arrayOrEmpty(formData.itemsByType['tete']); + formData.taches = this.arrayOrEmpty(formData.itemsByType['tache']); + formData.meditations = this.arrayOrEmpty(formData.itemsByType['meditation']); + formData.chants = this.arrayOrEmpty(formData.itemsByType['chant']); + formData.danses = this.arrayOrEmpty(formData.itemsByType['danse']); + formData.musiques = this.arrayOrEmpty(formData.itemsByType['musique']); + formData.oeuvres = this.arrayOrEmpty(formData.itemsByType['oeuvre']); + formData.jeux = this.arrayOrEmpty(formData.itemsByType['jeu']); - formData.recettescuisine = this.checkNull(formData.itemsByType['recettecuisine']); - formData.recettesAlchimiques = this.checkNull(formData.itemsByType['recettealchimique']); - formData.maladies = this.checkNull(formData.itemsByType['maladie']); - formData.poisons = this.checkNull(formData.itemsByType['poison']); - formData.possessions = this.checkNull(formData.itemsByType['possession']); + formData.recettescuisine = this.arrayOrEmpty(formData.itemsByType['recettecuisine']); + formData.recettesAlchimiques = this.arrayOrEmpty(formData.itemsByType['recettealchimique']); + formData.maladies = this.arrayOrEmpty(formData.itemsByType['maladie']); + formData.poisons = this.arrayOrEmpty(formData.itemsByType['poison']); + formData.possessions = this.arrayOrEmpty(formData.itemsByType['possession']); formData.maladiesPoisons = formData.maladies.concat(formData.poisons); formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []); } static filterEquipementParType(formData) { - formData.conteneurs = this.checkNull(formData.itemsByType['conteneur']); + formData.conteneurs = this.arrayOrEmpty(formData.itemsByType['conteneur']); - formData.materiel = this.checkNull(formData.itemsByType['objet']); - formData.armes = this.checkNull(formData.itemsByType['arme']); - formData.armures = this.checkNull(formData.itemsByType['armure']); - formData.munitions = this.checkNull(formData.itemsByType['munition']); - formData.livres = this.checkNull(formData.itemsByType['livre']); - formData.potions = this.checkNull(formData.itemsByType['potion']); - formData.ingredients = this.checkNull(formData.itemsByType['ingredient']); - formData.herbes = this.checkNull(formData.itemsByType['herbe']); - formData.monnaie = this.checkNull(formData.itemsByType['monnaie']); + formData.materiel = this.arrayOrEmpty(formData.itemsByType['objet']); + formData.armes = this.arrayOrEmpty(formData.itemsByType['arme']); + formData.armures = this.arrayOrEmpty(formData.itemsByType['armure']); + formData.munitions = this.arrayOrEmpty(formData.itemsByType['munition']); + formData.livres = this.arrayOrEmpty(formData.itemsByType['livre']); + formData.potions = this.arrayOrEmpty(formData.itemsByType['potion']); + formData.ingredients = this.arrayOrEmpty(formData.itemsByType['ingredient']); + formData.herbes = this.arrayOrEmpty(formData.itemsByType['herbe']); + formData.monnaie = this.arrayOrEmpty(formData.itemsByType['monnaie']); formData.monnaie.sort(Monnaie.triValeurDenier()); - formData.nourritureboissons = this.checkNull(formData.itemsByType['nourritureboisson']); - formData.gemmes = this.checkNull(formData.itemsByType['gemme']); + formData.nourritureboissons = this.arrayOrEmpty(formData.itemsByType['nourritureboisson']); + formData.gemmes = this.arrayOrEmpty(formData.itemsByType['gemme']); formData.objets = formData.conteneurs .concat(formData.materiel) diff --git a/module/tmr/pixi-tmr.js b/module/tmr/pixi-tmr.js index 368e0e00..a5f6cbbe 100644 --- a/module/tmr/pixi-tmr.js +++ b/module/tmr/pixi-tmr.js @@ -25,7 +25,7 @@ export class PixiTMR { for (const [name, img] of Object.entries(PixiTMR.textures)) { loader = loader.add(name, img); } - loader.onLoad.add((error, resaon) => { console.log("ERROR", error, resaon) }); + loader.onLoad.add((error, reason) => { console.log("ERROR", error, reason) }); loader.load( (loader, resources) => { onLoad(loader, resources); for (let onAnimate of this.callbacksOnAnimate) { diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 0556d602..b9d3e4d0 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -55,7 +55,6 @@ {{/each}}
  • Total Caractéristiques - {{log 'data-actor-creature' this}} {{calc.caracTotal}}
  • diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index d151bd16..88e76ad8 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -307,7 +307,6 @@ {{esq.name}} - {{log esq}} @@ -509,65 +508,8 @@
    - {{#if data.attributs.hautrevant.value}} - {{#if options.isGM}} -

    Signes draconiques

    - - {{/if}} -

    Sorts:

    - - -

    Sorts en Réserve:

    - - -

    Méditations:

    - -
    - {{/if}} {{!-- Queues, Souffles, Tetes, Ombre --}} + {{#if queues.length}}

    Queues:

    -

    Souffles:

    - -

    Tetes:

    - + {{/if}} + {{#if ombres.length}}

    Ombres de Thanatos:

    + {{/if}} + {{#if souffles.length}} +

    Souffles:

    + + {{/if}} + {{#if tetes.length}} +

    Tetes:

    + + {{/if}} {{#if data.attributs.hautrevant.value}} + {{#if (and options.isGM signesdraconiques.length)}} +

    Signes draconiques

    + + {{/if}} + + {{#if hautreve.rencontres.length}} +

    Rencontres présentes:

    + + {{/if}} + {{#if hautreve.sortsReserve.length}} +

    Sorts en Réserve:

    + + {{/if}} + +
    + +

    Sorts:

    + + +

    Méditations:

    +
    -

    Rencontres présentes:

    - -
    -

    Cases Spéciales:

    - + {{#if hautreve.casesTmr}} +

    Cases Spéciales:

    + + {{/if}}

    {{/if}} diff --git a/templates/dialog-roll-signedraconique.html b/templates/dialog-roll-signedraconique.html index bf8fd8b2..051341ec 100644 --- a/templates/dialog-roll-signedraconique.html +++ b/templates/dialog-roll-signedraconique.html @@ -1,4 +1,3 @@ -{{log 'lecture signe draconique' this}}

    Lire le signe draconique