diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 1f0c37a4..b218fa7c 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -139,7 +139,8 @@ export class RdDActorSheet extends ActorSheet {
formData.hautreve = {
sortsReserve: formData.data.reve.reserve.list,
rencontres: duplicate(formData.data.reve.rencontre.list),
- casesTmr: formData.itemsByType.casetmr
+ casesTmr: formData.itemsByType.casetmr,
+ cacheTMR: this.actor.isTMRCache()
}
RdDUtility.buildArbreDeConteneur(this, formData);
@@ -398,7 +399,15 @@ export class RdDActorSheet extends ActorSheet {
actor.sheet.render(true);
}
});
-
+
+ // Boutons spéciaux MJs
+ html.find('.forcer-tmr-aleatoire').click((event) => {
+ this.actor.cacheTMRetMessage();
+ });
+ html.find('.afficher-tmr').click((event) => {
+ this.actor.afficheTMRetMessage();
+ });
+
// Points de reve actuel
html.find('.ptreve-actuel a').click((event) => {
this.actor.rollCarac('reve-actuel');
diff --git a/module/actor.js b/module/actor.js
index 897efaa1..95ce99b1 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -1217,9 +1217,31 @@ export class RdDActor extends Actor {
async montreTMR( ) {
await this.update({ 'data.reve.tmrpos.cache': false });
}
- async isTMRCache( ) {
+ isTMRCache( ) {
return this.data.data.reve.tmrpos.cache;
}
+ /* -------------------------------------------- */
+ async cacheTMRetMessage() {
+ await this.reinsertionAleatoire();
+ await this.cacheTMR();
+ game.socket.emit("system.foundryvtt-reve-de-dragon", {
+ msg: "msg_tmr_move", data: {
+ actorId: this.data._id,
+ tmrPos: this.data.data.reve.tmrpos
+ }
+ });
+ }
+
+ /* -------------------------------------------- */
+ async afficheTMRetMessage() {
+ await this.montreTMR();
+ game.socket.emit("system.foundryvtt-reve-de-dragon", {
+ msg: "msg_tmr_move", data: {
+ actorId: this.data._id,
+ tmrPos: this.data.data.reve.tmrpos
+ }
+ });
+ }
/* -------------------------------------------- */
async reinsertionAleatoire(raison) {
@@ -2739,7 +2761,7 @@ export class RdDActor extends Actor {
refreshTMRView(tmrData) {
console.log("REFRESH !!!!");
if (this.currentTMR) {
- this.currentTMR.forceDemiRevePositionView();
+ this.currentTMR.externalRefresh( tmrData)
}
}
diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js
index 1d21c45b..2cf45e56 100644
--- a/module/rdd-tmr-dialog.js
+++ b/module/rdd-tmr-dialog.js
@@ -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()));
+ }
}
/* -------------------------------------------- */
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index c2948537..c6123b52 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -510,10 +510,11 @@ export class RdDUtility {
case "msg_response_nombre_astral":
return RdDUtility.responseNombreAstral(sockmsg.data);
case "msg_tmr_move":
- if (game.user.isGM) {
- let actor = game.actors.get(sockmsg.data.actorId);
+ let actor = game.actors.get(sockmsg.data.actorId);
+ if (actor.isOwner || game.user.isGM ) {
actor.refreshTMRView(sockmsg.data.tmrPos);
}
+ break;
}
}
diff --git a/module/tmr-utility.js b/module/tmr-utility.js
index 454355fd..14efd5ac 100644
--- a/module/tmr-utility.js
+++ b/module/tmr-utility.js
@@ -335,9 +335,14 @@ export class TMRUtility {
return TMRMapping[coord]?.label ?? (coord + ": case inconnue");
}
+ static getTMRType(coord) {
+ const tmr = TMRMapping[coord];
+ return Misc.upperFirst(tmr.type);
+ }
+
static getTMRDescr(coord) {
const tmr = TMRMapping[coord];
- return Grammar.articleDetermine(tmr.genre) + ' ' + tmr.label;
+ return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
}
static isCaseHumide(tmr) {
diff --git a/styles/img/ui/dir-bottom-left.svg b/styles/img/ui/dir-bottom-left.svg
new file mode 100644
index 00000000..8bc4e865
--- /dev/null
+++ b/styles/img/ui/dir-bottom-left.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/styles/img/ui/dir-bottom-right.svg b/styles/img/ui/dir-bottom-right.svg
new file mode 100644
index 00000000..7bd45ff1
--- /dev/null
+++ b/styles/img/ui/dir-bottom-right.svg
@@ -0,0 +1 @@
+
+
+
+
+
+
+
+
+
+
+
|