Merge branch 'working' into 'master'

Regarder les TMR

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!16
This commit is contained in:
Leratier Bretonnien 2020-11-14 20:28:53 +00:00
commit 183718638d
4 changed files with 58 additions and 21 deletions

View File

@ -275,15 +275,19 @@ export class RdDActorSheet extends ActorSheet {
let armeName = event.currentTarget.text; let armeName = event.currentTarget.text;
this.actor.rollArme( armeName); this.actor.rollArme( armeName);
}); });
// Display TMR, normal
html.find('.visu-tmr a').click((event) => {
this.actor.displayTMR( "visu");
});
// Display TMR, normal // Display TMR, normal
html.find('.monte-tmr a').click((event) => { html.find('.monte-tmr a').click((event) => {
this.actor.displayTMR( false ); this.actor.displayTMR( "normal" );
}); });
// Display TMR, fast // Display TMR, fast
html.find('.monte-tmr-rapide a').click((event) => { html.find('.monte-tmr-rapide a').click((event) => {
this.actor.displayTMR( true ); this.actor.displayTMR( "rapide" );
}); });
// Display info about queue // Display info about queue

View File

@ -744,14 +744,18 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async displayTMR( isRapide=false ) async displayTMR(mode="normal" )
{ {
let minReveValue = (isRapide) ? 3 : 2; let isRapide= mode == "rapide"
if (this.data.data.reve.reve.value <= minReveValue ) { if (mode != "visu")
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) } ); let minReveValue = (isRapide) ? 3 : 2;
return; 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 = { let data = {
fatigueHTML:"<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "</table>", fatigueHTML:"<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "</table>",
@ -762,7 +766,7 @@ export class RdDActor extends Actor {
isRapide: isRapide isRapide: isRapide
} }
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data ); 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); this.currentTMR.render(true);
} }

View File

@ -19,7 +19,7 @@ const tmrConstants = {
export class RdDTMRDialog extends Dialog { export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, actor, tmrData) { constructor(html, actor, tmrData, viewOnly) {
const dialogConf = { const dialogConf = {
title: "Terres Médianes de Rêve", title: "Terres Médianes de Rêve",
content: html, content: html,
@ -38,7 +38,8 @@ export class RdDTMRDialog extends Dialog {
this.tmrdata = duplicate(tmrData); this.tmrdata = duplicate(tmrData);
this.actor = actor; 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.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list); this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list);
this.allTokens = [] this.allTokens = []
@ -132,7 +133,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async manageRencontre(coordTMR, cellDescr) { async manageRencontre(coordTMR, cellDescr) {
if (this.viewOnly) {
return;
}
this.currentRencontre = undefined; this.currentRencontre = undefined;
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR); let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
let deRencontre = new Roll("d7").roll(); let deRencontre = new Roll("d7").roll();
@ -162,6 +165,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
performRoll(html) { performRoll(html) {
if (this.viewOnly) {
return;
}
this.actor.performRoll(this.rollData); this.actor.performRoll(this.rollData);
} }
@ -193,6 +199,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async manageCaseHumide(cellDescr) { async manageCaseHumide(cellDescr) {
if (this.viewOnly) {
return;
}
if (cellDescr.type == "lac" || cellDescr.type == "fleuve" || cellDescr.type == "marais") { if (cellDescr.type == "lac" || cellDescr.type == "fleuve" || cellDescr.type == "marais") {
let draconic = this.actor.getBestDraconic(); let draconic = this.actor.getBestDraconic();
@ -239,6 +248,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async declencheSortEnReserve(coordTMR) { async declencheSortEnReserve(coordTMR) {
if (this.viewOnly) {
return;
}
let sortReserve = this.sortReserves.find(it => it.coord == coordTMR) let sortReserve = this.sortReserves.find(it => it.coord == coordTMR)
if (sortReserve != undefined) { if (sortReserve != undefined) {
await this.actor.deleteSortReserve(sortReserve.coord); await this.actor.deleteSortReserve(sortReserve.coord);
@ -254,6 +266,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async deplacerDemiReve(event) { async deplacerDemiReve(event) {
if (this.viewOnly) {
return;
}
let origEvent = event.data.originalEvent; let origEvent = event.data.originalEvent;
let myself = event.target.tmrObject; let myself = event.target.tmrObject;
@ -293,10 +308,16 @@ export class RdDTMRDialog extends Dialog {
var cell1 = row.insertCell(1); var cell1 = row.insertCell(1);
cell1.append(this.pixiApp.view); cell1.append(this.pixiApp.view);
// Roll Sort if (this.viewOnly) {
html.find('#lancer-sort').click((event) => { html.find('#lancer-sort').remove();
this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord); }
}); else {
// Roll Sort
html.find('#lancer-sort').click((event) => {
this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord);
});
}
// load the texture we need // load the texture we need
await this.pixiApp.loader await this.pixiApp.loader
@ -317,7 +338,9 @@ export class RdDTMRDialog extends Dialog {
mytmr.interactive = true; mytmr.interactive = true;
mytmr.buttonMode = true; mytmr.buttonMode = true;
mytmr.tmrObject = this; mytmr.tmrObject = this;
mytmr.on('pointerdown', this.deplacerDemiReve); if (!this.viewOnly) {
mytmr.on('pointerdown', this.deplacerDemiReve);
}
this.pixiApp.stage.addChild(mytmr); this.pixiApp.stage.addChild(mytmr);
this._addDemiReve(); this._addDemiReve();
@ -325,6 +348,9 @@ export class RdDTMRDialog extends Dialog {
this.displaySortReserve(); this.displaySortReserve();
}); });
if (this.viewOnly) {
return;
}
await this.actor.updatePointsDeReve((this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue await this.actor.updatePointsDeReve((this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue
this.updateValuesDisplay(); this.updateValuesDisplay();
let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); 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), x: 16 - (tmrConstants.cellw / 2),
y: 16 - (tmrConstants.cellh / 2) y: 16 - (tmrConstants.cellh / 2)
} }
return { sprite: sprite, sort: sort, coordTMR: () => sort.coord} return { sprite: sprite, sort: sort, coordTMR: () => sort.coord }
} }
_tokenDemiReve() { _tokenDemiReve() {

View File

@ -385,11 +385,14 @@
{{!-- hautreve Tab --}} {{!-- hautreve Tab --}}
<div class="tab hautreve" data-group="primary" data-tab="hautreve" style="height:200px"> <div class="tab hautreve" data-group="primary" data-tab="hautreve" style="height:200px">
<div>
<span class="visu-tmr"><strong><a>Regarder les Terres Medianes</a></strong></span>
</div>
<div> <div>
<span class="monte-tmr"><strong><a>Monter Normale dans les Terres Medianes !</a></strong></span> <span class="monte-tmr"><strong><a>Monter Normale dans les Terres Medianes !</a></strong></span>
</div> </div>
<div> <div>
<span class="monte-tmr-rapide"><strong><a>Monter Accélérée dans les Terres Medianes !</a></strong></span> <span class="monte-tmr-rapide"><strong><a>Monter en Accéléré dans les Terres Medianes !</a></strong></span>
</div> </div>
<div> <div>
<ol class="item-list"> <ol class="item-list">