## v11.0.25 - la vision du rêve de Khrachtchoum #672

Merged
uberwald merged 2 commits from VincentVk/foundryvtt-reve-de-dragon:v11 into v11 2023-10-22 21:40:43 +02:00
7 changed files with 106 additions and 39 deletions

View File

@ -1,4 +1,7 @@
# 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
- nouvelle carte des TMRs

View File

@ -369,7 +369,7 @@ export class RdDActor extends RdDBaseActor {
async _openRollDialog({ name, label, template, rollData, callbackAction }) {
const dialog = await RdDRoll.create(this, rollData,
{ html: template },
{ html: template, close: html => { this.tmrApp?.restoreTMRAfterAction() } },
{
name: name,
label: label,
@ -380,6 +380,7 @@ export class RdDActor extends RdDBaseActor {
]
});
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' }
}],
{ 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} !`);
return;
}
if (this.currentTMR) this.currentTMR.minimize(); // Hide
const draconicList = this.computeDraconicAndSortIndex(sorts);
const reve = duplicate(this.system.carac.reve);
await this._openRollDialog({
const dialog = await this._openRollDialog({
name: 'lancer-un-sort',
label: 'Lancer un sort',
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)
});
this.tmrApp?.setTMRPendingAction(dialog);
}
/* -------------------------------------------- */
@ -2252,9 +2254,9 @@ export class RdDActor extends RdDBaseActor {
await this.update({ "system.reve.reve.value": reveActuel });
if (rollData.isSortReserve) {
this.currentTMR.maximize(); // Re-display TMR
this.tmrApp.maximize(); // Re-display TMR
} else {
this.currentTMR.close(); // Close TMR !
this.tmrApp.close(); // Close TMR !
}
// Final chat message
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} !`);
return;
}
if (this.currentTMR) this.currentTMR.minimize(); // Hide
let draconicList = this.getDraconicList()
.map(draconic => {
let draconicLecture = duplicate(draconic);
@ -2747,7 +2747,7 @@ export class RdDActor extends RdDBaseActor {
const dialog = await RdDRoll.create(this, rollData,
{
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',
@ -2759,6 +2759,7 @@ export class RdDActor extends RdDBaseActor {
}
);
dialog.render(true);
this.tmrApp?.setTMRPendingAction(dialog);
}
/* -------------------------------------------- */
@ -2777,7 +2778,7 @@ export class RdDActor extends RdDBaseActor {
}
await this.deleteEmbeddedDocuments("Item", [rollData.signe._id]);
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() {
if (this.currentTMR) {
this.currentTMR.externalRefresh();
if (this.tmrApp) {
this.tmrApp.externalRefresh();
}
}
@ -3021,6 +3022,7 @@ export class RdDActor extends RdDBaseActor {
async displayTMR(mode = "normal") {
if (this.tmrApp) {
ui.notifications.warn("Vous êtes déja dans les TMR....");
this.tmrApp.forceTMRDisplay();
return
}
if (mode != 'visu' && this.getEffect(STATUSES.StatusDemiReve)) {
@ -3066,8 +3068,8 @@ export class RdDActor extends RdDBaseActor {
hasPlayerOwner: this.hasPlayerOwner
}
this.currentTMR = await RdDTMRDialog.create(this, tmrFormData);
this.currentTMR.render(true);
this.tmrApp = await RdDTMRDialog.create(this, tmrFormData);
this.tmrApp.render(true);
}
/* -------------------------------------------- */

View File

@ -2,7 +2,6 @@ import { SHOW_DICE } from "./constants.js";
import { RollDataAjustements } from "./rolldata-ajustements.js";
import { RdDUtility } from "./rdd-utility.js";
import { TMRUtility } from "./tmr-utility.js";
import { tmrConstants } from "./tmr-constants.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js";
import { ChatUtility } from "./chat-utility.js";
@ -39,7 +38,8 @@ export class RdDTMRDialog extends Dialog {
title: "Terres Médianes de Rêve",
content: html,
buttons: {
closeButton: { label: "Fermer", callback: html => this.close(html) }
closeButton: {
label: "Fermer", callback: html => this.close() }
},
default: "closeButton"
}
@ -63,6 +63,7 @@ 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.subdialog = undefined
this.callbacksOnAnimate = [];
if (!this.viewOnly) {
@ -73,6 +74,27 @@ export class RdDTMRDialog extends Dialog {
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() {
return !game.user.isGM && this.actor.isTMRCache();
}
@ -174,6 +196,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
async moveFromKey(move) {
if (this.subdialog) {
return this.forceTMRContinueAction();
}
let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
if (move == 'top') oddq.row -= 1;
@ -198,7 +223,9 @@ export class RdDTMRDialog extends Dialog {
super.activateListeners(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) {
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(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
this.html.find('tr.tmr-row *').click((event) => {
this.subdialog?.bringToTop();
});
// Roll Sort
this.html.find('.lancer-sort').click((event) => {
this.actor.rollUnSort(this._getActorCoord());
@ -230,7 +261,6 @@ export class RdDTMRDialog extends Dialog {
this.cumulFatigue += this.fatigueParCase;
}
await this.actor.reveActuelIncDec(reveCout);
// Le reste...
this.updateValuesDisplay();
let tmr = TMRUtility.getTMR(this._getActorCoord());
@ -270,6 +300,10 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
async close() {
if (this.subdialog) {
return this.forceTMRContinueAction()
}
this.descenteTMR = true;
if (this.actor.tmrApp) {
this.actor.tmrApp = undefined; // Cleanup reference
@ -292,6 +326,7 @@ export class RdDTMRDialog extends Dialog {
switch (action) {
case 'derober':
await this.derober();
this.restoreTMRAfterAction();
return;
case 'refouler':
await this.refouler();
@ -304,6 +339,7 @@ export class RdDTMRDialog extends Dialog {
break;
}
await this.postRencontre(tmr);
this.restoreTMRAfterAction();
}
async derober() {
@ -359,7 +395,6 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
checkQuitterTMR() {
if (this.actor.isDead()) {
this._tellToGM("Vous êtes mort : vous quittez les Terres médianes !");
this.close();
@ -530,8 +565,9 @@ export class RdDTMRDialog extends Dialog {
await this.maitriserRencontre();
}
else {
let dialog = new RdDTMRRencontreDialog(this, this.currentRencontre, tmr);
const dialog = new RdDTMRRencontreDialog(this.actor, this.currentRencontre, tmr);
dialog.render(true);
this.setTMRPendingAction(dialog);
}
}
else {
@ -586,7 +622,10 @@ export class RdDTMRDialog extends Dialog {
? TMRUtility.getTMRType(tmr.coord) + " ??"
: tmr.label + " (" + tmr.coord + ")");
const fakeDialogRencontre = { bringToTop: () => { } };
this.setTMRPendingAction(fakeDialogRencontre)
let myRoll = await RdDDice.rollTotal("1dt", { showDice: SHOW_DICE });
this.restoreTMRAfterAction()
if (myRoll == 7) {
this._tellToUser(myRoll + ": Rencontre en " + locTMR);
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,
{
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,
@ -861,7 +900,8 @@ export class RdDTMRDialog extends Dialog {
nettoyerRencontre() {
if (!this.currentRencontre) return; // Sanity check
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);
}
}
@ -894,8 +934,8 @@ export class RdDTMRDialog extends Dialog {
}
/* -------------------------------------------- */
isConnaissanceFleuve(currentTMR, nextTMR) {
return TMRUtility.getTMR(currentTMR).type == 'fleuve' &&
isConnaissanceFleuve(tmrApp, nextTMR) {
return TMRUtility.getTMR(tmrApp).type == 'fleuve' &&
TMRUtility.getTMR(nextTMR).type == 'fleuve' &&
EffetsDraconiques.isConnaissanceFleuve(this.actor);
}
@ -905,6 +945,9 @@ export class RdDTMRDialog extends Dialog {
if (this.viewOnly) {
return;
}
if (this.subdialog) {
return this.forceTMRContinueAction()
}
let clickOddq = TMRUtility.computeEventOddq(event);
let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
@ -971,9 +1014,11 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
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 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);
await this.actor.rollUnSort(targetCoord);
@ -990,6 +1035,9 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
async _deplacerDemiReve(targetCoord, deplacementType) {
if (this.subdialog) {
return this.forceTMRContinueAction()
}
if (this.currentRencontre != 'normal') {
this.nettoyerRencontre();
}
@ -1039,6 +1087,10 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
async positionnerDemiReve(coord) {
if (this.subdialog) {
return this.forceTMRContinueAction()
}
await this.actor.updateCoordTMR(coord);
this.forceDemiRevePositionView();
let tmr = TMRUtility.getTMR(coord);

View File

@ -2,7 +2,7 @@
export class RdDTMRRencontreDialog extends Dialog {
/* -------------------------------------------- */
constructor(tmrApp, rencontre, tmr) {
constructor(actor, rencontre, tmr) {
const dialogConf = {
title: "Rencontre en TMR!",
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.tmr = tmr;
this.tmrApp = tmrApp;
this.actor = actor;
this.rencontre = rencontre;
this.tmrApp.minimize();
}
async onButtonAction(action) {
this.toClose = true;
this.tmrApp.onActionRencontre(action, this.tmr, this.rencontre)
this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre)
}
/* -------------------------------------------- */
close() {
if (this.toClose) {
this.tmrApp.maximize();
return super.close();
async close() {
if (this.actor.tmrApp){
if (this.toClose) {
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) {
if (!event.nativeEvent.target.getBoundingClientRect) {
return { x: 0, y: 0 }
}
const canvasRect = event.nativeEvent.target.getBoundingClientRect();
return {
x: event.nativeEvent.clientX - canvasRect.left,
@ -389,7 +392,7 @@ export class TMRUtility {
static computeEventOddq(event) {
var { x, y } = TMRUtility.computeEventPosition(event);
return TMRUtility.computeOddq(x, y);
}
}
static computeOddq(x, y) {
const col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12]

View File

@ -1,8 +1,8 @@
{
"id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"version": "11.0.24",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.0.24.zip",
"version": "11.0.25",
"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",
"changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md",
"compatibility": {

View File

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