From f20a8055c6633b4aeda2cf4a5775a2cc8d8cdec8 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 10 May 2021 18:39:35 +0200 Subject: [PATCH] Minor reformat avant signes draconiques --- module/actor-sheet.js | 25 ++------ module/actor.js | 12 ++-- module/item.js | 1 + module/rdd-main.js | 10 +-- module/rdd-tmr-dialog.js | 67 ++++++++++---------- templates/actor-sheet.html | 106 +++++++++++++++++++------------- templates/dialog-roll-sort.html | 1 - 7 files changed, 114 insertions(+), 108 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index ab9de568..441e0222 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -223,6 +223,11 @@ export class RdDActorSheet extends ActorSheet { const item = this.actor.items.get(li.data("item-id")); item.sheet.render(true); }); + html.find('.display-label a').click((event) => { + let myID = event.currentTarget.attributes['data-item-id'].value; + const item = this.actor.getEmbeddedDocument('Item', myID); + item.sheet.render(true); + }); html.find('.rencontre-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); const rencontreKey = li.data("item-id"); @@ -428,26 +433,6 @@ export class RdDActorSheet extends ActorSheet { html.find('.enlever-tous-effets').click((event) => { this.actor.enleverTousLesEffets(); }); - // Display info about queue - html.find('.queuesouffle-label a').click((event) => { - let myID = event.currentTarget.attributes['data-item-id'].value; - const item = this.actor.getEmbeddedDocument('Item', myID); - item.sheet.render(true); - }); - // Info sort - html.find('.sort-label a').click((event) => { - let myID = event.currentTarget.attributes['data-id'].value; - const item = this.actor.getEmbeddedDocument('Item', 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.getEmbeddedDocument('Item', myID); - item.sheet.render(true); - }); - - // Display info about queue html.find('.conteneur-name a').click((event) => { let myID = event.currentTarget.attributes['data-item-id'].value; RdDUtility.toggleAfficheContenu(myID); diff --git a/module/actor.js b/module/actor.js index c63ff35d..da276847 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1482,7 +1482,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async santeIncDec(name, inc, options = { isCritique: false, ethylisme: false }) { - if (name=='fatigue' && !ReglesOptionelles.isUsing("appliquer-fatigue")) { + if (name == 'fatigue' && !ReglesOptionelles.isUsing("appliquer-fatigue")) { return; } const sante = duplicate(Misc.templateData(this).sante); @@ -2097,9 +2097,11 @@ export class RdDActor extends Actor { let draconicList = this.computeDraconicAndSortIndex(sortList); const actorData = Misc.data(this); + const reve = duplicate(actorData.data.carac.reve); let rollData = { - forceCarac: { 'reve': duplicate(actorData.data.carac.reve) }, - selectedCarac: duplicate(actorData.data.carac.reve), + carac: { 'reve': reve }, + forceCarac: { 'reve': reve }, + selectedCarac: reve, draconicList: draconicList, sortList: sortList, competence: draconicList[0], @@ -2107,10 +2109,8 @@ export class RdDActor extends Actor { tmr: TMRUtility.getTMR(coord), diffLibre: RdDItemSort.getDifficulte(sortList[0], -7), // Per default at startup coutreve: Array(30).fill().map((item, index) => 1 + index), - carac: { 'reve': duplicate(actorData.data.carac.reve) } } - if (this.currentTMR) this.currentTMR.minimize(); // Hide const dialog = await RdDRoll.create(this, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', @@ -3306,7 +3306,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async achatVente(vendeurId, acheteurId, venteData, chatMessageIdVente) { - if (vendeurId == acheteurId){ + if (vendeurId == acheteurId) { ui.notifications.info("Inutile de se vendre à soi-même"); return; } diff --git a/module/item.js b/module/item.js index 75610267..98bda21f 100644 --- a/module/item.js +++ b/module/item.js @@ -25,6 +25,7 @@ export class RdDItem extends Item { isConteneur() { return Misc.data(this).type == 'conteneur'; } + isVide() { return this.isConteneur() && (Misc.templateData(this).contenu ?? []).length == 0; } diff --git a/module/rdd-main.js b/module/rdd-main.js index e019331f..e7136f9c 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -117,7 +117,7 @@ Hooks.once("init", async function () { config: true, default: true, type: Boolean - }); + }); /* -------------------------------------------- */ game.settings.register("foundryvtt-reve-de-dragon", "appliquer-famine-soif", { name: "Notifier de la famine et la soif pour", @@ -131,7 +131,7 @@ Hooks.once("init", async function () { "famine-soif": "la famine et la soif", }, default: "aucun" - }); + }); /* -------------------------------------------- */ // Set an initiative formula for the system @@ -176,7 +176,7 @@ Hooks.once("init", async function () { RdDDice.init(); RdDCommands.init(); RdDCombat.init(); - RdDCombatManager.init(), + RdDCombatManager.init(); RdDTokenHud.init(); RdDActor.init(); RddCompendiumOrganiser.init(); @@ -198,12 +198,12 @@ function messageDeBienvenue() { ` }); } } - + /* -------------------------------------------- */ /* Foundry VTT Initialization */ /* -------------------------------------------- */ Hooks.once("ready", function () { - + StatusEffects.onReady(); RdDHerbes.initializeHerbes(); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index 54ca9860..d593129c 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -59,8 +59,8 @@ 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.cacheTMR = (game.user.isGM) ? false: actor.isTMRCache(); + this.pixiTMR = new PixiTMR(this, this.pixiApp); + this.cacheTMR = (game.user.isGM) ? false : actor.isTMRCache(); this.callbacksOnAnimate = []; if (!this.viewOnly) { @@ -69,7 +69,7 @@ export class RdDTMRDialog extends Dialog { } // load the texture we need - this.pixiTMR.load( (loader, resources) => this.createPixiSprites() ); + this.pixiTMR.load((loader, resources) => this.createPixiSprites()); } /* -------------------------------------------- */ @@ -142,20 +142,25 @@ export class RdDTMRDialog extends Dialog { _tokenSortEnReserve(sortEnReserve) { return EffetsDraconiques.sortReserve.token(this.pixiTMR, sortEnReserve.sort, () => sortEnReserve.coord); } + _tokenDemiReve() { const actorData = Misc.data(this.actor); return EffetsDraconiques.demiReve.token(this.pixiTMR, actorData, () => actorData.data.reve.tmrpos.coord); } _updateDemiReve() { - if ( !this.cacheTMR) { + if (!this.cacheTMR) { this._setTokenPosition(this.demiReve); } } + _getActorCoord() { + return Misc.data(this.actor).data.reve.tmrpos.coord; + } + /* -------------------------------------------- */ - async moveFromKey( move ) { - let pos = TMRUtility.convertToCellPos(Misc.data(this.actor).data.reve.tmrpos.coord); + async moveFromKey(move) { + let pos = TMRUtility.convertToCellPos(this._getActorCoord()); if (move == 'top') pos.y -= 1; if (move == 'bottom') pos.y += 1; @@ -165,7 +170,7 @@ export class RdDTMRDialog extends Dialog { if (move == 'top-left') pos.y -= 1; if (move == 'top-right') pos.y -= 1; } else { - if (move == 'bottom-left') pos.y += 1; + if (move == 'bottom-left') pos.y += 1; if (move == 'bottom-right') pos.y += 1; } @@ -196,34 +201,33 @@ export class RdDTMRDialog extends Dialog { html.find('#dir-top').click((event) => { this.moveFromKey("top"); - } ); + }); html.find('#dir-top-left').click((event) => { this.moveFromKey("top-left"); - } ); + }); html.find('#dir-top-right').click((event) => { this.moveFromKey("top-right"); - } ); + }); html.find('#dir-bottom-left').click((event) => { this.moveFromKey("bottom-left"); - } ); + }); html.find('#dir-bottom-right').click((event) => { this.moveFromKey("bottom-right"); - } ); + }); html.find('#dir-bottom').click((event) => { this.moveFromKey("bottom"); - } ); + }); - // Gestion du cout de montée en points de rêve let reveCout = ((this.tmrdata.isRapide && !EffetsDraconiques.isDeplacementAccelere(this.actor)) ? -2 : -1) - this.actor.countMonteeLaborieuse(); - if (ReglesOptionelles.isUsing("appliquer-fatigue")){ + if (ReglesOptionelles.isUsing("appliquer-fatigue")) { this.cumulFatigue += this.fatigueParCase; } await this.actor.reveActuelIncDec(reveCout); // Le reste... this.updateValuesDisplay(); - let tmr = TMRUtility.getTMR(Misc.data(this.actor).data.reve.tmrpos.coord); + let tmr = TMRUtility.getTMR(this._getActorCoord()); await this.manageRencontre(tmr, () => { this.postRencontre(tmr); }); @@ -234,13 +238,13 @@ export class RdDTMRDialog extends Dialog { let ptsreve = document.getElementById("tmr-pointsreve-value"); const actorData = Misc.data(this.actor); ptsreve.innerHTML = actorData.data.reve.reve.value; + const coord = this._getActorCoord(); let tmrpos = document.getElementById("tmr-pos"); - if ( this.cacheTMR ) { - tmrpos.innerHTML = '?? ('+ TMRUtility.getTMRType( actorData.data.reve.tmrpos.coord ) + ')'; + if (this.cacheTMR) { + tmrpos.innerHTML = '?? (' + TMRUtility.getTMRType(coord) + ')'; } else { - let tmr = TMRUtility.getTMR(actorData.data.reve.tmrpos.coord); - tmrpos.innerHTML = actorData.data.reve.tmrpos.coord + " (" + tmr.label + ")"; + tmrpos.innerHTML = coord + " (" + TMRUtility.getTMRLabel(coord) + ")"; } let etat = document.getElementById("tmr-etatgeneral-value"); @@ -249,7 +253,7 @@ export class RdDTMRDialog extends Dialog { let refoulement = document.getElementById("tmr-refoulement-value"); refoulement.innerHTML = actorData.data.reve.refoulement.value; - if (ReglesOptionelles.isUsing("appliquer-fatigue")){ + if (ReglesOptionelles.isUsing("appliquer-fatigue")) { let fatigueItem = document.getElementById("tmr-fatigue-table"); //console.log("Refresh : ", actorData.data.sante.fatigue.value); fatigueItem.innerHTML = "" + RdDUtility.makeHTMLfatigueMatrix(actorData.data.sante.fatigue.value, actorData.data.sante.endurance.max).html() + "
"; @@ -373,7 +377,7 @@ export class RdDTMRDialog extends Dialog { rencontre: this.currentRencontre, nbRounds: 1, canClose: false, - tmr: TMRUtility.getTMR(Misc.data(this.actor).data.reve.tmrpos.coord) + tmr: TMRUtility.getTMR(this._getActorCoord()) } await this._tentativeMaitrise(rencontreData); @@ -414,7 +418,7 @@ export class RdDTMRDialog extends Dialog { else if (rencData.rolled.isEchec && rencData.rencontre.isPersistant) { setTimeout(() => { rencData.nbRounds++; - if (ReglesOptionelles.isUsing("appliquer-fatigue")){ + if (ReglesOptionelles.isUsing("appliquer-fatigue")) { this.cumulFatigue += this.fatigueParCase; } this._tentativeMaitrise(rencData); @@ -523,11 +527,11 @@ export class RdDTMRDialog extends Dialog { if (rencontre) { return rencontre; } - let myRoll = new Roll("1d7").evaluate( { async: false} ).total; + let myRoll = new Roll("1d7").evaluate({ async: false }).total; if (TMRUtility.isForceRencontre() || myRoll == 7) { return await this.rencontreTMRRoll(tmr, this.actor.isRencontreSpeciale()); } - let locTMR = (this.cacheTMR) ? "??": tmr.label + " (" + tmr.coord + ")"; + let locTMR = (this.cacheTMR) ? "??" : tmr.label + " (" + tmr.coord + ")"; this._tellToUser(myRoll + ": Pas de rencontre en " + locTMR); } @@ -852,7 +856,7 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async _onClickTMRPos(eventPos) { - let currentPos = TMRUtility.convertToCellPos(Misc.data(this.actor).data.reve.tmrpos.coord); + let currentPos = TMRUtility.convertToCellPos(this._getActorCoord()); console.log("deplacerDemiReve >>>>", currentPos, eventPos); @@ -861,7 +865,7 @@ export class RdDTMRDialog extends Dialog { // Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter) let deplacementType = this._calculDeplacement(targetCoord, currentCoord, currentPos, eventPos); - + // Si le deplacement est valide if (deplacementType == 'normal' || deplacementType == 'saut') { await this._deplacerDemiReve(targetCoord, deplacementType); @@ -901,8 +905,8 @@ export class RdDTMRDialog extends Dialog { } /* -------------------------------------------- */ - externalRefresh( tmrData ) { - this.cacheTMR = (game.user.isGM) ? false: this.actor.isTMRCache(); + externalRefresh(tmrData) { + this.cacheTMR = (game.user.isGM) ? false : this.actor.isTMRCache(); this.createPixiSprites(); this.forceDemiRevePositionView(); this.updateValuesDisplay(); @@ -920,11 +924,10 @@ export class RdDTMRDialog extends Dialog { // Gestion cases spéciales type Trou noir, etc tmr = await this.manageTmrInnaccessible(tmr); - this.actor.updateCoordTMR(tmr.coord); await this.actor.updateCoordTMR(tmr.coord); this._updateDemiReve(); - if (ReglesOptionelles.isUsing("appliquer-fatigue")){ + if (ReglesOptionelles.isUsing("appliquer-fatigue")) { this.cumulFatigue += this.fatigueParCase; } this.updateValuesDisplay(); @@ -998,7 +1001,7 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ _setTokenPosition(token) { - if ( !this.cacheTMR) { + if (!this.cacheTMR) { this.pixiTMR.setPosition(token.sprite, TMRUtility.convertToCellPos(token.coordTMR())); } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index c428fe72..069e0eac 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -310,7 +310,7 @@