ENH: Individual Init

master
U~man 2020-07-10 20:30:52 +02:00
parent 8760b08dcc
commit e3f9afe297
2 changed files with 19 additions and 4 deletions

View File

@ -1,5 +1,3 @@
import { OseDice } from "./dice.js";
export class OseCombat {
static rollInitiative(combat, data) {
// Check groups
@ -27,6 +25,14 @@ export class OseCombat {
}
}
static individualInitiative(combat, data) {
let ids = [];
combat.data.combatants.forEach(cbt => {
ids.push(cbt._id);
})
combat.rollInitiative(ids);
}
static format(object, html, user) {
html.find('.combat-control[data-control="rollNPC"]').remove();
html.find('.combat-control[data-control="rollAll"]').remove();

View File

@ -77,6 +77,7 @@ Hooks.once("ready", async () => {
);
});
// License and KOFI infos
Hooks.on("renderSidebarTab", async (object, html) => {
if (object instanceof Settings) {
const template = "systems/ose/templates/chat/license.html";
@ -106,6 +107,10 @@ Hooks.on("preUpdateCombatant", (combat, combatant, data, diff, id) => {
data.initiative = parseInt(groupInit);
}
});
} else if (data.initiative && init) {
if (combatant.actor.data.data.isSlow) {
data.initiative = -1;
}
}
});
@ -118,10 +123,14 @@ Hooks.on("renderCombatTracker", (object, html, data) => {
Hooks.on("preUpdateCombat", async (combat, data, diff, id) => {
let init = game.settings.get("ose", "individualInit");
if (!data.round || init) {
if (!data.round) {
return;
}
OseCombat.rollInitiative(combat, data, diff, id);
if (!init) {
OseCombat.rollInitiative(combat, data, diff, id);
} else {
OseCombat.individualInitiative(combat, data, diff, id);
}
});
Hooks.on("renderChatLog", (app, html, data) => OseItem.chatListeners(html));