|
|
|
@ -44,9 +44,6 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
}
|
|
|
|
|
super(dialogConf, dialogOptions);
|
|
|
|
|
|
|
|
|
|
if ( actor.isTMRCache() ) {
|
|
|
|
|
console.log("TMR cachées !!!!!!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.tmrdata = duplicate(tmrData);
|
|
|
|
|
this.actor = actor;
|
|
|
|
@ -61,25 +58,30 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
this.rencontreState = 'aucune';
|
|
|
|
|
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
|
|
|
|
|
|
|
|
|
|
this.pixiTMR = new PixiTMR(this, this.pixiApp);
|
|
|
|
|
this.pixiTMR = new PixiTMR(this, this.pixiApp);
|
|
|
|
|
this.cacheTMR = (game.user.isGM) ? false: actor.isTMRCache();
|
|
|
|
|
|
|
|
|
|
this.callbacksOnAnimate = [];
|
|
|
|
|
if (!this.viewOnly) {
|
|
|
|
|
this.actor.setStatusDemiReve(true);
|
|
|
|
|
this._tellToGM(this.actor.name + " monte dans les terres médianes (" + tmrData.mode + ")");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load the texture we need
|
|
|
|
|
this.pixiTMR.load((loader, resources) => this.createPixiSprites());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
loadCasesSpeciales() {
|
|
|
|
|
this.casesSpeciales = this.actor.data.items.filter(item => Draconique.isCaseTMR(item));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
loadSortsReserve() {
|
|
|
|
|
this.sortsReserves = Misc.data(this.actor).data.reve.reserve.list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
loadRencontres() {
|
|
|
|
|
this.rencontresExistantes = this.actor.getTMRRencontres();
|
|
|
|
|
}
|
|
|
|
@ -87,9 +89,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
createPixiSprites() {
|
|
|
|
|
EffetsDraconiques.carteTmr.createSprite(this.pixiTMR);
|
|
|
|
|
|
|
|
|
|
this.updateTokens();
|
|
|
|
|
|
|
|
|
|
this.demiReve = this._tokenDemiReve();
|
|
|
|
|
this._updateDemiReve();
|
|
|
|
|
}
|
|
|
|
@ -147,7 +147,30 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updateDemiReve() {
|
|
|
|
|
this._setTokenPosition(this.demiReve);
|
|
|
|
|
if ( !this.cacheTMR) {
|
|
|
|
|
this._setTokenPosition(this.demiReve);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async moveFromKey( move ) {
|
|
|
|
|
let pos = TMRUtility.convertToCellPos(Misc.data(this.actor).data.reve.tmrpos.coord);
|
|
|
|
|
|
|
|
|
|
if (move == 'top') pos.y -= 1;
|
|
|
|
|
if (move == 'bottom') pos.y += 1;
|
|
|
|
|
if (move.includes('left')) pos.x -= 1;
|
|
|
|
|
if (move.includes('right')) pos.x += 1;
|
|
|
|
|
if (pos.x % 2 == 1) {
|
|
|
|
|
if (move == 'top-left') pos.y -= 1;
|
|
|
|
|
if (move == 'top-right') pos.y -= 1;
|
|
|
|
|
} else {
|
|
|
|
|
if (move == 'bottom-left') pos.y += 1;
|
|
|
|
|
if (move == 'bottom-right') pos.y += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let targetCoord = TMRUtility.convertToTMRCoord(pos);
|
|
|
|
|
await this._deplacerDemiReve(targetCoord, 'normal');
|
|
|
|
|
this.checkQuitterTMR();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
@ -169,6 +192,25 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html.find('#dir-top').click((event) => {
|
|
|
|
|
this.moveFromKey("top");
|
|
|
|
|
} );
|
|
|
|
|
html.find('#dir-top-left').click((event) => {
|
|
|
|
|
this.moveFromKey("top-left");
|
|
|
|
|
} );
|
|
|
|
|
html.find('#dir-top-right').click((event) => {
|
|
|
|
|
this.moveFromKey("top-right");
|
|
|
|
|
} );
|
|
|
|
|
html.find('#dir-bottom-left').click((event) => {
|
|
|
|
|
this.moveFromKey("bottom-left");
|
|
|
|
|
} );
|
|
|
|
|
html.find('#dir-bottom-right').click((event) => {
|
|
|
|
|
this.moveFromKey("bottom-right");
|
|
|
|
|
} );
|
|
|
|
|
html.find('#dir-bottom').click((event) => {
|
|
|
|
|
this.moveFromKey("bottom");
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
// Gestion du cout de montée en points de rêve
|
|
|
|
|
let reveCout = ((this.tmrdata.isRapide && !EffetsDraconiques.isDeplacementAccelere(this.actor)) ? -2 : -1)
|
|
|
|
|
- this.actor.countMonteeLaborieuse();
|
|
|
|
@ -190,8 +232,12 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
ptsreve.innerHTML = actorData.data.reve.reve.value;
|
|
|
|
|
|
|
|
|
|
let tmrpos = document.getElementById("tmr-pos");
|
|
|
|
|
let tmr = TMRUtility.getTMR(actorData.data.reve.tmrpos.coord);
|
|
|
|
|
tmrpos.innerHTML = actorData.data.reve.tmrpos.coord + " (" + tmr.label + ")";
|
|
|
|
|
if ( this.cacheTMR ) {
|
|
|
|
|
tmrpos.innerHTML = '?? ('+ TMRUtility.getTMRType( actorData.data.reve.tmrpos.coord ) + ')';
|
|
|
|
|
} else {
|
|
|
|
|
let tmr = TMRUtility.getTMR(actorData.data.reve.tmrpos.coord);
|
|
|
|
|
tmrpos.innerHTML = actorData.data.reve.tmrpos.coord + " (" + tmr.label + ")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let etat = document.getElementById("tmr-etatgeneral-value");
|
|
|
|
|
etat.innerHTML = this.actor.getEtatGeneral();
|
|
|
|
@ -214,7 +260,6 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async derober() {
|
|
|
|
|
await this.actor.addTMRRencontre(this.currentRencontre);
|
|
|
|
@ -222,6 +267,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
this._tellToGM(this.actor.name + " s'est dérobé et quitte les TMR.");
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async refouler() {
|
|
|
|
|
this._tellToGM(this.actor.name + " a refoulé : " + this.currentRencontre.name);
|
|
|
|
@ -265,12 +311,14 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
this.rencontreState = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async choisirCasePortee(coord, portee) {
|
|
|
|
|
// Récupère la liste des cases à portées
|
|
|
|
|
let locList = TMRUtility.getTMRPortee(coord, portee);
|
|
|
|
|
this.colorierZoneRencontre(locList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async choisirCaseType(type) {
|
|
|
|
|
const locList = TMRUtility.filterTMR(it => it.type == type).map(it => it.coord);
|
|
|
|
|
this.colorierZoneRencontre(locList);
|
|
|
|
@ -298,6 +346,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async quitterLesTMRInconscient() {
|
|
|
|
|
if (this.currentRencontre?.isPersistant) {
|
|
|
|
|
await this.refouler();
|
|
|
|
@ -366,6 +415,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_rollPresentCite(rencontreData) {
|
|
|
|
|
let rolled = RdDResolutionTable.computeChances(rencontreData.reve, 0);
|
|
|
|
|
mergeObject(rolled, { caracValue: rencontreData.reve, finalLevel: 0, roll: rolled.score });
|
|
|
|
@ -426,6 +476,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_presentCite(tmr, postRencontre) {
|
|
|
|
|
const presentCite = this.casesSpeciales.find(c => EffetsDraconiques.presentCites.isCase(c, tmr.coord));
|
|
|
|
|
if (presentCite) {
|
|
|
|
@ -435,6 +486,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
return presentCite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async _utiliserPresentCite(presentCite, typeRencontre, tmr, postRencontre) {
|
|
|
|
|
this.currentRencontre = TMRRencontres.getRencontre(typeRencontre);
|
|
|
|
|
await TMRRencontres.evaluerForceRencontre(this.currentRencontre);
|
|
|
|
@ -467,7 +519,8 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
if (TMRUtility.isForceRencontre() || myRoll == 7) {
|
|
|
|
|
return await this.rencontreTMRRoll(tmr, this.actor.isRencontreSpeciale());
|
|
|
|
|
}
|
|
|
|
|
this._tellToUser(myRoll + ": Pas de rencontre en " + tmr.label + " (" + tmr.coord + ")");
|
|
|
|
|
let locTMR = (this.montreTMR) ? tmr.label + " (" + tmr.coord + ")" : "??";
|
|
|
|
|
this._tellToUser(myRoll + ": Pas de rencontre en " + locTMR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
@ -633,6 +686,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
await this._maitriserTMR(rollData, r => this._onResultatConquerir(r, options));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async _onResultatConquerir(rollData, options) {
|
|
|
|
|
if (rollData.rolled.isETotal) {
|
|
|
|
|
rollData.souffle = await this.actor.ajouterSouffle({ chat: false });
|
|
|
|
@ -799,7 +853,7 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
|
|
|
|
|
// Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter)
|
|
|
|
|
let deplacementType = this._calculDeplacement(targetCoord, currentCoord, currentPos, eventPos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Si le deplacement est valide
|
|
|
|
|
if (deplacementType == 'normal' || deplacementType == 'saut') {
|
|
|
|
|
await this._deplacerDemiReve(targetCoord, deplacementType);
|
|
|
|
@ -838,12 +892,23 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
this.nettoyerRencontre();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
externalRefresh( tmrData ) {
|
|
|
|
|
this.cacheTMR = (game.user.isGM) ? false: this.actor.isTMRCache();
|
|
|
|
|
this.createPixiSprites();
|
|
|
|
|
this.forceDemiRevePositionView();
|
|
|
|
|
this.updateValuesDisplay();
|
|
|
|
|
this.updateTokens();
|
|
|
|
|
console.log("TMR REFRESHED !!!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async _deplacerDemiReve(targetCoord, deplacementType) {
|
|
|
|
|
if (this.currentRencontre != 'normal') {
|
|
|
|
|
this.nettoyerRencontre();
|
|
|
|
|
}
|
|
|
|
|
let tmr = TMRUtility.getTMR(targetCoord);
|
|
|
|
|
console.log("deplacerDemiReve", tmr, this);
|
|
|
|
|
//console.log("deplacerDemiReve", tmr, this);
|
|
|
|
|
// Gestion cases spéciales type Trou noir, etc
|
|
|
|
|
tmr = await this.manageTmrInnaccessible(tmr);
|
|
|
|
|
|
|
|
|
@ -924,7 +989,9 @@ export class RdDTMRDialog extends Dialog {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_setTokenPosition(token) {
|
|
|
|
|
this.pixiTMR.setPosition(token.sprite, TMRUtility.convertToCellPos(token.coordTMR()));
|
|
|
|
|
if ( !this.cacheTMR) {
|
|
|
|
|
this.pixiTMR.setPosition(token.sprite, TMRUtility.convertToCellPos(token.coordTMR()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|