Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ GRIMWILD:
Combat:
ActionCount: 'Rolls'
ResetActionCount: Reset Action Count
ResetActionTokens: Reset Action Tokens
AddActionToken: Add Action Token
RemoveActionToken: Remove Action Token
SpotlightActor: Spotlight
TokenActions: 'Actions'
TYPES:
Expand Down
3 changes: 1 addition & 2 deletions src/module/data/actor-character.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ export default class GrimwildCharacter extends GrimwildActorBase {
});

await this.updateCombatActionCount();

}
}

Expand All @@ -365,7 +364,7 @@ export default class GrimwildCharacter extends GrimwildActorBase {
*/
async updateCombatActionCount() {
for (const combat of game.combats) {
const combatant = combat?.getCombatantByActor(this.parent.id);
const combatant = combat?.getCombatantsByActor(this.parent.id)?.[0] || null;
if (combatant) {
const actionCount = Number(combatant.flags?.grimwild?.actionCount ?? 0);
await combatant.setFlag("grimwild", "actionCount", actionCount + 1);
Expand Down
43 changes: 38 additions & 5 deletions src/module/documents/combat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com

_getCombatContextOptions() {
return [{
name: "GRIMWILD.Combat.ResetActionCount",
name: game.settings.get("grimwild", "tokenActions")
? "GRIMWILD.Combat.ResetActionTokens"
: "GRIMWILD.Combat.ResetActionCount",
icon: '<i class="fa-solid fa-arrow-rotate-left"></i>',
condition: () => game.user.isGM && (this.viewed?.turns.length > 0),
callback: () => this.viewed.resetActions()
Expand All @@ -167,7 +169,7 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com

_getEntryContextOptions() {
const getCombatant = (li) => this.viewed.combatants.get(li.dataset.combatantId);
return [{
const contextOptions = [{
name: "COMBAT.CombatantUpdate",
icon: '<i class="fa-solid fa-pen-to-square"></i>',
condition: () => game.user.isGM,
Expand All @@ -179,7 +181,9 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com
}
})
}, {
name: "GRIMWILD.Combat.ResetActionCount",
name: game.settings.get("grimwild", "tokenActions")
? "GRIMWILD.Combat.ResetActionTokens"
: "GRIMWILD.Combat.ResetActionCount",
icon: '<i class="fa-solid fa-arrow-rotate-left"></i>',
condition: (li) => game.user.isGM,
callback: (li) => {
Expand All @@ -189,12 +193,41 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com
combatant?.actor.update({ "system.tokenActions.value": 2 });
}
}
}, {
}];

if (game.settings.get("grimwild", "tokenActions")) {
contextOptions.push({
name: "GRIMWILD.Combat.AddActionToken",
icon: '<i class="fa-solid fa-plus"></i>',
condition: (li) => game.user.isGM && getCombatant(li)?.actor.system.tokenActions.value < 2,
callback: (li) => {
const combatant = getCombatant(li);
if (combatant) {
combatant?.actor.update({ "system.tokenActions.value": Math.min(combatant.actor.system.tokenActions.value + 1, 2) });
}
}
});
contextOptions.push({
name: "GRIMWILD.Combat.RemoveActionToken",
icon: '<i class="fa-solid fa-minus"></i>',
condition: (li) => game.user.isGM && getCombatant(li)?.actor.system.tokenActions.value > 0,
callback: (li) => {
const combatant = getCombatant(li);
if (combatant) {
combatant?.actor.update({ "system.tokenActions.value": Math.max(combatant.actor.system.tokenActions.value - 1, 0) });
}
}
});
}

contextOptions.push({
name: "COMBAT.CombatantRemove",
icon: '<i class="fa-solid fa-trash"></i>',
condition: () => game.user.isGM,
callback: (li) => getCombatant(li)?.delete()
}];
});

return contextOptions;
}

/** @inheritdoc */
Expand Down
15 changes: 15 additions & 0 deletions src/module/sheets/actor-sheet-vue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,21 @@ export class GrimwildActorSheetVue extends VueRenderingMixin(GrimwildBaseVueActo
if (game.dice3d && msg?.id) {
await game.dice3d.waitFor3DAnimationByMessageID(msg.id);
}
// Update the action count.
for (const combat of game.combats) {
const combatant = combat?.getCombatantsByActor(this.actor.id)?.[0] || null;
if (combatant) {
const actionCount = Number(combatant.flags?.grimwild?.actionCount ?? 0);
await combatant.setFlag("grimwild", "actionCount", actionCount + 1);
update["system.tokenActions.value"] = Math.max(this.actor.system.tokenActions.value - 1, 0);

// Update the active turn.
const combatantTurn = combat.turns.findIndex((c) => c.id === combatant.id);
if (combatantTurn !== undefined) {
combat.update({ turn: combatantTurn });
}
}
}
}
else {
const roll = new grimwild.diePools(`{${pool.diceNum}d6}`, rollData);
Expand Down