diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 46fb7979..52bde16a 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -275,15 +275,19 @@ export class RdDActorSheet extends ActorSheet { let armeName = event.currentTarget.text; this.actor.rollArme( armeName); }); - + // Display TMR, normal + html.find('.visu-tmr a').click((event) => { + this.actor.displayTMR( "visu"); + }); + // Display TMR, normal html.find('.monte-tmr a').click((event) => { - this.actor.displayTMR( false ); + this.actor.displayTMR( "normal" ); }); // Display TMR, fast html.find('.monte-tmr-rapide a').click((event) => { - this.actor.displayTMR( true ); + this.actor.displayTMR( "rapide" ); }); // Display info about queue diff --git a/module/actor.js b/module/actor.js index 3ee84914..47d5e423 100644 --- a/module/actor.js +++ b/module/actor.js @@ -727,14 +727,18 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async displayTMR( isRapide=false ) + async displayTMR(mode="normal" ) { - let minReveValue = (isRapide) ? 3 : 2; - if (this.data.data.reve.reve.value <= minReveValue ) { - ChatMessage.create( { title: "Montée impossible !", content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes", - whisper: ChatMessage.getWhisperRecipients(game.user.name) } ); - return; - } + let isRapide= mode == "rapide" + if (mode != "visu") + { + let minReveValue = (isRapide) ? 3 : 2; + if (this.data.data.reve.reve.value <= minReveValue ) { + ChatMessage.create( { title: "Montée impossible !", content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes", + whisper: ChatMessage.getWhisperRecipients(game.user.name) } ); + return; + } + } let data = { fatigueHTML:"" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "
", @@ -745,7 +749,7 @@ export class RdDActor extends Actor { isRapide: isRapide } let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data ); - this.currentTMR = new RdDTMRDialog(html, this, data ); + this.currentTMR = new RdDTMRDialog(html, this, data, mode == "visu"); this.currentTMR.render(true); } diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index 1737f694..b25eb2ac 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -19,7 +19,7 @@ const tmrConstants = { export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ - constructor(html, actor, tmrData) { + constructor(html, actor, tmrData, viewOnly) { const dialogConf = { title: "Terres Médianes de Rêve", content: html, @@ -38,7 +38,8 @@ export class RdDTMRDialog extends Dialog { this.tmrdata = duplicate(tmrData); this.actor = actor; - this.nbFatigue = 1; // 1 premier point de fatigue du à la montée + this.viewOnly = viewOnly + this.nbFatigue = this.viewOnly ? 0 : 1; // 1 premier point de fatigue du à la montée this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list); this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list); this.allTokens = [] @@ -132,7 +133,9 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async manageRencontre(coordTMR, cellDescr) { - + if (this.viewOnly) { + return; + } this.currentRencontre = undefined; let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR); let deRencontre = new Roll("d7").roll(); @@ -162,6 +165,9 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ performRoll(html) { + if (this.viewOnly) { + return; + } this.actor.performRoll(this.rollData); } @@ -193,6 +199,9 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async manageCaseHumide(cellDescr) { + if (this.viewOnly) { + return; + } if (cellDescr.type == "lac" || cellDescr.type == "fleuve" || cellDescr.type == "marais") { let draconic = this.actor.getBestDraconic(); @@ -239,6 +248,9 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async declencheSortEnReserve(coordTMR) { + if (this.viewOnly) { + return; + } let sortReserve = this.sortReserves.find(it => it.coord == coordTMR) if (sortReserve != undefined) { await this.actor.deleteSortReserve(sortReserve.coord); @@ -254,6 +266,9 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async deplacerDemiReve(event) { + if (this.viewOnly) { + return; + } let origEvent = event.data.originalEvent; let myself = event.target.tmrObject; @@ -293,10 +308,16 @@ export class RdDTMRDialog extends Dialog { var cell1 = row.insertCell(1); cell1.append(this.pixiApp.view); - // Roll Sort - html.find('#lancer-sort').click((event) => { - this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord); - }); + if (this.viewOnly) { + html.find('#lancer-sort').remove(); + } + else { + // Roll Sort + html.find('#lancer-sort').click((event) => { + + this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord); + }); + } // load the texture we need await this.pixiApp.loader @@ -317,7 +338,9 @@ export class RdDTMRDialog extends Dialog { mytmr.interactive = true; mytmr.buttonMode = true; mytmr.tmrObject = this; - mytmr.on('pointerdown', this.deplacerDemiReve); + if (!this.viewOnly) { + mytmr.on('pointerdown', this.deplacerDemiReve); + } this.pixiApp.stage.addChild(mytmr); this._addDemiReve(); @@ -325,6 +348,9 @@ export class RdDTMRDialog extends Dialog { this.displaySortReserve(); }); + if (this.viewOnly) { + return; + } await this.actor.updatePointsDeReve((this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue this.updateValuesDisplay(); let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); @@ -371,7 +397,7 @@ export class RdDTMRDialog extends Dialog { x: 16 - (tmrConstants.cellw / 2), y: 16 - (tmrConstants.cellh / 2) } - return { sprite: sprite, sort: sort, coordTMR: () => sort.coord} + return { sprite: sprite, sort: sort, coordTMR: () => sort.coord } } _tokenDemiReve() { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index fc3a25cc..16bd8387 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -385,11 +385,14 @@ {{!-- hautreve Tab --}}
+
+ Regarder les Terres Medianes +
Monter Normale dans les Terres Medianes !
- Monter Accélérée dans les Terres Medianes ! + Monter en Accéléré dans les Terres Medianes !