From e985472a31e47da868d48389409f556f8ba3413b Mon Sep 17 00:00:00 2001 From: U~man Date: Fri, 10 Jul 2020 13:25:08 +0200 Subject: [PATCH] ENH: Reroll initiative --- src/module/combat.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/module/combat.js b/src/module/combat.js index e866200..96966be 100644 --- a/src/module/combat.js +++ b/src/module/combat.js @@ -1,7 +1,7 @@ import { OseDice } from "./dice.js"; export class OseCombat { - static rollInitiative(combat, data, diff, id) { + static rollInitiative(combat, data) { // Check groups data.combatants = []; let groups = {}; @@ -19,7 +19,6 @@ export class OseCombat { // Set init for (let i = 0; i < data.combatants.length; ++i) { - console.log(data.combatants[i]); if (data.combatants[i].actor.data.data.isSlow) { data.combatants[i].initiative = -1; } else { @@ -31,6 +30,9 @@ export class OseCombat { static format(object, html, user) { html.find('.combat-control[data-control="rollNPC"]').remove(); html.find('.combat-control[data-control="rollAll"]').remove(); + let trash = html.find('.encounters .combat-control[data-control="endCombat"]'); + $('').insertBefore(trash); + html.find(".combatant").each((_, ct) => { // Can't roll individual inits $(ct).find(".roll").remove(); @@ -65,6 +67,12 @@ export class OseCombat { flags: { ose: { group: colors[index] } }, }); }); + + html.find('.combat-control[data-control="reroll"]').click(ev => { + let data = {}; + OseCombat.rollInitiative(game.combat, data); + game.combat.update({data: data}); + }); } static addCombatant(combat, data, options, id) {