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 = "