Merge branch 'v1.4' into 'dev_0.8'

# Conflicts:
#   module/actor-sheet.js
#   system.json
#   templates/actor-sheet.html
This commit is contained in:
2021-03-02 22:44:57 +00:00
36 changed files with 933 additions and 590 deletions

View File

@@ -34,77 +34,7 @@ import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
const _patch_initiative = () => {
Combat.prototype.rollInitiative = async function (
ids,
formula = undefined,
messageOptions = {}
) {
console.log(
`${game.data.system.data.title} | Combat.rollInitiative()`,
ids,
formula,
messageOptions
);
// Structure input data
ids = typeof ids === "string" ? [ids] : ids;
const currentId = this.combatant._id;
// calculate initiative
for (let cId = 0; cId < ids.length; cId++) {
const c = this.getCombatant(ids[cId]);
//if (!c) return results;
let rollFormula = formula; // Init per default
if (!rollFormula) {
let armeCombat, competence;
if (c.actor.data.type == 'creature' || c.actor.data.type == 'entite') {
for (const competenceItem of c.actor.data.items) {
if (competenceItem.data.iscombat) {
competence = duplicate(competenceItem);
}
}
rollFormula = "2+( ("+RdDUtility.calculInitiative(competence.data.niveau, competence.data.carac_value)+")/100)";
} else {
for (const item of c.actor.data.items) {
if (item.type == "arme" && item.data.equipe) {
armeCombat = duplicate(item);
}
}
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
competence = RdDItemCompetence.findCompetence(c.actor.data.items, compName);
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
rollFormula = "2+( ("+RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value, bonusEcaille) + ")/100)";
}
}
//console.log("Combatat", c);
const roll = this._getInitiativeRoll(c, rollFormula);
if (roll.total <= 0) roll.total = 0.00;
console.log("Compute init for", rollFormula, roll.total);
await this.updateEmbeddedEntity("Combatant", { _id: c._id, initiative: roll.total });
// Send a chat message
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
let messageData = mergeObject(
{
speaker: {
scene: canvas.scene._id,
actor: c.actor ? c.actor._id : null,
token: c.token._id,
alias: c.token.name,
sound: CONFIG.sounds.dice,
},
flavor: `${c.token.name} a fait son jet d'Initiative (${messageOptions.initInfo})`,
},
messageOptions
);
roll.toMessage(messageData, { rollMode, create: true });
RdDUtility.processPremierRoundInit( );
}
return this;
};
}
/************************************************************************************/
Hooks.once("init", async function () {
@@ -224,15 +154,10 @@ Hooks.once("init", async function () {
//CONFIG.Combat.entityClass = RdDCombatManager;
CONFIG.Combat.documentClass = RdDCombatManager;
// Handlebar function pour container
Handlebars.registerHelper('buildConteneur', (objet) => { return RdDUtility.buildConteneur(objet); });
// Patch the initiative formula
_patch_initiative();
// préparation des différents modules
RdDCommands.init();
RdDCombat.init();
RdDCombatManager.init(),
RdDTokenHud.init();
RdDActor.init();
RddCompendiumOrganiser.init();
@@ -301,10 +226,6 @@ Hooks.on("chatMessage", (html, content, msg) => {
return true;
});
/* -------------------------------------------- */
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
RdDUtility.pushInitiativeOptions(html, options);
});
/* -------------------------------------------- */
Hooks.on("renderChatMessage", async (app, html, msg) => {