diff --git a/module/actor-sheet.js b/module/actor-sheet.js index d0f05218..ecbbdf66 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -435,6 +435,10 @@ export class RdDActorSheet extends ActorSheet { this.actor.setPointsDeSeuil(event.currentTarget.value); } ); + html.find('#attribut-protection-edit').change((event) => { + this.actor.updateProtectionValue( event.currentTarget.attributes.name.value, parseInt(event.target.value) ); + } ); + // On stress change html.find('.compteur-edit').change((event) => { let fieldName = event.currentTarget.attributes.name.value; diff --git a/module/actor.js b/module/actor.js index 03f9fb27..5b0d4d53 100644 --- a/module/actor.js +++ b/module/actor.js @@ -528,12 +528,19 @@ export class RdDActor extends Actor { async updateCompteurValue( fieldName, fieldValue ) { //console.log("Update", fieldName, fieldValue); - let content; let compteurs = duplicate(this.data.data.compteurs); compteurs[fieldName].value = fieldValue; await this.update( {"data.compteurs": compteurs } ); } + /* -------------------------------------------- */ + async updateProtectionValue( fieldName, fieldValue ) + { + let attributs = duplicate(this.data.data.attributs); + attributs[fieldName].value = fieldValue; + await this.update( {"data.attributs": attributs } ); + } + /* -------------------------------------------- */ /** Teste si le conteneur de destination a suffisament de capacité * pour recevoir le nouvel objet @@ -1133,7 +1140,7 @@ export class RdDActor extends Actor { action: r => this._appliquerAjoutExperience(r) }; } - + /* -------------------------------------------- */ async _appliquerAjoutExperience(rollData) { let xpResult = this.appliquerExperience( rollData.rolled, rollData.selectedCarac.label, (rollData.competence) ? rollData.competence.data.name: undefined ); @@ -1312,10 +1319,6 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollCompetence( name ) { - if (name == 'queue') { - await this.ajouterQueue({chat: true}); - return; - } let rollData = { competence: duplicate(this.getCompetence(name)), needSignificative : !this.isEntiteCauchemar() && this.data.data.sante.sonne.value @@ -1389,6 +1392,7 @@ export class RdDActor extends Actor { label: 'Jet de Tâche ' + tache.name, callbacks: [ this.createCallbackExperience(), + { condition: r=> r.rolled.isETotal, action: r => this._tacheETotal(r)}, { action: r => this._tacheResult(r) } ] } ); @@ -1400,7 +1404,7 @@ export class RdDActor extends Actor { // Mise à jour de la tache rollData.tache.data.points_de_tache_courant += rollData.rolled.ptTache; this.updateEmbeddedEntity( "OwnedItem", rollData.tache); - this.santeIncDec( "fatigue", -rollData.tache.data.fatigue); + this.santeIncDec( "fatigue", rollData.tache.data.fatigue); // Message de résultat ChatUtility.chatWithRollMode({ @@ -1418,6 +1422,11 @@ export class RdDActor extends Actor { }, this.name); } + _tacheETotal(rollData) { + rollData.tache.data.difficulte --; + this.updateEmbeddedEntity( "OwnedItem", rollData.tache); + } + /* -------------------------------------------- */ _competenceResult(rollData) { ChatUtility.chatWithRollMode({ @@ -1688,7 +1697,8 @@ export class RdDActor extends Actor { this.updateEmbeddedEntity("OwnedItem", update); } } - protection = Math.max(protection - Misc.toInt(arme.data.penetration), 0); + const penetration = arme ? Misc.toInt(arme.data.penetration) : 0; + protection = Math.max(protection - penetration, 0); protection += this.getProtectionNaturelle(); console.log("Final protect", protection); return protection; diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index e08a0dc4..bd9d0dda 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -58,13 +58,17 @@ export class RdDCalendrier extends Application { } // nombre astral if ( game.user.isGM) { - this.listeNombreAstral = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral")); + this.listeNombreAstral = this._loadListNombreAstral(); this.rebuildListeNombreAstral(); // Ensure always up-to-date } console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral); } + _loadListNombreAstral() { + return Object.values(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral")); + } + /* -------------------------------------------- */ static get defaultOptions() { const options = super.defaultOptions; @@ -114,7 +118,7 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ getNombreAstral( index ) { - const liste = this.listeNombreAstral || game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral") + const liste = this.listeNombreAstral || this._loadListNombreAstral(); let astralData = liste.find( (nombreAstral, i) => nombreAstral.index == index ); return astralData.nombreAstral || "N/A"; } diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 12edf14d..6a6a46d1 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -296,7 +296,9 @@ export class RdDCombat { switch (categorie) { case 'tir': case 'lancer': - return items.filter(item => item.data.competence.toLowerCase().match("bouclier")); + return items.filter(item => + item.type == 'arme' && + item.data.competence.toLowerCase().match("bouclier")); default: return items.filter(item => { if (item.type == 'competencecreature') { diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 48d5993f..6070a707 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -35,7 +35,7 @@ export class RdDRoll extends Dialog { etat: actor.data.data.compteurs.etat.value, carac: actor.data.data.carac, finalLevel: 0, - diffConditions: 0, + diffConditions: rollData.arme ? RdDBonus.bonusAttaque(rollData.surpriseDefenseur) :0, diffLibre: 0, editLibre: true, editConditions: true, @@ -110,7 +110,6 @@ export class RdDRoll extends Dialog { rollData.dmg = rollData.attackerRoll ? rollData.attackerRoll.dmg : RdDBonus.dmg(rollData, actor.getBonusDegat()); rollData.finalLevel = rollLevel; rollData.caracValue = caracValue; - rollData.diffConditions = RdDBonus.bonusAttaque(rollData.surpriseDefenseur); rollData.coupsNonMortels = (rollData.attackerRoll ? rollData.attackerRoll.dmg.mortalite : rollData.dmg.mortalite) == 'non-mortel'; let dmgText = Misc.toSignedString(rollData.dmg.total); if (rollData.coupsNonMortels) { diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 7734d4e3..0768aa13 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -78,7 +78,7 @@ function _cumulSegmentsFatigue(matrix) { } /* -------------------------------------------- */ -const fatigueMatrix = _buildAllSegmentsFatigue(30); +const fatigueMatrix = _buildAllSegmentsFatigue(60); const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix); const fatigueMalus = [ 0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7 ]; // Provides the malus for each segment of fatigue diff --git a/template.json b/template.json index abf5e47c..a3a9339c 100644 --- a/template.json +++ b/template.json @@ -81,7 +81,7 @@ "protection": { "type": "number", "value": 0, - "label": "Protection", + "label": "Protection naturelle", "derivee": false } } @@ -189,7 +189,7 @@ "protection": { "type": "number", "value": 0, - "label": "Protection", + "label": "Protection naturelle", "derivee": false } }, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 6223eaa5..6ccaff32 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -125,7 +125,13 @@