forked from public/foundryvtt-reve-de-dragon
Regarder les TMR
This commit is contained in:
@ -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() {
|
||||
|
Reference in New Issue
Block a user