diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 1aaa6d3a..10d48c6d 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -100,7 +100,7 @@ export class RdDActorSheet extends ActorSheet { // Gestion du lock/unlock des zones éditables (carac+compétences) data.data.editCaracComp = this.options.editCaracComp; - data.data.lockUnlockText = (this.options.editCaracComp) ? "Bloquer" : "Debloquer"; + data.data.lockUnlockText = (this.options.editCaracComp) ? "Bloquer" : "Débloquer"; // low is normal, this the base used to compute the grid. data.data.fatigue = { @@ -118,7 +118,7 @@ export class RdDActorSheet extends ActorSheet { /* -------------------------------------------- */ async displayDialogEncaisser( ) { - let data = { ajustementsConditions: CONFIG.RDD.ajustementsConditions /* techniquement on peut encaisser à +20 */ }; + let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }; let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data ); new RdDEncaisser(html, this.actor ).render(true); } @@ -160,6 +160,12 @@ export class RdDActorSheet extends ActorSheet { activateListeners(html) { super.activateListeners(html); + if (game.user.isGM) { + $(".gm-only").show(); + } else { + $(".gm-only").hide(); + } + // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; @@ -176,11 +182,16 @@ export class RdDActorSheet extends ActorSheet { this.confirmerSuppression( li ); }); - // Update Inventory Item - html.find('.encaisser-direct').click(ev => { + html.find('#encaisser-direct').click(ev => { this.displayDialogEncaisser() }); + html.find('#remise-a-neuf').click(ev => { + if (game.user.isGM) { + this.actor.remiseANeuf(); + } + }); + // Blessure control html.find('.blessure-control').click(ev => { const li = $(ev.currentTarget).parents(".item"); @@ -234,24 +245,24 @@ export class RdDActorSheet extends ActorSheet { this.actor.rollArme( armeName, competenceName); }); // Display TMR, normal - html.find('.visu-tmr a').click((event) => { + html.find('#visu-tmr').click((event) => { this.actor.displayTMR( "visu"); }); // Display TMR, normal - html.find('.monte-tmr a').click((event) => { + html.find('#monte-tmr').click((event) => { this.actor.displayTMR( "normal" ); }); // Display TMR, fast - html.find('.monte-tmr-rapide a').click((event) => { + html.find('#monte-tmr-rapide').click((event) => { this.actor.displayTMR( "rapide" ); }); - html.find('.dormir-une-heure').click((event) => { + html.find('#dormir-une-heure').click((event) => { this.actor.dormir(1); }); - html.find('.dormir-chateau-dormant').click((event) => { + html.find('#dormir-chateau-dormant').click((event) => { this.actor.dormirChateauDormant(); }); diff --git a/module/actor.js b/module/actor.js index a088133d..84bc05c0 100644 --- a/module/actor.js +++ b/module/actor.js @@ -391,10 +391,14 @@ export class RdDActor extends Actor { } mergeObject(retrograde, { "active": true, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": blessure.localisation }); } - mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }); + this._supprimerBlessure(blessure); return true; } + _supprimerBlessure(blessure) { + mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }); + } + async _recupererVie(message) { let blessures = [].concat(this.data.data.blessures.legeres.liste).concat(this.data.data.blessures.graves.liste).concat(this.data.data.blessures.critiques.liste); let nbBlessures = blessures.filter(b => b.active); @@ -430,6 +434,28 @@ export class RdDActor extends Actor { return rolled; } + + async remiseANeuf() { + let message = { + whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ), + content : "Remise à neuf de " + this.name + }; + const blessures = duplicate(this.data.data.blessures); + for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) { + for (let blessure of listeBlessures) { + this._supprimerBlessure(blessure); + } + } + await this.update( {"data.blessures": blessures } ); + await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); + await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); + let fatigue = duplicate(this.data.data.sante.fatigue) + fatigue.value = 0; + await this.update( {"data.sante.fatigue": fatigue } ); + ChatMessage.create( message ); + } + + /* -------------------------------------------- */ async dormir(heures=1) { let message = { @@ -890,12 +916,15 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async santeIncDec(name, inc, isCritique = false ) { + async santeIncDec(name, inc, isCritique = false) { const sante = duplicate(this.data.data.sante); let data = sante[name]; let minValue = 0; - if (this.type == 'personnage') - minValue = name == "vie" ? Number(-this.data.data.attributs.sconst.value) : 0; + if (this.type == 'personnage') { + // TODO: les animaux/humanoïdes on théoriquement aussi un sconst, mais la SPA n'est pas passé par là + minValue = name == "vie" ? -Number(this.data.data.attributs.sconst.value) : 0; + } + let newValue = Math.max(minValue, Math.min(data.value + inc, data.max)); //console.log("New value ", inc, minValue, newValue); @@ -1298,9 +1327,8 @@ export class RdDActor extends Actor { let degatsReel = attackerRoll.degats - armure; let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite); - if ( this.data.type != 'entite') // Pas de PV chez les entités - await this.santeIncDec("vie", result.vie, (result.critiques > 0) ); - await this.santeIncDec("endurance", result.endurance, (result.critiques > 0) ); + await this.santeIncDec("vie", result.vie); + await this.santeIncDec("endurance", result.endurance, (result.critiques > 0)); result.locName = (attackerRoll.loc) ? attackerRoll.loc.label : "Corps"; this.manageBlessures(result); // Will upate the result table diff --git a/module/rdd-utility.js b/module/rdd-utility.js index ef3cbd9d..e2601fd8 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -28,6 +28,8 @@ const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; +const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25]; + function _buildAllSegmentsFatigue(max) { const cycle = [5, 2, 4, 1, 3, 0]; @@ -298,6 +300,10 @@ export class RdDUtility { { return ajustementsConditions; } + static getAjustementsEncaissement() + { + return ajustementsEncaissement; + } static getDefinitionsBlessures() { return definitionsBlessures; diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index ad89353f..94b36b4a 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -58,13 +58,14 @@