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; } 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, 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') { 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 @@ + +