diff --git a/lang/en.json b/lang/en.json index acc3fdc..ff4b8b1 100644 --- a/lang/en.json +++ b/lang/en.json @@ -43,6 +43,7 @@ "MNBL.disarm": "Disarm", "MNBL.doubleD20": "Double d20 (1 Shard Point)", "MNBL.dramaticfailure": "Dramatic Failure", + "MNBL.oddresult": "Odd result — the die counts as 0", "MNBL.duration": "Duration", "MNBL.easy": "Easy (5)", "MNBL.eclat": "Shard", diff --git a/lang/fr.json b/lang/fr.json index 4d183c2..c7eeb84 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -161,6 +161,7 @@ "MNBL.failure": "Echec", "MNBL.heroicsuccess": "Succés Héroïque", "MNBL.dramaticfailure": "Echec Dramatique", + "MNBL.oddresult": "Résultat impair — le dé compte pour 0", "MNBL.attackmountbonus": "Attaquant monté vs def. au sol (+5)", "MNBL.targetdefense": "Défense adversaire", diff --git a/modules/applications/sheets/base-item-sheet.mjs b/modules/applications/sheets/base-item-sheet.mjs index b75d5e7..6960ca7 100644 --- a/modules/applications/sheets/base-item-sheet.mjs +++ b/modules/applications/sheets/base-item-sheet.mjs @@ -132,7 +132,7 @@ export default class MournbladeItemSheet extends HandlebarsApplicationMixin(foun payload: chatData, }) - const html = await renderTemplate('systems/fvtt-mournblade/templates/post-item.hbs', chatData) + const html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-mournblade/templates/post-item.hbs', chatData) const chatOptions = { user: game.user.id, content: html, diff --git a/modules/models/competence.mjs b/modules/models/competence.mjs index d209119..b53576a 100644 --- a/modules/models/competence.mjs +++ b/modules/models/competence.mjs @@ -11,7 +11,22 @@ export default class CompetenceDataModel extends foundry.abstract.TypeDataModel attribut2: new fields.StringField({ initial: "" }), attribut3: new fields.StringField({ initial: "" }), doublebonus: new fields.BooleanField({ initial: false }), - predilections: new fields.ArrayField(new fields.StringField(), { initial: [] }) + predilections: new fields.ArrayField( + new fields.SchemaField({ + name: new fields.StringField({ initial: "" }), + used: new fields.BooleanField({ initial: false }) + }), + { initial: [] } + ) }; } + + static migrateData(source) { + if (Array.isArray(source.predilections)) { + source.predilections = source.predilections.map(pred => + typeof pred === "string" ? { name: pred, used: false } : pred + ); + } + return super.migrateData(source); + } } \ No newline at end of file diff --git a/modules/mournblade-actor.js b/modules/mournblade-actor.js index 1a611ee..cd0d6d7 100644 --- a/modules/mournblade-actor.js +++ b/modules/mournblade-actor.js @@ -18,6 +18,12 @@ export class MournbladeActor extends Actor { // Calculate derived attributes const data = this.system; + if (this.type == 'personnage') { + // Compute base health and max soul from attributes (derived, no DB write needed) + data.sante.base = data.sante.bonus + (data.attributs.pui.value + data.attributs.tre.value) * 2 + 5; + data.ame.fullmax = (data.attributs.cla.value + data.attributs.tre.value) * data.biodata.amemultiplier + 5; + } + // Calculate total health data.sante.total = data.sante.base + data.sante.bonus; @@ -32,7 +38,7 @@ export class MournbladeActor extends Actor { } prepareDerivedData() { - this.prepareData(); + super.prepareDerivedData(); } /* -------------------------------------------- */ @@ -299,25 +305,6 @@ export class MournbladeActor extends Actor { return combat } - /* -------------------------------------------- */ - prepareDerivedData() { - - if (this.type == 'personnage') { - let newSante = this.system.sante.bonus + (this.system.attributs.pui.value + this.system.attributs.tre.value) * 2 + 5 - if (this.system.sante.base != newSante && this._id) { - // Only update if the actor already exists (has an _id) - this.update({ 'system.sante.base': newSante }) - } - let newAme = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.amemultiplier + 5 - if (this.system.ame.fullmax != newAme && this._id) { - // Only update if the actor already exists (has an _id) - this.update({ 'system.ame.fullmax': newAme }) - } - } - - super.prepareDerivedData() - } - /* -------------------------------------------- */ _preUpdate(changed, options, user) { @@ -583,8 +570,8 @@ export class MournbladeActor extends Actor { this.update({ 'system.ressources': ressources }) ChatMessage.create({ content: "L'utilisation de la capacité/arme a dépensé " + arme.system.nbressources + " ressources.", - whisper: game.user._id, - user: game.user._id + whisper: game.user.id, + user: game.user.id }); } else { ui.notifications.warn("Points de ressources insuffisants.") @@ -735,7 +722,7 @@ export class MournbladeActor extends Actor { let arme = this.items.get(armeId) if (arme) { MournbladeUtility.createChatWithRollMode("GM", { - content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-display-description.hbs`, arme) + content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-mournblade/templates/chat-display-description.hbs`, arme) }, arme) this.depenseRessources(arme) } @@ -751,7 +738,7 @@ export class MournbladeActor extends Actor { arme = this.prepareBouclier(arme) } //Unused rollData.degatsFormula = arme.system.totalDegats - let roll = await new Roll(arme.system.totalDegats).roll() + let roll = await new Roll(arme.system.totalDegats).evaluate() await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode")); let rollData = { degatsFormula:arme.system.totalDegats, diff --git a/modules/mournblade-combat.js b/modules/mournblade-combat.js index c9b16ea..1947114 100644 --- a/modules/mournblade-combat.js +++ b/modules/mournblade-combat.js @@ -10,7 +10,7 @@ export class MournbladeCombat extends Combat { const c = this.combatants.get(ids[cId]); let id = c._id || c.id; let initBonus = c.actor ? c.actor.getInitiativeScore() : 0 - let roll = new Roll("1d10 + "+initBonus).roll({ async: false}) + let roll = await new Roll("1d10 + "+initBonus).evaluate() await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode")) //console.log("Init bonus", initBonus, roll.total) await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: roll.total } ]); diff --git a/modules/mournblade-commands.js b/modules/mournblade-commands.js index 6abb6cd..8699123 100644 --- a/modules/mournblade-commands.js +++ b/modules/mournblade-commands.js @@ -89,7 +89,7 @@ export class MournbladeCommands { if (command && command.func) { const result = command.func(content, msg, params); if (result == false) { - RdDCommands._chatAnswer(msg, command.descr); + MournbladeCommands._chatAnswer(msg, command.descr); } return true; } @@ -98,8 +98,8 @@ export class MournbladeCommands { /* -------------------------------------------- */ async createChar(msg) { - game.system.Mournblade.creator = new MournbladeActorCreate(); - game.system.Mournblade.creator.start(); + game.system.mournblade.creator = new MournbladeActorCreate(); + game.system.mournblade.creator.start(); } /* -------------------------------------------- */ diff --git a/modules/mournblade-item-sheet.js b/modules/mournblade-item-sheet.js index 4b9d83d..7b0037b 100644 --- a/modules/mournblade-item-sheet.js +++ b/modules/mournblade-item-sheet.js @@ -106,7 +106,7 @@ export class MournbladeItemSheet extends foundry.appv1.sheets.ItemSheet { payload: chatData, }); - renderTemplate('systems/fvtt-mournblade/templates/post-item.hbs', chatData).then(html => { + foundry.applications.handlebars.renderTemplate('systems/fvtt-mournblade/templates/post-item.hbs', chatData).then(html => { let chatOptions = MournbladeUtility.chatDataSetup(html); ChatMessage.create(chatOptions) }); diff --git a/modules/mournblade-main.js b/modules/mournblade-main.js index 002de45..7c0f49e 100644 --- a/modules/mournblade-main.js +++ b/modules/mournblade-main.js @@ -44,7 +44,7 @@ Hooks.once("init", async function () { }; /* -------------------------------------------- */ - game.socket.on("system.fvtt-mournblade-rpg", data => { + game.socket.on("system.fvtt-mournblade", data => { MournbladeUtility.onSocketMesssage(data); }); @@ -119,7 +119,7 @@ Hooks.once("init", async function () { /* -------------------------------------------- */ async function welcomeMessage() { const templateData = {}; - const html = await renderTemplate("systems/fvtt-mournblade/templates/chat-welcome-message.hbs", templateData); + const html = await foundry.applications.handlebars.renderTemplate("systems/fvtt-mournblade/templates/chat-welcome-message.hbs", templateData); ChatMessage.create({ user: game.user.id, @@ -154,14 +154,14 @@ Hooks.once("ready", function () { ui.notifications.info("Attention ! Aucun personnage n'est relié au joueur !"); ChatMessage.create({ content: "ATTENTION Le joueur " + game.user.name + " n'est relié à aucun personnage !", - user: game.user._id + user: game.user.id }); } if (!game.user.isGM && game.user.character && !game.user.character.prototypeToken.actorLink) { ui.notifications.info("Le token de du joueur n'est pas connecté à l'acteur !"); ChatMessage.create({ content: "ATTENTION Le token du joueur " + game.user.name + " n'est pas connecté à l'acteur !", - user: game.user._id + user: game.user.id }); } diff --git a/modules/mournblade-utility.js b/modules/mournblade-utility.js index 32e1071..53e6153 100644 --- a/modules/mournblade-utility.js +++ b/modules/mournblade-utility.js @@ -154,7 +154,7 @@ export class MournbladeUtility { if (game.user.isGM) { MournbladeUtility.applyDegatsFromAttaque(rollData) } else { - game.socket.emit("system.fvtt-mournblade", { name: "msg_apply_damage", data: { rolLData: rollData } }) + game.socket.emit("system.fvtt-mournblade", { name: "msg_apply_damage", data: { rollData: rollData } }) } }) } @@ -294,6 +294,7 @@ export class MournbladeUtility { if (diceValue % 2 == 1) { //console.log("PAIR/IMP2", diceValue) rollData.finalResult -= rollData.roll.terms[0].results[0].result // Substract value + rollData.isImpair = true if (diceValue == 1 || diceValue == 11) { rollData.isDramatique = true rollData.isSuccess = false @@ -312,6 +313,7 @@ export class MournbladeUtility { rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10) rollData.isPureSuccess = (rollData.isSuccess && !rollData.isHeroique) } + rollData.isEchec = !rollData.isSuccess } /* -------------------------------------------- */ @@ -608,7 +610,7 @@ export class MournbladeUtility { chatGM.whisper = this.getUsers(user => user.isGM); chatGM.content = "Blinde message of " + game.user.name + "
" + chatOptions.content; console.log("blindMessageToGM", chatGM); - game.socket.emit("system.fvtt-weapons-of-the-gods", { msg: "msg_gm_chat_message", data: chatGM }); + game.socket.emit("system.fvtt-mournblade", { msg: "msg_gm_chat_message", data: chatGM }); } /* -------------------------------------------- */ @@ -682,7 +684,7 @@ export class MournbladeUtility { let target = MournbladeUtility.getTarget() if (target) { rollData.defenderTokenId = target.id - let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor + let defender = game.canvas.tokens.get(rollData.defenderTokenId)?.actor rollData.defenderCombatValues = defender.getCombatValues() rollData.defender = defender.toObject() // Simpler rollData.defenderDefense = defender.getBestDefenseValue() diff --git a/packs/armes/000306.log b/packs/armes/000314.log similarity index 100% rename from packs/armes/000306.log rename to packs/armes/000314.log diff --git a/packs/armes/MANIFEST-000304 b/packs/armes/MANIFEST-000304 deleted file mode 100644 index c4e9a12..0000000 Binary files a/packs/armes/MANIFEST-000304 and /dev/null differ diff --git a/packs/dons/000305.log b/packs/dons/000313.log similarity index 100% rename from packs/dons/000305.log rename to packs/dons/000313.log diff --git a/packs/dons/MANIFEST-000303 b/packs/dons/MANIFEST-000303 deleted file mode 100644 index fc626ac..0000000 Binary files a/packs/dons/MANIFEST-000303 and /dev/null differ diff --git a/packs/equipement/000305.log b/packs/equipement/000313.log similarity index 100% rename from packs/equipement/000305.log rename to packs/equipement/000313.log diff --git a/packs/equipement/MANIFEST-000303 b/packs/equipement/MANIFEST-000303 deleted file mode 100644 index 76e4b0c..0000000 Binary files a/packs/equipement/MANIFEST-000303 and /dev/null differ diff --git a/packs/heritages/000305.log b/packs/heritages/000313.log similarity index 100% rename from packs/heritages/000305.log rename to packs/heritages/000313.log diff --git a/packs/heritages/MANIFEST-000303 b/packs/heritages/MANIFEST-000303 deleted file mode 100644 index 7893ad1..0000000 Binary files a/packs/heritages/MANIFEST-000303 and /dev/null differ diff --git a/packs/metiers/000305.log b/packs/metiers/000313.log similarity index 100% rename from packs/metiers/000305.log rename to packs/metiers/000313.log diff --git a/packs/metiers/MANIFEST-000303 b/packs/metiers/MANIFEST-000303 deleted file mode 100644 index bf35a63..0000000 Binary files a/packs/metiers/MANIFEST-000303 and /dev/null differ diff --git a/packs/origines/000305.log b/packs/origines/000313.log similarity index 100% rename from packs/origines/000305.log rename to packs/origines/000313.log diff --git a/packs/origines/MANIFEST-000303 b/packs/origines/MANIFEST-000303 deleted file mode 100644 index ede92a0..0000000 Binary files a/packs/origines/MANIFEST-000303 and /dev/null differ diff --git a/packs/pnj-creatures/000201.log b/packs/pnj-creatures/000209.log similarity index 100% rename from packs/pnj-creatures/000201.log rename to packs/pnj-creatures/000209.log diff --git a/packs/pnj-creatures/MANIFEST-000199 b/packs/pnj-creatures/MANIFEST-000199 deleted file mode 100644 index ab08871..0000000 Binary files a/packs/pnj-creatures/MANIFEST-000199 and /dev/null differ diff --git a/packs/protection/000305.log b/packs/protection/000313.log similarity index 100% rename from packs/protection/000305.log rename to packs/protection/000313.log diff --git a/packs/protection/MANIFEST-000303 b/packs/protection/MANIFEST-000303 deleted file mode 100644 index 0a91f2e..0000000 Binary files a/packs/protection/MANIFEST-000303 and /dev/null differ diff --git a/packs/runes/000305.log b/packs/runes/000313.log similarity index 100% rename from packs/runes/000305.log rename to packs/runes/000313.log diff --git a/packs/runes/MANIFEST-000303 b/packs/runes/MANIFEST-000303 deleted file mode 100644 index 6c4196d..0000000 Binary files a/packs/runes/MANIFEST-000303 and /dev/null differ diff --git a/packs/scenes/000221.log b/packs/scenes/000229.log similarity index 100% rename from packs/scenes/000221.log rename to packs/scenes/000229.log diff --git a/packs/scenes/MANIFEST-000219 b/packs/scenes/MANIFEST-000219 deleted file mode 100644 index 5328073..0000000 Binary files a/packs/scenes/MANIFEST-000219 and /dev/null differ diff --git a/packs/skills-creatures/000213.log b/packs/skills-creatures/000221.log similarity index 100% rename from packs/skills-creatures/000213.log rename to packs/skills-creatures/000221.log diff --git a/packs/skills-creatures/MANIFEST-000211 b/packs/skills-creatures/MANIFEST-000211 deleted file mode 100644 index 6fe0505..0000000 Binary files a/packs/skills-creatures/MANIFEST-000211 and /dev/null differ diff --git a/packs/skills/000305.log b/packs/skills/000313.log similarity index 100% rename from packs/skills/000305.log rename to packs/skills/000313.log diff --git a/packs/skills/MANIFEST-000303 b/packs/skills/MANIFEST-000303 deleted file mode 100644 index 1c5e3d1..0000000 Binary files a/packs/skills/MANIFEST-000303 and /dev/null differ diff --git a/packs/tables/000305.log b/packs/tables/000313.log similarity index 100% rename from packs/tables/000305.log rename to packs/tables/000313.log diff --git a/packs/tables/MANIFEST-000303 b/packs/tables/MANIFEST-000303 deleted file mode 100644 index aebd44c..0000000 Binary files a/packs/tables/MANIFEST-000303 and /dev/null differ diff --git a/packs/tendances/000305.log b/packs/tendances/000313.log similarity index 100% rename from packs/tendances/000305.log rename to packs/tendances/000313.log diff --git a/packs/tendances/MANIFEST-000303 b/packs/tendances/MANIFEST-000303 deleted file mode 100644 index e0e59d4..0000000 Binary files a/packs/tendances/MANIFEST-000303 and /dev/null differ diff --git a/packs/traits-chaotiques/000305.log b/packs/traits-chaotiques/000313.log similarity index 100% rename from packs/traits-chaotiques/000305.log rename to packs/traits-chaotiques/000313.log diff --git a/packs/traits-chaotiques/MANIFEST-000303 b/packs/traits-chaotiques/MANIFEST-000303 deleted file mode 100644 index 7c32c5e..0000000 Binary files a/packs/traits-chaotiques/MANIFEST-000303 and /dev/null differ diff --git a/templates/actor-sheet.hbs b/templates/actor-sheet.hbs index a0ac6d1..92985d4 100644 --- a/templates/actor-sheet.hbs +++ b/templates/actor-sheet.hbs @@ -698,7 +698,7 @@
  • - +
  • diff --git a/templates/chat-generic-result-v2.hbs b/templates/chat-generic-result-v2.hbs index 575ff26..c164b16 100644 --- a/templates/chat-generic-result-v2.hbs +++ b/templates/chat-generic-result-v2.hbs @@ -64,6 +64,13 @@ {{/if}} + {{!-- Résultat impair --}} + {{#if isImpair}} +
    + {{localize "MNBL.oddresult"}} +
    + {{/if}} + {{!-- Détails du jet --}}