Fix initiative

This commit is contained in:
sladecraven 2022-01-21 15:43:22 +01:00
parent d776c219a8
commit 0b86c3b159
2 changed files with 10 additions and 8 deletions

View File

@ -10,22 +10,24 @@ export class VadentisCombat extends Combat {
ids = typeof ids === "string" ? [ids] : ids; ids = typeof ids === "string" ? [ids] : ids;
const currentId = this.combatant._id; const currentId = this.combatant._id;
for (let cId = 0; cId < ids.length; cId++) { for (let cId = 0; cId < ids.length; cId++) {
const c = this.getCombatant(ids[cId]); const c = this.combatants.get(ids[cId]);
let initBonus = c.actor ? c.actor.getInitiativeScore() : 0; let initBonus = c.actor ? c.actor.getInitiativeScore() : 0;
console.log("Init for ", initBonus); console.log("Init for ", initBonus);
const roll = super._getInitiativeRoll(c, "1d20+"+initBonus); const roll = c.getInitiativeRoll("1d20+"+initBonus);
if ( !roll.total) {
roll.evaluate( {async: false});
}
if (roll.total <= 0) roll.total = 0; if (roll.total <= 0) roll.total = 0;
console.log("Compute init for", roll.total); let id = c._id || c.id;
await this.updateEmbeddedEntity("Combatant", { _id: c._id, initiative: roll.total }); await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: roll.total } ]);
// Send a chat message // Send a chat message
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode"); let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
let messageData = mergeObject( let messageData = mergeObject(
{ {
speaker: { speaker: {
scene: canvas.scene._id, scene: canvas.scene.id,
actor: c.actor ? c.actor._id : null, actor: id,
token: c.token._id, token: c.token._id,
alias: c.token.name, alias: c.token.name,
sound: CONFIG.sounds.dice, sound: CONFIG.sounds.dice,

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-vadentis", "name": "foundryvtt-vadentis",
"title": "Vadentis", "title": "Vadentis",
"description": "Système Vadentis pour FoundryVTT", "description": "Système Vadentis pour FoundryVTT",
"version": "0.3.1", "version": "0.3.2",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.8.9", "minimumCoreVersion": "0.8.9",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",