From 67e5e2c822a99f8ce6337a67579669f902fae555 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 30 Dec 2020 21:11:01 +0100 Subject: [PATCH] #90 : Gestion de la connaissance du fleuve --- module/actor.js | 14 ++++++++++ module/rdd-tmr-dialog.js | 59 +++++++++++++++++++++++++++++++++++++--- module/tmr-utility.js | 2 +- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/module/actor.js b/module/actor.js index ca5ad169..dfa81ead 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1351,6 +1351,11 @@ export class RdDActor extends Actor { return 1; } + /* -------------------------------------------- */ + isConnaissanceFleuve( ) { + return this.data.items.find( item => item.type == 'tete' && item.name.toLowerCase().includes( 'connaissance du fleuve' ) ); + } + /* -------------------------------------------- */ isReserveEnSecurite() { let reserveSecurite = this.data.items.find( item => item.type == 'tete' && item.name.toLowerCase().includes( ' en sécurité' ) ); @@ -1380,6 +1385,15 @@ export class RdDActor extends Actor { } } + /* -------------------------------------------- */ + checkTeteDeplacementAccelere() { + let deplAccelere = this.data.items.find( item => item.type == 'tete' && item.name.toLowerCase().includes( ' déplacement accéléré' ) ); + if ( deplAccelere ) { + return true; + } + return false; + } + /* -------------------------------------------- */ checkIsAdditionnalHumide( cellDescr, coordTMR) { let pontHumide = this.data.items.find( item => item.type == 'souffle' && item.name.toLowerCase().includes( ' des ponts' ) ); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index adad3cb3..134665d5 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -80,6 +80,8 @@ export class RdDTMRDialog extends Dialog { this._trackToken(this._tokenTerreAttache( caseTMR.data.coord )); } else if ( caseTMR.data.specific == 'debordement') { this._trackToken(this._tokenDebordement( caseTMR.data.coord )); + } else if ( caseTMR.data.specific == 'maitrisee') { + this._trackToken(this._tokenMaitrisee( caseTMR.data.coord )); } } } @@ -354,6 +356,16 @@ export class RdDTMRDialog extends Dialog { } } + /* -------------------------------------------- */ + isCaseMaitrisee( coordTMR) { + for( let caseTMR of this.casesSpeciales) { + if (caseTMR.data.coord == coordTMR && caseTMR.data.specific == 'maitrisee') { + return true; + } + } + return false; + } + /* -------------------------------------------- */ manageCaseHumideResult() { if (this.toclose) @@ -367,6 +379,12 @@ export class RdDTMRDialog extends Dialog { } let isHumide = this.actor.checkIsAdditionnalHumide(cellDescr, coordTMR); if (cellDescr.type == "lac" || cellDescr.type == "fleuve" || cellDescr.type == "marais" || isHumide) { + if ( this.isCaseMaitrisee( coordTMR ) ) { + ChatMessage.create( { + content: "Cette case humide est déja maitrisée grâce à votre Tête Quête des Eaux", + whisper: ChatMessage.getWhisperRecipients(game.user.name) } ); + return; + } // TODO: permettre de choisir la voie de draconic? let draconic = this.actor.getBestDraconic(); @@ -514,6 +532,17 @@ export class RdDTMRDialog extends Dialog { return false; } + /* -------------------------------------------- */ + checkConnaissanceFleuve( currentTMR, nextTMR ) { + if ( this.actor.isConnaissanceFleuve() ) { + //console.log(currentTMR, nextTMR ); + if ( TMRUtility.getTMRDescription(currentTMR).type == 'fleuve' && TMRUtility.getTMRDescription(nextTMR).type == 'fleuve') { + return true; + } + } + return false; + } + /* -------------------------------------------- */ async deplacerDemiReve(event) { if (this.viewOnly) { @@ -529,11 +558,12 @@ export class RdDTMRDialog extends Dialog { console.log("deplacerDemiReve >>>>", cellx, celly); let currentPos = TMRUtility.convertToCellCoord(myself.actor.data.data.reve.tmrpos.coord); let coordTMR = TMRUtility.convertToTMRCoord(cellx, celly); - + let currentTMR = TMRUtility.convertToTMRCoord( currentPos.x, currentPos.y); + // 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) || myself.isTerreAttache(coordTMR) ) { + if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly) || myself.isTerreAttache(coordTMR) || myself.checkConnaissanceFleuve(currentTMR,coordTMR ) ) { deplacementType = 'normal'; } } else { @@ -643,8 +673,16 @@ export class RdDTMRDialog extends Dialog { return; } - let addMonteLaborieuse = this.actor.checkMonteeLaborieuse(); - await this.actor.reveActuelIncDec( (this.tmrdata.isRapide) ? -2-addMonteLaborieuse : -1-addMonteLaborieuse ); + // Gestion du cout de montée en points de rêve + let reveCout = -1; + if ( this.actor.checkTeteDeplacementAccelere() ) { + reveCout = -1; + } else { + reveCout = (this.tmrdata.isRapide) ? -2 : -1; + } + reveCout -= this.actor.checkMonteeLaborieuse(); + await this.actor.reveActuelIncDec( reveCout ); + // Le reste... this.updateValuesDisplay(); let coordTMR = this.actor.data.data.reve.tmrpos.coord; let cellDescr = TMRUtility.getTMRDescription(coordTMR); @@ -713,6 +751,19 @@ export class RdDTMRDialog extends Dialog { return { sprite: sprite, coordTMR: () => coord } } + /* -------------------------------------------- */ + _tokenMaitrisee(coord) { + let sprite = new PIXI.Graphics(); + sprite.beginFill(0x1010F0, 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 } + } + /* -------------------------------------------- */ _tokenTerreAttache(coord) { let sprite = new PIXI.Graphics(); diff --git a/module/tmr-utility.js b/module/tmr-utility.js index cbec6024..1573392e 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -253,7 +253,7 @@ const rencontresTable = [ ] /* -------------------------------------------- */ -const caseSpecificModes = [ "attache", "trounoir", "debordement", "reserve_extensible", "maitrisee", "debordement" ]; +const caseSpecificModes = [ "attache", "trounoir", "debordement", "reserve_extensible", "maitrisee" ]; /* -------------------------------------------- */ const tmrMovePattern =