Stylistic changes

master
John Downey 2022-04-09 17:32:15 -05:00
parent 60e61da5c4
commit 337f578a51
1 changed files with 53 additions and 25 deletions

View File

@ -201,50 +201,68 @@ export class AcksCombat {
} }
static announceListener(html) { static announceListener(html) {
html.find(".combatant-control.hold-turn").click(async (ev) => { html.find(".combatant-control.hold-turn").click(async (event) => {
ev.preventDefault(); event.preventDefault();
// Toggle hold announcement // Toggle hold announcement
const id = $(ev.currentTarget).closest(".combatant")[0].dataset.combatantId; const id = $(event.currentTarget).closest(".combatant")[0].dataset.combatantId;
const isActive = ev.currentTarget.classList.contains('active'); const isActive = event.currentTarget.classList.contains('active');
const combatant = game.combat.combatants.get(id); const combatant = game.combat.combatants.get(id);
await combatant.update({ await combatant.update({
_id: id, _id: id,
flags: { acks: { holdTurn: !isActive } }, flags: {
acks: {
holdTurn: !isActive,
},
},
}); });
}) })
html.find(".combatant-control.prepare-spell").click(async (ev) => { html.find(".combatant-control.prepare-spell").click(async (event) => {
ev.preventDefault(); event.preventDefault();
// Toggle spell announcement // Toggle spell announcement
const id = $(ev.currentTarget).closest(".combatant")[0].dataset.combatantId; const id = $(event.currentTarget).closest(".combatant")[0].dataset.combatantId;
const isActive = ev.currentTarget.classList.contains('active'); const isActive = event.currentTarget.classList.contains('active');
const combatant = game.combat.combatants.get(id); const combatant = game.combat.combatants.get(id);
await combatant.update({ await combatant.update({
_id: id, _id: id,
flags: { acks: { prepareSpell: !isActive } }, flags: {
acks: {
prepareSpell: !isActive,
},
},
}); });
}); });
html.find(".combatant-control.move-combat").click(async (ev) => { html.find(".combatant-control.move-combat").click(async (event) => {
ev.preventDefault(); event.preventDefault();
// Toggle retreat announcement // Toggle retreat announcement
const id = $(ev.currentTarget).closest(".combatant")[0].dataset.combatantId; const id = $(event.currentTarget).closest(".combatant")[0].dataset.combatantId;
const isActive = ev.currentTarget.classList.contains('active'); const isActive = event.currentTarget.classList.contains('active');
const combatant = game.combat.combatants.get(id); const combatant = game.combat.combatants.get(id);
await combatant.update({ await combatant.update({
_id: id, _id: id,
flags: { acks: { moveInCombat: !isActive } }, flags: {
acks: {
moveInCombat: !isActive,
},
},
}); });
}); });
} }
static addListeners(html) { static addListeners(html) {
// Cycle through colors // Cycle through colors
html.find(".combatant-control.flag").click(async (ev) => { html.find(".combatant-control.flag").click(async (event) => {
event.preventDefault();
if (!game.user.isGM) { if (!game.user.isGM) {
return; return;
} }
const currentColor = ev.currentTarget.style.color;
const currentColor = event.currentTarget.style.color;
const colors = Object.keys(CONFIG.ACKS.colors); const colors = Object.keys(CONFIG.ACKS.colors);
let index = colors.indexOf(currentColor); let index = colors.indexOf(currentColor);
if (index + 1 == colors.length) { if (index + 1 == colors.length) {
@ -253,7 +271,7 @@ export class AcksCombat {
index++; index++;
} }
const id = $(ev.currentTarget).closest(".combatant")[0].dataset.combatantId; const id = $(event.currentTarget).closest(".combatant")[0].dataset.combatantId;
const combatant = game.combat.combatants.get(id); const combatant = game.combat.combatants.get(id);
await combatant.update({ await combatant.update({
_id: id, _id: id,
@ -265,16 +283,22 @@ export class AcksCombat {
}); });
}); });
html.find('.combat-control[data-control="reroll"]').click((ev) => { html.find('.combat-control[data-control="reroll"]').click(async (event) => {
event.preventDefault();
if (!game.combat) { if (!game.combat) {
return; return;
} }
let data = {};
const data = {};
AcksCombat.rollInitiative(game.combat, data); AcksCombat.rollInitiative(game.combat, data);
game.combat.update({ data: data }).then(() => {
await game.combat.update({
data: data,
})
game.combat.setupTurns(); game.combat.setupTurns();
}); });
});
} }
static async addCombatant(combatant, options, userId) { static async addCombatant(combatant, options, userId) {
@ -314,12 +338,13 @@ export class AcksCombat {
} }
static async preUpdateCombat(combat, data, diff, id) { static async preUpdateCombat(combat, data, diff, id) {
let init = game.settings.get("acks", "initiative");
let reroll = game.settings.get("acks", "initiativePersistence");
if (!data.round) { if (!data.round) {
return; return;
} }
if (data.round !== 1) { if (data.round !== 1) {
const reroll = game.settings.get("acks", "initiativePersistence");
if (reroll === "reset") { if (reroll === "reset") {
AcksCombat.resetInitiative(combat, data, diff, id); AcksCombat.resetInitiative(combat, data, diff, id);
return; return;
@ -327,6 +352,9 @@ export class AcksCombat {
return; return;
} }
} }
const init = game.settings.get("acks", "initiative");
if (init === "group") { if (init === "group") {
AcksCombat.rollInitiative(combat, data, diff, id); AcksCombat.rollInitiative(combat, data, diff, id);
} else if (init === "individual") { } else if (init === "individual") {