From 4bd23b3a59f1f29797f5928899d712a7f8c17ece Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 30 Dec 2020 18:12:01 +0100 Subject: [PATCH] =?UTF-8?q?#90=20Gestion=20des=20cases=20modifies=20de=20f?= =?UTF-8?q?a=C3=A7on=20permanente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor-sheet.js | 3 +- module/rdd-tmr-dialog.js | 46 +++++++++++++++++++++++++++++-- module/tmr-utility.js | 8 ++++-- system.json | 2 +- template.json | 12 ++++++-- templates/actor-sheet.html | 13 +++++++++ templates/item-casetmr-sheet.html | 35 +++++++++++++++++++++++ 7 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 templates/item-casetmr-sheet.html diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 05f15491..853d7cd0 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -124,7 +124,8 @@ export class RdDActorSheet extends ActorSheet { } RdDUtility.filterItemsPerTypeForSheet(data ); - data.data.sortReserve = data.data.reve.reserve.list; + data.data.sortReserve = data.data.reve.reserve.list; + data.data.caseSpeciales = data.itemsByType['casetmr']; RdDUtility.buildArbreDeConteneur( this, data ); data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index b41f4643..664d6b46 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -46,6 +46,7 @@ export class RdDTMRDialog extends Dialog { this.nbFatigue = this.viewOnly ? 0 : 1; // 1 premier point de fatigue du à la montée this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list); this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list); + this.casesSpeciales = this.actor.data.items.filter( item => item.type == 'casetmr'); this.allTokens = []; this.rencontreState = 'aucune'; this.pixiApp = new PIXI.Application({ width: 720, height: 860 }); @@ -69,6 +70,16 @@ export class RdDTMRDialog extends Dialog { } } + /* -------------------------------------------- */ + displaySpecificCase() { + for (let caseTMR of this.casesSpeciales) { + console.log("SPEC CASE ", caseTMR); + if ( caseTMR.data.specific == 'trounoir') { + this._trackToken(this._tokenTrouNoir( caseTMR.data.coord )); + } + } + } + /* -------------------------------------------- */ displayPreviousRencontres() { console.debug("displayPreviousRencontres", this.rencontresExistantes); @@ -275,7 +286,7 @@ export class RdDTMRDialog extends Dialog { if (rencontre) { // Manages it if (rencontre.rencontre) rencontre = rencontre.rencontre; // Manage stored rencontres - console.log("manageRencontre", rencontre) + console.log("manageRencontre", rencontre); this.currentRencontre = duplicate(rencontre); let dialog = new RdDTMRRencontreDialog("", this, this.currentRencontre); @@ -322,6 +333,23 @@ export class RdDTMRDialog extends Dialog { fatigueItem.innerHTML = "" + RdDUtility.makeHTMLfatigueMatrix(this.actor.data.data.sante.fatigue.value, this.actor.data.data.sante.endurance.max).html() + "
"; } + /* -------------------------------------------- */ + async manageCaseSpeciale( cellDescr, coordTMR ) { + for( let caseTMR of this.casesSpeciales) { + if (caseTMR.data.coord == coordTMR) { // Match ! + if (caseTMR.data.specific == 'trounoir') { + let newTMR = TMRUtility.getTMRAleatoire(); + let tmrPos = duplicate(this.actor.data.data.reve.tmrpos); + tmrPos.coord = newTMR; + await this.actor.update( { "data.reve.tmrpos": tmrPos } ); + ChatMessage.create( { + content: "Vous êtes rentré sur un Trou Noir : ré-insertion aléatoire.", + whisper: ChatMessage.getWhisperRecipients(game.user.name) } ); + } + } + } + } + /* -------------------------------------------- */ manageCaseHumideResult() { if (this.toclose) @@ -478,6 +506,7 @@ export class RdDTMRDialog extends Dialog { 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); @@ -554,7 +583,7 @@ export class RdDTMRDialog extends Dialog { this._addDemiReve(); this.displayPreviousRencontres(); this.displaySortReserve(); - + this.displaySpecificCase(); }); if (this.viewOnly) { @@ -604,6 +633,19 @@ 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 } + } + /* -------------------------------------------- */ _tokenSortEnReserve(sort) { let sprite = new PIXI.Graphics(); diff --git a/module/tmr-utility.js b/module/tmr-utility.js index 80168a60..3551a569 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -252,6 +252,9 @@ const rencontresTable = [ lac: "98-00", marais: "98-00", gouffre: "98-00", necropole: "98-00", desolation: "98-00" } } ] +/* -------------------------------------------- */ +const caseSpecificModes = [ "attache", "trounoir", "humide", "reserve_securite", "reserve_extensible", "maitrisee", "debordement" ]; + /* -------------------------------------------- */ const tmrMovePattern = [ { name: 'top', x: 0, y: -1 }, @@ -567,6 +570,7 @@ export class TMRUtility { let caseIndex = letter+num; ChatMessage.create( { content: "Case aléatoire : " + letter+num + " - " + TMRMapping[caseIndex].label , whisper: ChatMessage.getWhisperRecipients("GM") } ); + return caseIndex; } /* -------------------------------------------- */ @@ -589,13 +593,13 @@ export class TMRUtility { // TODO : Gérer les têtes spéciales réserve! let sortReserve let tmrDescr = this.getTMRDescription(coordTMR); - console.log("Sort réserve : ", tmrDescr); + //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' ); } else { // Reserve sur un case "normale" sortReserve = reserveList.find(it => it.coord == coordTMR); } - console.log("Sort réserve : ", tmrDescr, sortReserve, reserveList); + //console.log("Sort réserve : ", tmrDescr, sortReserve, reserveList); return sortReserve; } diff --git a/system.json b/system.json index 9dd214f6..d6b82a72 100644 --- a/system.json +++ b/system.json @@ -5,7 +5,7 @@ "version": "1.2.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.8", - "templateVersion": 73, + "templateVersion": 75, "author": "LeRatierBretonnien", "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "styles": ["styles/simple.css"], diff --git a/template.json b/template.json index c1c66e7b..c00220f7 100644 --- a/template.json +++ b/template.json @@ -541,7 +541,7 @@ } }, "Item": { - "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation"], + "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr" ], "objet": { "description": "", "quantite": 1, @@ -722,7 +722,15 @@ "purification": "", "veture": "", "comportement": "", - "tmr": "" + "tmr": "", + "description": "" + }, + "casetmr": { + "coord": "", + "type": "", + "label": "", + "specific": "", + "description": "" } } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index a7edc110..07804020 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -597,6 +597,19 @@ {{/each}} +
+ Cases Spéciales: + +
{{!-- Equipment Tab --}} diff --git a/templates/item-casetmr-sheet.html b/templates/item-casetmr-sheet.html new file mode 100644 index 00000000..07f7a317 --- /dev/null +++ b/templates/item-casetmr-sheet.html @@ -0,0 +1,35 @@ +
+
+ +
+

+
+
+ + {{!-- Sheet Body --}} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} +
+
+
+ +