Merge pull request '## v11.0.25 - la vision du rêve de Khrachtchoum' (#672) from VincentVk/foundryvtt-reve-de-dragon:v11 into v11

Reviewed-on: public/foundryvtt-reve-de-dragon#672
This commit is contained in:
uberwald 2023-10-22 21:40:42 +02:00
commit e61417c44e
7 changed files with 106 additions and 39 deletions

View File

@ -1,4 +1,7 @@
# v11.0 # v11.0
## v11.0.25 - la vision du rêve de Khrachtchoum
- Les TMRs restent affichées tant que le Haut-rêvant est en demi-rêve
## v11.0.24 - les couleurs de Khrachtchoum ## v11.0.24 - les couleurs de Khrachtchoum
- nouvelle carte des TMRs - nouvelle carte des TMRs

View File

@ -369,7 +369,7 @@ export class RdDActor extends RdDBaseActor {
async _openRollDialog({ name, label, template, rollData, callbackAction }) { async _openRollDialog({ name, label, template, rollData, callbackAction }) {
const dialog = await RdDRoll.create(this, rollData, const dialog = await RdDRoll.create(this, rollData,
{ html: template }, { html: template, close: html => { this.tmrApp?.restoreTMRAfterAction() } },
{ {
name: name, name: name,
label: label, label: label,
@ -380,6 +380,7 @@ export class RdDActor extends RdDBaseActor {
] ]
}); });
dialog.render(true); dialog.render(true);
return dialog
} }
@ -846,7 +847,7 @@ export class RdDActor extends RdDBaseActor {
system: { sortid: sort._id, draconic: (draconic?.name ?? sort.system.draconic), ptreve: ptreve, coord: coord, heurecible: 'Vaisseau' } system: { sortid: sort._id, draconic: (draconic?.name ?? sort.system.draconic), ptreve: ptreve, coord: coord, heurecible: 'Vaisseau' }
}], }],
{ renderSheet: false }); { renderSheet: false });
this.currentTMR.updateTokens(); this.tmrApp.updateTokens();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -2138,12 +2139,12 @@ export class RdDActor extends RdDBaseActor {
ui.notifications.info(`Aucun sort disponible en ${TMRUtility.getTMR(coord).label} !`); ui.notifications.info(`Aucun sort disponible en ${TMRUtility.getTMR(coord).label} !`);
return; return;
} }
if (this.currentTMR) this.currentTMR.minimize(); // Hide
const draconicList = this.computeDraconicAndSortIndex(sorts); const draconicList = this.computeDraconicAndSortIndex(sorts);
const reve = duplicate(this.system.carac.reve); const reve = duplicate(this.system.carac.reve);
await this._openRollDialog({ const dialog = await this._openRollDialog({
name: 'lancer-un-sort', name: 'lancer-un-sort',
label: 'Lancer un sort', label: 'Lancer un sort',
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
@ -2161,6 +2162,7 @@ export class RdDActor extends RdDBaseActor {
}, },
callbackAction: r => this._rollUnSortResult(r) callbackAction: r => this._rollUnSortResult(r)
}); });
this.tmrApp?.setTMRPendingAction(dialog);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -2252,9 +2254,9 @@ export class RdDActor extends RdDBaseActor {
await this.update({ "system.reve.reve.value": reveActuel }); await this.update({ "system.reve.reve.value": reveActuel });
if (rollData.isSortReserve) { if (rollData.isSortReserve) {
this.currentTMR.maximize(); // Re-display TMR this.tmrApp.maximize(); // Re-display TMR
} else { } else {
this.currentTMR.close(); // Close TMR ! this.tmrApp.close(); // Close TMR !
} }
// Final chat message // Final chat message
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html'); await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html');
@ -2723,8 +2725,6 @@ export class RdDActor extends RdDBaseActor {
ui.notifications.info(`Aucun signe draconiques en ${coord} !`); ui.notifications.info(`Aucun signe draconiques en ${coord} !`);
return; return;
} }
if (this.currentTMR) this.currentTMR.minimize(); // Hide
let draconicList = this.getDraconicList() let draconicList = this.getDraconicList()
.map(draconic => { .map(draconic => {
let draconicLecture = duplicate(draconic); let draconicLecture = duplicate(draconic);
@ -2747,7 +2747,7 @@ export class RdDActor extends RdDBaseActor {
const dialog = await RdDRoll.create(this, rollData, const dialog = await RdDRoll.create(this, rollData,
{ {
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-signedraconique.html', html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-signedraconique.html',
close: html => { this.currentTMR.maximize() } // Re-display TMR close: html => { this.tmrApp?.restoreTMRAfterAction() }
}, },
{ {
name: 'lire-signe-draconique', name: 'lire-signe-draconique',
@ -2759,6 +2759,7 @@ export class RdDActor extends RdDBaseActor {
} }
); );
dialog.render(true); dialog.render(true);
this.tmrApp?.setTMRPendingAction(dialog);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -2777,7 +2778,7 @@ export class RdDActor extends RdDBaseActor {
} }
await this.deleteEmbeddedDocuments("Item", [rollData.signe._id]); await this.deleteEmbeddedDocuments("Item", [rollData.signe._id]);
await RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html'); await RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html');
this.currentTMR.close(); this.tmrApp.close();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -3012,8 +3013,8 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
refreshTMRView() { refreshTMRView() {
if (this.currentTMR) { if (this.tmrApp) {
this.currentTMR.externalRefresh(); this.tmrApp.externalRefresh();
} }
} }
@ -3021,6 +3022,7 @@ export class RdDActor extends RdDBaseActor {
async displayTMR(mode = "normal") { async displayTMR(mode = "normal") {
if (this.tmrApp) { if (this.tmrApp) {
ui.notifications.warn("Vous êtes déja dans les TMR...."); ui.notifications.warn("Vous êtes déja dans les TMR....");
this.tmrApp.forceTMRDisplay();
return return
} }
if (mode != 'visu' && this.getEffect(STATUSES.StatusDemiReve)) { if (mode != 'visu' && this.getEffect(STATUSES.StatusDemiReve)) {
@ -3066,8 +3068,8 @@ export class RdDActor extends RdDBaseActor {
hasPlayerOwner: this.hasPlayerOwner hasPlayerOwner: this.hasPlayerOwner
} }
this.currentTMR = await RdDTMRDialog.create(this, tmrFormData); this.tmrApp = await RdDTMRDialog.create(this, tmrFormData);
this.currentTMR.render(true); this.tmrApp.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -2,7 +2,6 @@ import { SHOW_DICE } from "./constants.js";
import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RollDataAjustements } from "./rolldata-ajustements.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
import { TMRUtility } from "./tmr-utility.js"; import { TMRUtility } from "./tmr-utility.js";
import { tmrConstants } from "./tmr-constants.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js"; import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
@ -39,7 +38,8 @@ export class RdDTMRDialog extends Dialog {
title: "Terres Médianes de Rêve", title: "Terres Médianes de Rêve",
content: html, content: html,
buttons: { buttons: {
closeButton: { label: "Fermer", callback: html => this.close(html) } closeButton: {
label: "Fermer", callback: html => this.close() }
}, },
default: "closeButton" default: "closeButton"
} }
@ -63,6 +63,7 @@ export class RdDTMRDialog extends Dialog {
this.rencontreState = 'aucune'; this.rencontreState = 'aucune';
this.pixiApp = new PIXI.Application({ width: 720, height: 860 }); this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
this.pixiTMR = new PixiTMR(this, this.pixiApp); this.pixiTMR = new PixiTMR(this, this.pixiApp);
this.subdialog = undefined
this.callbacksOnAnimate = []; this.callbacksOnAnimate = [];
if (!this.viewOnly) { if (!this.viewOnly) {
@ -73,6 +74,27 @@ export class RdDTMRDialog extends Dialog {
this.pixiTMR.load((loader, resources) => this.createPixiSprites()); this.pixiTMR.load((loader, resources) => this.createPixiSprites());
} }
async forceTMRDisplay() {
this.bringToTop();
if (this.subdialog) {
this.subdialog.bringToTop();
}
}
async restoreTMRAfterAction() {
this.subdialog = undefined
this.bringToTop();
}
forceTMRContinueAction() {
ui.notifications.warn('Vous devez finir votre action avant de continuer dans les TMR');
this.subdialog.bringToTop();
return;
}
setTMRPendingAction(dialog) {
this.subdialog = dialog
}
isDemiReveCache() { isDemiReveCache() {
return !game.user.isGM && this.actor.isTMRCache(); return !game.user.isGM && this.actor.isTMRCache();
} }
@ -174,6 +196,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async moveFromKey(move) { async moveFromKey(move) {
if (this.subdialog) {
return this.forceTMRContinueAction();
}
let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord()); let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
if (move == 'top') oddq.row -= 1; if (move == 'top') oddq.row -= 1;
@ -198,7 +223,9 @@ export class RdDTMRDialog extends Dialog {
super.activateListeners(html); super.activateListeners(html);
this.html = html; this.html = html;
document.getElementById("tmrrow1").insertCell(0).append(this.pixiApp.view); document.getElementsByClassName("tmr-row")
.item(0)
.insertCell(0).append(this.pixiApp.view);
if (this.viewOnly) { if (this.viewOnly) {
this.html.find('.lancer-sort').remove(); this.html.find('.lancer-sort').remove();
@ -209,6 +236,10 @@ export class RdDTMRDialog extends Dialog {
HtmlUtility.showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionnelles.isUsing("appliquer-fatigue")); HtmlUtility.showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionnelles.isUsing("appliquer-fatigue"));
HtmlUtility.showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord())); HtmlUtility.showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
this.html.find('tr.tmr-row *').click((event) => {
this.subdialog?.bringToTop();
});
// Roll Sort // Roll Sort
this.html.find('.lancer-sort').click((event) => { this.html.find('.lancer-sort').click((event) => {
this.actor.rollUnSort(this._getActorCoord()); this.actor.rollUnSort(this._getActorCoord());
@ -230,7 +261,6 @@ export class RdDTMRDialog extends Dialog {
this.cumulFatigue += this.fatigueParCase; this.cumulFatigue += this.fatigueParCase;
} }
await this.actor.reveActuelIncDec(reveCout); await this.actor.reveActuelIncDec(reveCout);
// Le reste... // Le reste...
this.updateValuesDisplay(); this.updateValuesDisplay();
let tmr = TMRUtility.getTMR(this._getActorCoord()); let tmr = TMRUtility.getTMR(this._getActorCoord());
@ -270,6 +300,10 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async close() { async close() {
if (this.subdialog) {
return this.forceTMRContinueAction()
}
this.descenteTMR = true; this.descenteTMR = true;
if (this.actor.tmrApp) { if (this.actor.tmrApp) {
this.actor.tmrApp = undefined; // Cleanup reference this.actor.tmrApp = undefined; // Cleanup reference
@ -292,6 +326,7 @@ export class RdDTMRDialog extends Dialog {
switch (action) { switch (action) {
case 'derober': case 'derober':
await this.derober(); await this.derober();
this.restoreTMRAfterAction();
return; return;
case 'refouler': case 'refouler':
await this.refouler(); await this.refouler();
@ -304,6 +339,7 @@ export class RdDTMRDialog extends Dialog {
break; break;
} }
await this.postRencontre(tmr); await this.postRencontre(tmr);
this.restoreTMRAfterAction();
} }
async derober() { async derober() {
@ -359,7 +395,6 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
checkQuitterTMR() { checkQuitterTMR() {
if (this.actor.isDead()) { if (this.actor.isDead()) {
this._tellToGM("Vous êtes mort : vous quittez les Terres médianes !"); this._tellToGM("Vous êtes mort : vous quittez les Terres médianes !");
this.close(); this.close();
@ -530,8 +565,9 @@ export class RdDTMRDialog extends Dialog {
await this.maitriserRencontre(); await this.maitriserRencontre();
} }
else { else {
let dialog = new RdDTMRRencontreDialog(this, this.currentRencontre, tmr); const dialog = new RdDTMRRencontreDialog(this.actor, this.currentRencontre, tmr);
dialog.render(true); dialog.render(true);
this.setTMRPendingAction(dialog);
} }
} }
else { else {
@ -586,7 +622,10 @@ export class RdDTMRDialog extends Dialog {
? TMRUtility.getTMRType(tmr.coord) + " ??" ? TMRUtility.getTMRType(tmr.coord) + " ??"
: tmr.label + " (" + tmr.coord + ")"); : tmr.label + " (" + tmr.coord + ")");
const fakeDialogRencontre = { bringToTop: () => { } };
this.setTMRPendingAction(fakeDialogRencontre)
let myRoll = await RdDDice.rollTotal("1dt", { showDice: SHOW_DICE }); let myRoll = await RdDDice.rollTotal("1dt", { showDice: SHOW_DICE });
this.restoreTMRAfterAction()
if (myRoll == 7) { if (myRoll == 7) {
this._tellToUser(myRoll + ": Rencontre en " + locTMR); this._tellToUser(myRoll + ": Rencontre en " + locTMR);
return await game.system.rdd.rencontresTMR.getRencontreAleatoire(tmr, this.actor.isMauvaiseRencontre()) return await game.system.rdd.rencontresTMR.getRencontreAleatoire(tmr, this.actor.isMauvaiseRencontre())
@ -781,7 +820,7 @@ export class RdDTMRDialog extends Dialog {
const dialog = await RdDRoll.create(this.actor, rollData, const dialog = await RdDRoll.create(this.actor, rollData,
{ {
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-maitrise-tmr.html', html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-maitrise-tmr.html',
close: html => { this.maximize(); } // Re-display TMR close: html => { this.restoreTMRAfterAction(); }
}, },
{ {
name: rollData.maitrise.verbe, label: rollData.maitrise.action, name: rollData.maitrise.verbe, label: rollData.maitrise.action,
@ -861,7 +900,8 @@ export class RdDTMRDialog extends Dialog {
nettoyerRencontre() { nettoyerRencontre() {
if (!this.currentRencontre) return; // Sanity check if (!this.currentRencontre) return; // Sanity check
if (this.currentRencontre.graphics) { if (this.currentRencontre.graphics) {
for (let drawRect of this.currentRencontre.graphics) { // Suppression des dessins des zones possibles for (let drawRect of this.currentRencontre.graphics) {
// Suppression des dessins des zones possibles
this.pixiApp.stage.removeChild(drawRect); this.pixiApp.stage.removeChild(drawRect);
} }
} }
@ -894,8 +934,8 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
isConnaissanceFleuve(currentTMR, nextTMR) { isConnaissanceFleuve(tmrApp, nextTMR) {
return TMRUtility.getTMR(currentTMR).type == 'fleuve' && return TMRUtility.getTMR(tmrApp).type == 'fleuve' &&
TMRUtility.getTMR(nextTMR).type == 'fleuve' && TMRUtility.getTMR(nextTMR).type == 'fleuve' &&
EffetsDraconiques.isConnaissanceFleuve(this.actor); EffetsDraconiques.isConnaissanceFleuve(this.actor);
} }
@ -905,6 +945,9 @@ export class RdDTMRDialog extends Dialog {
if (this.viewOnly) { if (this.viewOnly) {
return; return;
} }
if (this.subdialog) {
return this.forceTMRContinueAction()
}
let clickOddq = TMRUtility.computeEventOddq(event); let clickOddq = TMRUtility.computeEventOddq(event);
let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord()); let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
@ -971,9 +1014,11 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _messagerDemiReve(targetCoord) { async _messagerDemiReve(targetCoord) {
/* /*
TODO: si la case a un sort en réserve, lancer ce sort. TODO:
Si la case a un sort en réserve, lancer ce sort.
Si la case est le demi-rêve, ne pas lancer de sort. Si la case est le demi-rêve, ne pas lancer de sort.
Si un lancement de sort est en cours, trouver un moyen de réafficher cette fenêtre si on essaie de lancer un sort (ou bloquer le lancer de sort) Si un lancement de sort est en cours, trouver un moyen de réafficher cette fenêtre
si on essaie de lancer un sort (ou bloquer le lancer de sort)
*/ */
this.notifierResonanceSigneDraconique(targetCoord); this.notifierResonanceSigneDraconique(targetCoord);
await this.actor.rollUnSort(targetCoord); await this.actor.rollUnSort(targetCoord);
@ -990,6 +1035,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _deplacerDemiReve(targetCoord, deplacementType) { async _deplacerDemiReve(targetCoord, deplacementType) {
if (this.subdialog) {
return this.forceTMRContinueAction()
}
if (this.currentRencontre != 'normal') { if (this.currentRencontre != 'normal') {
this.nettoyerRencontre(); this.nettoyerRencontre();
} }
@ -1039,6 +1087,10 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async positionnerDemiReve(coord) { async positionnerDemiReve(coord) {
if (this.subdialog) {
return this.forceTMRContinueAction()
}
await this.actor.updateCoordTMR(coord); await this.actor.updateCoordTMR(coord);
this.forceDemiRevePositionView(); this.forceDemiRevePositionView();
let tmr = TMRUtility.getTMR(coord); let tmr = TMRUtility.getTMR(coord);

View File

@ -2,7 +2,7 @@
export class RdDTMRRencontreDialog extends Dialog { export class RdDTMRRencontreDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(tmrApp, rencontre, tmr) { constructor(actor, rencontre, tmr) {
const dialogConf = { const dialogConf = {
title: "Rencontre en TMR!", title: "Rencontre en TMR!",
content: "Vous rencontrez un " + rencontre.name + " de force " + rencontre.system.force + "<br>", content: "Vous rencontrez un " + rencontre.name + " de force " + rencontre.system.force + "<br>",
@ -28,23 +28,30 @@ export class RdDTMRRencontreDialog extends Dialog {
this.toClose = false; this.toClose = false;
this.tmr = tmr; this.tmr = tmr;
this.tmrApp = tmrApp; this.actor = actor;
this.rencontre = rencontre; this.rencontre = rencontre;
this.tmrApp.minimize();
} }
async onButtonAction(action) { async onButtonAction(action) {
this.toClose = true; this.toClose = true;
this.tmrApp.onActionRencontre(action, this.tmr, this.rencontre) this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
close() { async close() {
if (this.toClose) { if (this.actor.tmrApp){
this.tmrApp.maximize(); if (this.toClose) {
return super.close(); this.actor.tmrApp?.restoreTMRAfterAction();
return await super.close();
}
else {
ui.notifications.info("Vous devez résoudre la rencontre.");
this.actor.tmrApp.forceTMRContinueAction();
}
}
else {
return await super.close();
} }
ui.notifications.info("Vous devez résoudre la rencontre.");
} }
} }

View File

@ -378,6 +378,9 @@ export class TMRUtility {
// /* -------------------------------------------- */ // /* -------------------------------------------- */
static computeEventPosition(event) { static computeEventPosition(event) {
if (!event.nativeEvent.target.getBoundingClientRect) {
return { x: 0, y: 0 }
}
const canvasRect = event.nativeEvent.target.getBoundingClientRect(); const canvasRect = event.nativeEvent.target.getBoundingClientRect();
return { return {
x: event.nativeEvent.clientX - canvasRect.left, x: event.nativeEvent.clientX - canvasRect.left,
@ -389,7 +392,7 @@ export class TMRUtility {
static computeEventOddq(event) { static computeEventOddq(event) {
var { x, y } = TMRUtility.computeEventPosition(event); var { x, y } = TMRUtility.computeEventPosition(event);
return TMRUtility.computeOddq(x, y); return TMRUtility.computeOddq(x, y);
} }
static computeOddq(x, y) { static computeOddq(x, y) {
const col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12] const col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12]

View File

@ -1,8 +1,8 @@
{ {
"id": "foundryvtt-reve-de-dragon", "id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"version": "11.0.24", "version": "11.0.25",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.0.24.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.0.25.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json",
"changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md", "changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md",
"compatibility": { "compatibility": {

View File

@ -1,6 +1,6 @@
<form class="tmr-dialog"> <form class="tmr-dialog">
<table> <table>
<tr id="tmrrow1"> <tr class="tmr-row">
<td> <td>
{{#if (eq mode "visu")}} {{#if (eq mode "visu")}}
<div class="flex-group-center"> <div class="flex-group-center">