From 16ce6a58ddc848eb59ceb3854b23184d193bf57f Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 22 Jul 2022 00:31:27 +0200 Subject: [PATCH 1/7] Fix accorder entite de cauchemar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A priori vieille régression, pas vue depuis. attaquant._id est devenu attaquant.id --- module/actor.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/module/actor.js b/module/actor.js index 5fb2a4e2..0a31555f 100644 --- a/module/actor.js +++ b/module/actor.js @@ -98,7 +98,6 @@ export class RdDActor extends Actor { * @param {Object} options (Unused) Additional options which customize the creation workflow. * */ - static async create(actorData, options) { // Case of compendium global import if (actorData instanceof Array) { @@ -135,13 +134,6 @@ export class RdDActor extends Actor { this.encTotal = 0; this.prixTotalEquipement = 0; - /* - // Auto-resize token - if (this.isToken) { - let tokenSize = actorData.data.carac.taille.value/10; - this.token.update({height: tokenSize, width: tokenSize } ); - }*/ - // Make separate methods for each Actor type (character, npc, etc.) to keep // things organized. if (actorData.type === 'personnage') this._prepareCharacterData(actorData); @@ -3593,7 +3585,7 @@ export class RdDActor extends Actor { isEntiteCauchemarAccordee(attaquant) { if (!this.isEntiteCauchemar()) { return true; } let resonnance = Misc.templateData(this).sante.resonnance; - return (resonnance.actors.find(it => it == attaquant._id)); + return (resonnance.actors.find(it => it == attaquant.id)); } /* -------------------------------------------- */ @@ -3603,11 +3595,11 @@ export class RdDActor extends Actor { return; } let resonnance = duplicate(Misc.templateData(this).sante.resonnance); - if (resonnance.actors.find(it => it == attaquant._id)) { + if (resonnance.actors.find(it => it == attaquant.id)) { // déjà accordé return; } - resonnance.actors.push(attaquant._id); + resonnance.actors.push(attaquant.id); await this.update({ "data.sante.resonnance": resonnance }); return; } From 34cc671f127b2266aaeb3d6c375b7efdf164ba22 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 22 Jul 2022 00:36:16 +0200 Subject: [PATCH 2/7] Fix init Autre action --- module/rdd-combat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index c057fbaa..455e76ff 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -320,7 +320,7 @@ export class RdDCombatManager extends Combat { initOffset = 10; caracForInit = combatant.actor.getReveActuel(); initInfo = "Possession" - } else if (action.name == 'autre') { + } else if (action.action == 'autre') { initOffset = 2; initInfo = "Autre Action" } else if (action.action == 'haut-reve') { From d51243d74f542eacf7749894f47cc51618c19cc7 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 22 Jul 2022 01:01:46 +0200 Subject: [PATCH 3/7] Fix Bouton "prendre" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le bouton devenait "Acheter" car le prix après la première prise était récupéré sous forme de string (et le template fait une comparaison de nombre) --- module/dialog-item-achat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/dialog-item-achat.js b/module/dialog-item-achat.js index b6b3f6ba..ddf4d78f 100644 --- a/module/dialog-item-achat.js +++ b/module/dialog-item-achat.js @@ -55,7 +55,7 @@ export class DialogItemAchat extends Dialog { static prepareVenteData(buttonAcheter, vendeurId, vendeur, acheteur) { const jsondata = buttonAcheter.attributes['data-jsondata']?.value; - const prixLot = buttonAcheter.attributes['data-prixLot']?.value ?? 0; + const prixLot = parseInt(buttonAcheter.attributes['data-prixLot']?.value ?? 0); let venteData = { item: JSON.parse(jsondata), vendeurId: vendeurId, From 46f5cb67f6b1ece954413c7ee476acd1e70bbb7f Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 22 Jul 2022 01:31:21 +0200 Subject: [PATCH 4/7] =?UTF-8?q?Cr=C3=A9er=20un=20acteur=20depuis=20/nom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-namegen.js | 28 +++++++++++++++++++--------- module/rdd-utility.js | 2 ++ templates/chat-command-nom.html | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 templates/chat-command-nom.html diff --git a/module/rdd-namegen.js b/module/rdd-namegen.js index 52713906..f054f435 100644 --- a/module/rdd-namegen.js +++ b/module/rdd-namegen.js @@ -1,19 +1,29 @@ +import { RdDActor } from "./actor.js"; import { Misc } from "./misc.js"; import { RdDDice } from "./rdd-dice.js"; -const words = [ 'pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i', 'onse', 'iane', 'ane', 'zach', 'arri', 'ba', 'bo', 'bi', - 'alta', 'par', 'pir', 'zor', 'zir', 'de', 'pol', 'tran', 'no', 'la', 'al' , 'pul', 'one', 'ner', 'nur', 'mac', 'mery', - 'cat', 'do', 'di', 'der', 'er', 'el', 'far', 'fer', 'go', 'guer', 'hot', 'jor', 'jar', 'ji', 'kri', 'ket', 'lor', 'hur', - 'lar', 'lir', 'lu', 'pot', 'pro', 'pra', 'pit', 'qua', 'qui', 're', 'ral', 'sal', 'sen', 'ted', 'to', 'ta', 'lars', 'ver', - 'vin', 'ov', 'wal', 'ry', 'ly', '' ]; +const words = ['pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i', 'onse', 'iane', 'ane', 'zach', 'arri', 'ba', 'bo', 'bi', + 'alta', 'par', 'pir', 'zor', 'zir', 'de', 'pol', 'tran', 'no', 'la', 'al', 'pul', 'one', 'ner', 'nur', 'mac', 'mery', + 'cat', 'do', 'di', 'der', 'er', 'el', 'far', 'fer', 'go', 'guer', 'hot', 'jor', 'jar', 'ji', 'kri', 'ket', 'lor', 'hur', + 'lar', 'lir', 'lu', 'pot', 'pro', 'pra', 'pit', 'qua', 'qui', 're', 'ral', 'sal', 'sen', 'ted', 'to', 'ta', 'lars', 'ver', + 'vin', 'ov', 'wal', 'ry', 'ly', '']; /* -------------------------------------------- */ export class RdDNameGen { - static async getName( msg, params ) { - let name = Misc.upperFirst( await RdDDice.rollOneOf(words) + await RdDDice.rollOneOf(words) ) - //console.log(name); - ChatMessage.create( { content: `Nom : ${name}`, whisper: ChatMessage.getWhisperRecipients("GM") } ); + static async getName(msg, params) { + const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-command-nom.html`, { + nom: Misc.upperFirst(await RdDDice.rollOneOf(words) + await RdDDice.rollOneOf(words)) + }); + ChatMessage.create({ content: html, whisper: ChatMessage.getWhisperRecipients("GM") }); } + static async onCreerActeur(event) { + const button = event.currentTarget; + await RdDActor.create({ + name: button.attributes['data-nom'].value, + type: button.attributes['data-type'].value + }, + {renderSheet: true}); + } } \ No newline at end of file diff --git a/module/rdd-utility.js b/module/rdd-utility.js index d6f26d13..afc4b2e3 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -11,6 +11,7 @@ import { RdDDice } from "./rdd-dice.js"; import { RdDItem } from "./item.js"; import { Monnaie } from "./item-monnaie.js"; import { RdDPossession } from "./rdd-possession.js"; +import { RdDNameGen } from "./rdd-namegen.js"; /* -------------------------------------------- */ // This table starts at 0 -> niveau -10 @@ -704,6 +705,7 @@ export class RdDUtility { // gestion bouton tchat Acheter html.on("click", '.button-acheter', event => DialogItemAchat.onButtonAcheter(event)); + html.on("click", '.button-creer-acteur', event => RdDNameGen.onCreerActeur(event)); // Gestion du bouton payer html.on("click", '.payer-button', event => { diff --git a/templates/chat-command-nom.html b/templates/chat-command-nom.html new file mode 100644 index 00000000..8467fe6e --- /dev/null +++ b/templates/chat-command-nom.html @@ -0,0 +1,16 @@ + +

Proposition de nom: {{nom}}

+ + + Créer un Personnage + + + + Créer une créature + + From 3958b1bdc23404e1775bdbac186f59eff415613c Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 22 Jul 2022 10:46:39 +0200 Subject: [PATCH 5/7] Add Vincent VK fixes --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index ec112e68..aa0e8ccc 100644 --- a/system.json +++ b/system.json @@ -29,7 +29,7 @@ "url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/", "license": "LICENSE.txt", "flags": {}, - "version": "1.5.82", + "version": "1.5.83", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "9", "scripts": [], @@ -500,7 +500,7 @@ "dependencies": [], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v1.5/system.json", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.82.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.83.zip", "protected": false, "gridDistance": 1, "gridUnits": "m", From 9e63706de6693689c991dd3ea66b360628cfe90a Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 22 Jul 2022 21:38:15 +0200 Subject: [PATCH 6/7] Support des blurettes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On peut définir Blurette comme type d'entité. Pas de jet poour s'accorder aux blurettes. --- module/actor.js | 39 +++++++++++++++++-------------- module/constants.js | 4 ++++ module/rdd-combat.js | 10 ++++---- module/rdd-roll-encaisser.js | 24 ++++++++++++------- templates/actor-entite-sheet.html | 1 + 5 files changed, 47 insertions(+), 31 deletions(-) diff --git a/module/actor.js b/module/actor.js index 0a31555f..31724a64 100644 --- a/module/actor.js +++ b/module/actor.js @@ -33,7 +33,8 @@ import { RollDataAjustements } from "./rolldata-ajustements.js"; import { DialogItemAchat } from "./dialog-item-achat.js"; import { RdDItem } from "./item.js"; import { RdDPossession } from "./rdd-possession.js"; -import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; +import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; + /* -------------------------------------------- */ /** @@ -239,7 +240,7 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ getForce() { - if (this.isEntiteCauchemar()) { + if (this.isEntite()) { return Misc.toInt(Misc.templateData(this).carac.reve?.value); } return Misc.toInt(Misc.templateData(this).carac.force?.value); @@ -612,7 +613,10 @@ export class RdDActor extends Actor { content: "Remise à neuf de " + this.name }; const actorData = Misc.data(this); - if (this.isEntiteCauchemar()) { + if (this.isEntite([ENTITE_NONINCARNE])) { + return; + } + if (this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) { await this.santeIncDec("endurance", actorData.data.sante.endurance.max - actorData.data.sante.endurance.value); } else { @@ -1622,7 +1626,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async setSonne(sonne = true) { - if (this.isEntiteCauchemar()) { + if (this.isEntite()) { return; } if (!game.combat && sonne) { @@ -1634,7 +1638,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ getSConst() { - if (this.isEntiteCauchemar()) { + if (this.isEntite()) { return 0; } return RdDCarac.calculSConst(Misc.templateData(this).carac.constitution.value); @@ -1751,7 +1755,7 @@ export class RdDActor extends Actor { result.newValue = Math.max(minValue, Math.min(compteur.value + inc, compteur.max)); //console.log("New value ", inc, minValue, result.newValue); let fatigue = 0; - if (name == "endurance" && !this.isEntiteCauchemar()) { + if (name == "endurance" && !this.isEntite()) { if (result.newValue == 0 && inc < 0 && !isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie sante.vie.value--; result.perteVie = true; @@ -1788,7 +1792,7 @@ export class RdDActor extends Actor { } isDead() { - return !this.isEntiteCauchemar() && Misc.templateData(this).sante.vie.value < -this.getSConst() + return !this.isEntite() && Misc.templateData(this).sante.vie.value < -this.getSConst() } /* -------------------------------------------- */ @@ -3347,7 +3351,7 @@ export class RdDActor extends Actor { let encaissement = await this.jetEncaissement(rollData); this.ajouterBlessure(encaissement); // Will upate the result table - const perteVie = this.isEntiteCauchemar() + const perteVie = this.isEntite() ? { newValue: 0 } : await this.santeIncDec("vie", - encaissement.vie); const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, encaissement.critiques > 0); @@ -3362,7 +3366,7 @@ export class RdDActor extends Actor { sonne: perteEndurance.sonne, jetEndurance: perteEndurance.jetEndurance, endurance: santeOrig.endurance.value - perteEndurance.newValue, - vie: this.isEntiteCauchemar() ? 0 : (santeOrig.vie.value - perteVie.newValue), + vie: this.isEntite() ? 0 : (santeOrig.vie.value - perteVie.newValue), show: defenderRoll?.show ?? {} }); @@ -3552,8 +3556,8 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async accorder(entite, when = 'avant-encaissement') { if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar") - || !entite.isEntiteCauchemar() - || entite.isEntiteCauchemarAccordee(this)) { + || !entite.isEntite([ENTITE_INCARNE]) + || entite.isEntiteAccordee(this)) { return true; } const tplData = Misc.templateData(this); @@ -3577,20 +3581,21 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - isEntiteCauchemar() { - return this.data.type == 'entite'; + isEntite(typeentite = [] ) { + return this.data.type == 'entite' && (typeentite.length == 0 || typeentite.includes(this.data.data.typeentite)); } /* -------------------------------------------- */ - isEntiteCauchemarAccordee(attaquant) { - if (!this.isEntiteCauchemar()) { return true; } + isEntiteAccordee(attaquant) { + if (!this.isEntite([ENTITE_INCARNE])) + { return true; } let resonnance = Misc.templateData(this).sante.resonnance; return (resonnance.actors.find(it => it == attaquant.id)); } /* -------------------------------------------- */ async setEntiteReveAccordee(attaquant) { - if (!this.isEntiteCauchemar()) { + if (!this.isEntite([ENTITE_INCARNE])) { ui.notifications.error("Impossible de s'accorder à " + this.name + ": ce n'est pas une entite de cauchemer/rêve"); return; } @@ -4153,7 +4158,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async setStatusEffect(label, status, updates = {}) { - if (this.isEntiteCauchemar() || this.data.type == 'vehicule') { + if (this.isEntite() || this.data.type == 'vehicule') { return; } console.log("setStatusEffect", label, status, updates) diff --git a/module/constants.js b/module/constants.js index 865a0559..675749ed 100644 --- a/module/constants.js +++ b/module/constants.js @@ -3,3 +3,7 @@ export const SYSTEM_SOCKET_ID = 'system.foundryvtt-reve-de-dragon'; export const HIDE_DICE = 'hide'; export const SHOW_DICE = 'show'; + +export const ENTITE_INCARNE = 'incarne'; +export const ENTITE_NONINCARNE = 'nonincarne'; +export const ENTITE_BLURETTE = 'blurette'; diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 455e76ff..0cc4a587 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -1,5 +1,5 @@ import { ChatUtility } from "./chat-utility.js"; -import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; +import { ENTITE_INCARNE, ENTITE_NONINCARNE, HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { Grammar } from "./grammar.js"; import { RdDItemArme } from "./item-arme.js"; import { RdDItemCompetence } from "./item-competence.js"; @@ -457,7 +457,7 @@ export class RdDCombat { else { const defender = target?.actor; const defenderTokenId = target?.data._id; - if ( defender.type == 'entite' && defender.data.data.definition.typeentite == 'nonincarne') { + if ( defender.type == 'entite' && defender.data.data.definition.typeentite == ENTITE_NONINCARNE) { ui.notifications.warn("Vous ne pouvez pas cibler une entité non incarnée !!!!"); } else { return this.create(attacker, defender, defenderTokenId, target) @@ -799,7 +799,7 @@ export class RdDCombat { async _onAttaqueNormale(attackerRoll) { console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); - attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); + attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntite()); let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} } attackerRoll.show = { cible: this.target ? this.defender.data.name : 'la cible', @@ -1249,8 +1249,8 @@ export class RdDCombat { async accorderEntite(when = 'avant-encaissement') { if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar") || this.defender == undefined - || !this.defender.isEntiteCauchemar() - || this.defender.isEntiteCauchemarAccordee(this.attacker)) { + || !this.defender.isEntite([ENTITE_INCARNE]) + || this.defender.isEntiteAccordee(this.attacker)) { return true; } diff --git a/module/rdd-roll-encaisser.js b/module/rdd-roll-encaisser.js index 55f2b8f5..8c8d8971 100644 --- a/module/rdd-roll-encaisser.js +++ b/module/rdd-roll-encaisser.js @@ -1,3 +1,5 @@ +import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE } from "./constants"; + /** * Extend the base Dialog entity by defining a custom window to perform roll. * @extends {Dialog} @@ -7,15 +9,19 @@ export class RdDEncaisser extends Dialog { /* -------------------------------------------- */ constructor(html, actor) { // Common conf - const buttonsCreatures = { - "mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") }, - "non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") }, - "sonne": { label: "Sonné", callback: html => this.actor.setSonne() }, - }; - const buttonsEntitesCauchemar = { - "cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") } - }; - const buttons = actor.isEntiteCauchemar() ? buttonsEntitesCauchemar : buttonsCreatures; + let buttons = {}; + if (!actor.isEntite()){ + buttons = { + "mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") }, + "non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") }, + "sonne": { label: "Sonné", callback: html => this.actor.setSonne() }, + }; + } + else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])){ + buttons = { + "cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") } + } + } let dialogConf = { title: "Jet d'Encaissement", diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html index 7bafd512..455d795e 100644 --- a/templates/actor-entite-sheet.html +++ b/templates/actor-entite-sheet.html @@ -65,6 +65,7 @@ {{#select data.definition.typeentite}} + {{/select}} From 9c71827baa55e08ffd4c400064e7a5027e418eb8 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 22 Jul 2022 22:45:41 +0200 Subject: [PATCH 7/7] Add Blurette --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index aa0e8ccc..baf600ae 100644 --- a/system.json +++ b/system.json @@ -29,7 +29,7 @@ "url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/", "license": "LICENSE.txt", "flags": {}, - "version": "1.5.83", + "version": "1.5.84", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "9", "scripts": [], @@ -500,7 +500,7 @@ "dependencies": [], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v1.5/system.json", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.83.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.84.zip", "protected": false, "gridDistance": 1, "gridUnits": "m",