From 5bb4e02915d404ea9645b482585cab0ed6eef604 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 11 Jan 2022 23:39:51 +0100 Subject: [PATCH 1/4] Fix getActiveUser for v9 --- module/chat-utility.js | 2 +- module/misc.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/module/chat-utility.js b/module/chat-utility.js index 224b2d2b..65e0c557 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -138,7 +138,7 @@ export class ChatUtility { /* -------------------------------------------- */ static getUsers(filter) { - return game.users.filter(filter).map(user => user.data._id); + return Misc.getUsers().filter(filter).map(user => user.data._id); } /* -------------------------------------------- */ diff --git a/module/misc.js b/module/misc.js index f7c62a42..3f8fa2a9 100644 --- a/module/misc.js +++ b/module/misc.js @@ -134,16 +134,17 @@ export class Misc { return Misc.firstConnectedGM()?.id ?? game.user.id; } - static getActiveUser(id) { - return game.users.entities.find(u => u.id == id && u.active); + static getUsers() { + return game.version ? game.users : game.users.entities; } + static getActiveUser(id) { + return Misc.getUsers().find(u => u.id == id && u.active); + } + static firstConnectedGM() { - if (game.version){ - return game.users.filter(u => u.isGM && u.active)[0]; - } else { - return game.users.entities.sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); - } + return Misc.getUsers().filter(u => u.isGM && u.active).sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); + } /** @@ -155,7 +156,7 @@ export class Misc { /* -------------------------------------------- */ static findPlayer(name) { - return Misc.findFirstLike(name, game.users, { description: 'joueur' }); + return Misc.findFirstLike(name, Misc.getUsers(), { description: 'joueur' }); } /* -------------------------------------------- */ From 31eab4a04f4265bae910d9baea13c4644c749755 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 7 Jan 2022 23:12:30 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Fix=20erreur=20sur=20entit=C3=A9=20de=20cau?= =?UTF-8?q?chemar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lié à l'encombrement max, une entité n'en a pas --- module/actor.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/module/actor.js b/module/actor.js index 796d0c1c..3b763ae6 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1288,6 +1288,10 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ computeMalusSurEncombrement() { + switch (this.type) { + case 'entite': case 'vehicule': + return 0; + } return Math.min(0, this.getEncombrementMax() - Math.ceil(Number(this.getEncTotal()))); } getMessageSurEncombrement(){ @@ -1295,9 +1299,14 @@ export class RdDActor extends Actor { } getEncombrementMax() { - return (this.data.type == 'vehicule') - ? Misc.templateData(this).capacite_encombrement - : Misc.templateData(this).attributs.encombrement.value; + switch (this.type){ + case 'vehicule': + return Misc.templateData(this).capacite_encombrement; + case 'entite': + return 0; + default: + return Misc.templateData(this).attributs.encombrement.value; + } } /* -------------------------------------------- */ From 264900a4bfdb12ee4aab8b3aa2ccaa4b2e6b0831 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 9 Jan 2022 14:17:48 +0100 Subject: [PATCH 3/4] Formatting --- styles/simple.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/styles/simple.css b/styles/simple.css index 27473615..f04559f8 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -434,17 +434,17 @@ table {border: 1px solid #7a7971;} border-bottom: 1px solid #BBB; } -.blessure-inactive{ +.blessure-inactive { color:rgba(150, 150, 150, 0.4) } -.blessure-active-legere{ +.blessure-active-legere { color:rgba(60, 60, 60, 0.9); text-shadow: rgba(60, 60, 60, 0.7); } -.blessure-active-grave{ +.blessure-active-grave { color:rgba(218, 126, 21, 0.9); } -.blessure-active-critique{ +.blessure-active-critique { color:rgba(173, 36, 26, 0.9); } From 36398948519b0586c93d2ccafb918c6e8dc0335e Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 9 Jan 2022 14:22:54 +0100 Subject: [PATCH 4/4] Ajout log pour probleme dans optimizeArgent --- module/actor.js | 3 ++- test/README.md | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/README.md diff --git a/module/actor.js b/module/actor.js index 3b763ae6..0e076007 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3602,7 +3602,8 @@ export class RdDActor extends Actor { 10: Math.floor(fortuneTotale / 10) % 10, // bronze 1: fortuneTotale % 10 // étain } - let updates = [] + console.log('RdDActor.optimizeArgent', fortuneTotale, 'nouvelleFortune', nouvelleFortune, 'monnaie_par_valeur',parValeur); + let updates = []; for (const [valeur, nombre] of Object.entries(nouvelleFortune)) { updates.push({ _id: parValeur[valeur].id, 'data.quantite': nombre }); } diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000..e599f842 --- /dev/null +++ b/test/README.md @@ -0,0 +1,8 @@ +# Quelques notes pour les tests + +# Commandes utiles + +Dans la console dans les "devtools" de Chrome, quelques commandes sont utiles: + +* `CONFIG.debug.hooks = true` permet de logger les appels des hooks et les objets passés +* `game.system.rdd.TMRUtility.setForceRencontre('changeur', 3)` pour forcer une rencontre avec un changeur de rêves