diff --git a/lang/fr.json b/lang/fr.json index 7e63c3f..3e6d769 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -477,6 +477,7 @@ "BOL.chat.rollbougette": "Jet de Bougette", "BOL.chat.bougettesuccess": "Votre bougette reste inchangée !", "BOL.chat.bougettefailure": "Vous avez trop dépensé, votre bougette s'est réduite...", + "BOL.chat.initiative": "Rang d'intiative (10 à 1)", "BOL.dialog.soeasy": "Inmanquable (+4)", "BOL.dialog.veryeasy": "Trés Facile (+2)", diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 22d1ac8..4b68257 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -141,6 +141,7 @@ export class BoLActorSheet extends ActorSheet { formData.ammos = this.actor.ammos formData.misc = this.actor.misc formData.combat = this.actor.buildCombat() + formData.initiativeRank = this.actor.getInitiativeRank() //formData.combatCreature = this.actor.buildCombatCreature() formData.features = this.actor.buildFeatures() formData.isGM = game.user.isGM diff --git a/module/actor/actor.js b/module/actor/actor.js index 145c299..cffba07 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -648,15 +648,37 @@ export class BoLActor extends Actor { } /*-------------------------------------------- */ - registerInit(initScore, isCritical, isFumble) { - this.update({ 'system.combat.lastinit': initScore, 'system.combat.iscritical': isCritical, 'system.combat.isfumble': isFumble }) + registerInit(rollData) { + rollData.actor = undefined // Cleanup if present + this.setFlag("world", "last-initiative", rollData) } /*-------------------------------------------- */ - getLastInitData() { - return this.system.combat + getInitiativeRank() { + let rollData = this.getFlag("world", "last-initiative") + let fvttInit = 5 + if (this.type == 'character') { + if (rollData.isLegendary) { + fvttInit = 10 + } else if (rollData.isCritical) { + fvttInit = 9 + } else if (rollData.isSuccess ) { + fvttInit = 8 + } else if (rollData.isFumble) { + fvttInit = 3 + } + } else { + fvttInit = 4 // Pietaille par defautco + if ( this.getCharType() == 'adversary') { + fvttInit = 7 + } + if ( this.getCharType() == 'tough') { + fvttInit = 6 + } + } + return fvttInit } - + /*-------------------------------------------- */ async subHeroPoints(nb) { let newHeroP = this.system.resources.hero.value - nb; diff --git a/module/bol.js b/module/bol.js index 87f6ae7..695c79b 100644 --- a/module/bol.js +++ b/module/bol.js @@ -41,7 +41,7 @@ Hooks.once('init', async function () { */ CONFIG.Combat.initiative = { formula: "2d6+@attributes.mind.value+@aptitudes.init.value", - decimals: 3 + decimals: 2 }; // Define custom Entity classes diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index e9eed20..9e4e00e 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -570,7 +570,8 @@ export class BoLDefaultRoll { } if (this.rollData.registerInit) { - actor.registerInit(r.total, this.rollData.isCritical, this.rollData.isFumble) + actor.registerInit(this.rollData) + this.rollData.initiativeRank = actor.getInitiativeRank() } if (this.rollData.isSuccess && this.rollData.mode == "spell") { // PP cost management this.rollData.remainingPP = actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor) diff --git a/module/system/bol-combat.js b/module/system/bol-combat.js index 0055e87..a676fe4 100644 --- a/module/system/bol-combat.js +++ b/module/system/bol-combat.js @@ -10,6 +10,8 @@ Init order = 3 - Echec critique */ +import { BoLUtility } from "../system/bol-utility.js"; + export class BoLCombatManager extends Combat { @@ -18,35 +20,12 @@ export class BoLCombatManager extends Combat { console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions); // Structure input data ids = typeof ids === "string" ? [ids] : ids; - const currentId = this.combatant._id; + const currentId = this.combatant.id; // calculate initiative for (let cId = 0; cId < ids.length; cId++) { - const combatant = this.combatants.get(ids[cId]); - let fvttInit = 5 - //console.log("TYPE", combatant.actor.type) - if (combatant.actor.type == 'character') { - let initData = combatant.actor.getLastInitData() - console.log("Init data !!!", initData) - if (initData.isLegendary) { - fvttInit = 10 - } else if (initData.isCritical) { - fvttInit = 9 - } else if (initData.lastinit >= 9) { - fvttInit = 8 - } else if (initData.isFumble) { - fvttInit = 3 - } - } else { - fvttInit = 4 // Pietaille par defautco - //console.log("ACTOR", combatant.actor.getCharType()) - if ( combatant.actor.getCharType() == 'adversary') { - fvttInit = 7 - } - if ( combatant.actor.getCharType() == 'tough') { - fvttInit = 6 - } - } + const combatant = this.combatants.get(ids[cId]) + let fvttInit = combatant.actor.getInitiativeRank() fvttInit += (cId / 100) await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]); } diff --git a/module/system/bol-utility.js b/module/system/bol-utility.js index f4a073a..7999e81 100644 --- a/module/system/bol-utility.js +++ b/module/system/bol-utility.js @@ -178,7 +178,7 @@ export class BoLUtility { static getOtherWhisperRecipients(name) { let users = [] for (let user of game.users) { - if (!user.isGM && user.name != name) { + if ( !user.isGM && user.name != name) { users.push(user.id) } } diff --git a/system.json b/system.json index b7b68bc..a603b58 100644 --- a/system.json +++ b/system.json @@ -14,7 +14,7 @@ ], "url": "https://www.uberwald.me/gitea/public/bol", "license": "LICENSE.txt", - "version": "10.4.6", + "version": "10.4.7", "compatibility": { "minimum": "10", "verified": "10", @@ -203,7 +203,7 @@ ], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json", - "download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.4.6.zip", + "download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.4.7.zip", "background": "systems/images/map_lemurie.webp", "gridDistance": 1.5, "gridUnits": "m", diff --git a/templates/chat/rolls/default-roll-card.hbs b/templates/chat/rolls/default-roll-card.hbs index 7ed7fb3..4116411 100644 --- a/templates/chat/rolls/default-roll-card.hbs +++ b/templates/chat/rolls/default-roll-card.hbs @@ -34,6 +34,12 @@ {{/if}} + {{#if initiativeRank}} +
+ {{localize "BOL.chat.initiative"}}: {{initiativeRank}} +
+ {{/if}} + {{#if (eq mode "bougette")}}
{{localize "BOL.chat.rollbougette"}} :