diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 853d7cd0..90af6b3b 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -370,12 +370,18 @@ export class RdDActorSheet extends ActorSheet {
const item = this.actor.getOwnedItem(myID);
item.sheet.render(true);
});
- // Display info about queue
+ // Info sort
html.find('.sort-label a').click((event) => {
let myID = event.currentTarget.attributes['data-id'].value;
const item = this.actor.getOwnedItem(myID);
item.sheet.render(true);
});
+ // Info sort
+ html.find('.case-label a').click((event) => {
+ let myID = event.currentTarget.attributes['data-id'].value;
+ const item = this.actor.getOwnedItem(myID);
+ item.sheet.render(true);
+ });
// Display info about queue
html.find('.conteneur-name a').click((event) => {
diff --git a/module/actor.js b/module/actor.js
index 7bbaedf8..c3c3fda4 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -162,13 +162,13 @@ export class RdDActor extends Actor {
return this.encTotal ? Math.floor(this.encTotal) : 0
}
/* -------------------------------------------- */
- async deleteSortReserve(coordTMR) {
+ async deleteSortReserve(sortReserve) {
let reserve = duplicate(this.data.data.reve.reserve);
let len = reserve.list.length;
let i = 0;
let newTable = [];
for( i=0; i < len; i++) {
- if (reserve.list[i].coord != coordTMR )
+ if (reserve.list[i].coord != sortReserve.coord && reserve.list[i].sort.name != sortReserve.sort.name )
newTable.push(reserve.list[i]);
}
if ( newTable.length != len ) {
@@ -1351,6 +1351,12 @@ export class RdDActor extends Actor {
return 1;
}
+ /* -------------------------------------------- */
+ isReserveEnSecurite() {
+ let reserveSecurite = this.data.items.find( item => item.type == 'tete' && item.name.toLowerCase().includes( ' en sécurité' ) );
+ return reserveSecurite;
+ }
+
/* -------------------------------------------- */
isDoubleResistanceFleuve( ) {
let resistFleuve = this.data.items.find( item => item.type == 'souffle' && item.name.toLowerCase().includes( 'résistance du fleuve' ) );
diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js
index 664d6b46..af6f3be0 100644
--- a/module/rdd-tmr-dialog.js
+++ b/module/rdd-tmr-dialog.js
@@ -76,6 +76,8 @@ export class RdDTMRDialog extends Dialog {
console.log("SPEC CASE ", caseTMR);
if ( caseTMR.data.specific == 'trounoir') {
this._trackToken(this._tokenTrouNoir( caseTMR.data.coord ));
+ } else if ( caseTMR.data.specific == 'attache') {
+ this._trackToken(this._tokenTerreAttache( caseTMR.data.coord ));
}
}
}
@@ -418,6 +420,14 @@ export class RdDTMRDialog extends Dialog {
humideDiag.render(true);
}
}
+ /* -------------------------------------------- */
+ isReserveExtensible( coordTMR) {
+ for( let caseTMR of this.casesSpeciales) {
+ if (caseTMR.data.specific == 'reserve_extensible' && caseTMR.data.coord == coordTMR )
+ return true;
+ }
+ return false;
+ }
/* -------------------------------------------- */
async declencheSortEnReserve(coordTMR) {
@@ -425,18 +435,47 @@ export class RdDTMRDialog extends Dialog {
return;
}
- let sortReserve = TMRUtility.getSortReserve( this.sortReserves, coordTMR );
- if (sortReserve != undefined) {
- await this.actor.deleteSortReserve(sortReserve.coord);
- this.updateSortReserve();
- console.log("declencheSortEnReserve", sortReserve)
- const declenchementSort = "Vous avez déclenché le sort " + sortReserve.sort.name
- + " en réserve en " + sortReserve.coord + " (" + TMRUtility.getTMRDescription(sortReserve.coord).label
- + ") avec " + sortReserve.sort.data.ptreve_reel + " points de Rêve";
- this._tellToGM(declenchementSort);
- this.close();
+ let sortReserveList = TMRUtility.getSortReserveList( this.sortReserves, coordTMR );
+ if (sortReserveList.length > 0 ) {
+ if ( this.actor.isReserveEnSecurite() || this.isReserveExtensible(coordTMR) ) {
+ let msg = "Vous êtes sur une case avec un Sort en Réserve. Grâce à votre Tête Reserve en Sécurité ou Réserve Exensible, vous pouvez contrôler le déclenchement. Cliquez si vous souhaitez le déclencher :
";
+ for (let sortReserve of sortReserveList) {
+ msg += "- "+sortReserve.sort.name+"
";
+ }
+ msg += "";
+ ChatMessage.create( {
+ content: msg,
+ whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
+ } else {
+ await this.processSortReserve( sortReserveList[0] );
+ }
}
}
+ /* -------------------------------------------- */
+ lancerSortEnReserve( coordTMR, sortId ) {
+ let sortReserveList = TMRUtility.getSortReserveList( this.sortReserves, coordTMR );
+ let sortReserve = sortReserveList.find( sortReserve => sortReserve.sort._id == sortId);
+ //console.log("SORT RESA", sortReserveList, coordTMR, sortId, sortReserve);
+ if ( sortReserve) {
+ this.processSortReserve( sortReserve );
+ } else {
+ ChatMessage.create( {
+ content: "Une erreur est survenue : impossible de récupérer le sort en réserve demandé.",
+ whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
+ }
+ }
+
+ /* -------------------------------------------- */
+ async processSortReserve( sortReserve ) {
+ await this.actor.deleteSortReserve(sortReserve);
+ this.updateSortReserve();
+ console.log("declencheSortEnReserve", sortReserve)
+ const declenchementSort = "Vous avez déclenché le sort " + sortReserve.sort.name
+ + " en réserve en " + sortReserve.coord + " (" + TMRUtility.getTMRDescription(sortReserve.coord).label
+ + ") avec " + sortReserve.sort.data.ptreve_reel + " points de Rêve";
+ this._tellToGM(declenchementSort);
+ this.close();
+ }
/* -------------------------------------------- */
nettoyerRencontre( ) {
@@ -463,6 +502,16 @@ export class RdDTMRDialog extends Dialog {
return deplacementType;
}
+ /* -------------------------------------------- */
+ isTerreAttache( coordTMR ) {
+ for( let caseTMR of this.casesSpeciales) {
+ if (caseTMR.data.specific == 'attache' && caseTMR.data.coord == coordTMR) { // Match !
+ return true;
+ }
+ }
+ return false;
+ }
+
/* -------------------------------------------- */
async deplacerDemiReve(event) {
if (this.viewOnly) {
@@ -482,7 +531,7 @@ export class RdDTMRDialog extends Dialog {
// Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter)
let deplacementType = 'erreur';
if ( myself.rencontreState == 'aucune') { // Pas de recontre en post-processing, donc deplacement normal
- if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly) ) {
+ if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly) || myself.isTerreAttache(coordTMR) ) {
deplacementType = 'normal';
}
} else {
@@ -490,10 +539,12 @@ export class RdDTMRDialog extends Dialog {
}
// Si le deplacement est valide
if ( deplacementType == 'normal' || deplacementType == 'saut') {
- if ( myself.currentRencontre != 'normal' )
+ if ( myself.currentRencontre != 'normal' )
myself.nettoyerRencontre();
let cellDescr = TMRUtility.getTMRDescription(coordTMR);
+ await myself.manageCaseSpeciale(cellDescr, coordTMR); // Gestion cases spéciales type Trou noir, etc
+
console.log("deplacerDemiReve: TMR column is", coordTMR, cellx, celly, cellDescr, this);
let tmrPos = duplicate(myself.actor.data.data.reve.tmrpos);
@@ -503,10 +554,10 @@ export class RdDTMRDialog extends Dialog {
myself.nbFatigue += 1;
myself.updateValuesDisplay();
+
if ( deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/...
await myself.manageRencontre(coordTMR, cellDescr);
}
- await myself.manageCaseSpeciale(cellDescr, coordTMR);
await myself.manageCaseHumide(cellDescr);
await myself.declencheSortEnReserve(coordTMR);
await myself.actor.checkSoufflePeage(cellDescr);
@@ -633,18 +684,31 @@ export class RdDTMRDialog extends Dialog {
return { sprite: sprite, rencontre: rencontre, coordTMR: () => rencontre.coord };
}
- /* -------------------------------------------- */
- _tokenTrouNoir( coord ) {
- let sprite = new PIXI.Graphics();
- sprite.beginFill(0x050505, 0.8);
- sprite.drawCircle(0, 0, (tmrConstants.cellw / 2) - 2);
- sprite.endFill();
- sprite.decallage = {
- x: 0,
- y: 2
- }
- return { sprite: sprite, coordTMR: () => coord }
+ /* -------------------------------------------- */
+ _tokenTrouNoir( coord ) {
+ let sprite = new PIXI.Graphics();
+ sprite.beginFill(0x050505, 0.8);
+ sprite.drawCircle(0, 0, (tmrConstants.cellw / 2) - 2);
+ sprite.endFill();
+ sprite.decallage = {
+ x: 0,
+ y: 2
}
+ return { sprite: sprite, coordTMR: () => coord }
+ }
+
+ /* -------------------------------------------- */
+ _tokenTerreAttache(coord) {
+ let sprite = new PIXI.Graphics();
+ sprite.beginFill(0x10F010, 0.8);
+ sprite.drawCircle(0, 0, 6);
+ sprite.endFill();
+ sprite.decallage = {
+ x: 16 - (tmrConstants.cellw / 2),
+ y: 16 - (tmrConstants.cellh / 2)
+ }
+ return { sprite: sprite, coordTMR: () => coord }
+ }
/* -------------------------------------------- */
_tokenSortEnReserve(sort) {
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index e558795f..8eb9f414 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -865,12 +865,21 @@ export class RdDUtility {
{
RdDCombat.registerChatCallbacks(html);
+ // Gestion spécifique message passeurs
html.on("click", '.tmr-passeur-coord a', event => {
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId );
actor.tmrApp.forceDemiRevePosition(coord);
});
+ // Gestio spécifique des sorts en réserve multiples (ie têtes)
+ html.on("click", '#sort-reserve', event => {
+ let coord = event.currentTarget.attributes['data-tmr-coord'].value;
+ let sortId = event.currentTarget.attributes['data-sort-id'].value;
+ let actorId = event.currentTarget.attributes['data-actor-id'].value;
+ let actor = game.actors.get( actorId );
+ actor.tmrApp.lancerSortEnReserve(coord, sortId);
+ });
}
/* -------------------------------------------- */
diff --git a/module/tmr-utility.js b/module/tmr-utility.js
index 3551a569..8bb4081a 100644
--- a/module/tmr-utility.js
+++ b/module/tmr-utility.js
@@ -253,7 +253,7 @@ const rencontresTable = [
]
/* -------------------------------------------- */
-const caseSpecificModes = [ "attache", "trounoir", "humide", "reserve_securite", "reserve_extensible", "maitrisee", "debordement" ];
+const caseSpecificModes = [ "attache", "trounoir", "humide", "reserve_extensible", "maitrisee", "debordement" ];
/* -------------------------------------------- */
const tmrMovePattern =
@@ -589,18 +589,18 @@ export class TMRUtility {
}
/* -------------------------------------------- */
- static getSortReserve( reserveList, coordTMR ) {
+ static getSortReserveList( reserveList, coordTMR ) {
// TODO : Gérer les têtes spéciales réserve!
- let sortReserve
+ let sortReserveList
let tmrDescr = this.getTMRDescription(coordTMR);
//console.log("Sort réserve : ", tmrDescr);
if ( tmrDescr.type == 'fleuve') { // Gestion de la reserve en Fleuve
- sortReserve = reserveList.find(it => TMRUtility.getTMRDescription(it.coord).type == 'fleuve' );
+ sortReserveList = reserveList.filter(it => TMRUtility.getTMRDescription(it.coord).type == 'fleuve' );
} else { // Reserve sur un case "normale"
- sortReserve = reserveList.find(it => it.coord == coordTMR);
+ sortReserveList = reserveList.filter(it => it.coord == coordTMR);
}
//console.log("Sort réserve : ", tmrDescr, sortReserve, reserveList);
- return sortReserve;
+ return sortReserveList;
}
/* -------------------------------------------- */