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
4 changes: 4 additions & 0 deletions src/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ GRIMWILD:
slowXp:
name: "Slow XP"
hint: Enable to use half-rate XP where it takes two pips per XP checkbox to be filled.
tokenActions:
name: "[Variant] Token Initiative"
hint: Enable the variant <strong>Token Initiative</strong> rule that gives each players 2 tokens per "round" of combat/scenes. Otherwise, a simple action counter will be used to count how many actions have been taken.
Stat:
bra:
long: Brawn
Expand Down Expand Up @@ -248,6 +251,7 @@ GRIMWILD:
ActionCount: 'Rolls'
ResetActionCount: Reset Action Count
SpotlightActor: Spotlight
TokenActions: 'Actions'
TYPES:
Actor:
character: Character
Expand Down
17 changes: 17 additions & 0 deletions src/module/data/actor-character.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ export default class GrimwildCharacter extends GrimwildActorBase {
})
);

schema.tokenActions = new fields.SchemaField({
value: new fields.NumberField({
...requiredInteger,
max: 2,
initial: 2,
min: 0
}),
max: new fields.NumberField({
...requiredInteger,
initial: 2,
min: 0
})
});

return schema;
}

Expand Down Expand Up @@ -354,6 +368,9 @@ export default class GrimwildCharacter extends GrimwildActorBase {
const actionCount = Number(combatant.flags?.grimwild?.actionCount ?? 0);
await combatant.setFlag("grimwild", "actionCount", actionCount + 1);

const actor = combatant.actor;
await actor.update({"system.tokenActions.value": Math.max(actor.system.tokenActions.value - 1, 0)});

// Update the active turn.
const combatantTurn = combat.turns.findIndex((c) => c.id === combatant.id);
if (combatantTurn !== undefined) {
Expand Down
28 changes: 24 additions & 4 deletions src/module/documents/combat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ export class GrimwildCombat extends foundry.documents.Combat {

/** @inheritdoc */
async _onStartRound(context) {
if (game.settings.get("grimwild", "tokenActions")) {
this.resetActions();
}
}

resetActions() {
for (let combatant of this.combatants) {
combatant.setFlag("grimwild", "actionCount", 0);
combatant.actor.update({"system.tokenActions.value": 2});
}
}

Expand Down Expand Up @@ -111,6 +115,9 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com
}
}

context.tokenActions = game.settings.get("grimwild", "tokenActions");
context.enableHarmPools = game.settings.get("grimwild", "enableHarmPools");

if (!turns.character.length) delete turns.character;
if (!turns.monster.length) delete turns.monster;
if (!turns.other.length) delete turns.other;
Expand All @@ -131,7 +138,9 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com
turn.spark = combatant.actor.system.spark;
turn.bloodied = combatant.actor.system.bloodied;
turn.rattled = combatant.actor.system.rattled;
turn.actionCount = combatant.flags?.grimwild?.actionCount ?? 0;
turn.actionCount = game.settings.get("grimwild", "tokenActions")
? combatant.actor.system.tokenActions.value ?? 0
: combatant.flags?.grimwild?.actionCount ?? 0;
}

return turn;
Expand Down Expand Up @@ -173,7 +182,13 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com
name: "GRIMWILD.Combat.ResetActionCount",
icon: '<i class="fa-solid fa-arrow-rotate-left"></i>',
condition: (li) => game.user.isGM,
callback: (li) => getCombatant(li)?.setFlag("grimwild", "actionCount", 0)
callback: (li) => {
const combatant = getCombatant(li);
if (combatant) {
combatant?.setFlag("grimwild", "actionCount", 0)
combatant?.actor.update({"system.tokenActions.value": 2});
}
}
}, {
name: "COMBAT.CombatantRemove",
icon: '<i class="fa-solid fa-trash"></i>',
Expand All @@ -200,11 +215,16 @@ export class GrimwildCombatTracker extends foundry.applications.sidebar.tabs.Com
const { combatantId } = event.target.closest(".combatant[data-combatant-id]")?.dataset ?? {};
const { harm } = target.dataset ?? false;
const combatant = this.viewed.combatants.get(combatantId);
const update = {};
if (!combatant || !harm) return;
const actor = combatant.actor;
if (!actor.isOwner) return;
const harmValue = actor.system?.[harm].marked;
actor.update({ [`system.${harm}.marked`]: !harmValue });
let harmValue = actor.system?.[harm].marked;
update[`system.${harm}.marked`] = !harmValue;
if (game.settings.get("grimwild", "enableHarmPools")) {
update[`system.${harm}.pool.diceNum`] = actor.system?.[harm].pool.diceNum > 0 ? 0 : 1;
}
actor.update(update);
}

static #onToggleSpark(...args) {
Expand Down
10 changes: 10 additions & 0 deletions src/module/grimwild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ Hooks.once("init", function () {
requiresReload: true
});

game.settings.register("grimwild", "tokenActions", {
name: game.i18n.localize("GRIMWILD.Settings.tokenActions.name"),
hint: game.i18n.localize("GRIMWILD.Settings.tokenActions.hint"),
scope: "world",
config: true,
type: Boolean,
default: false,
requiresReload: true
});

// Override 3d dice.
if (game.modules.get("dice-so-nice")) {
game.settings.register("grimwild", "diceSoNiceOverride", {
Expand Down
10 changes: 7 additions & 3 deletions src/templates/combat/tracker.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<div class="combatant combatant-header">
<div class="token-image"></div>
<div class="token-name">{{localize "Name"}}</div>
<div class="token-initiative">{{localize "GRIMWILD.Combat.ActionCount"}}</div>
{{#if @root.tokenActions}}
<div class="token-initiative">{{localize "GRIMWILD.Combat.TokenActions"}}</div>
{{else}}
<div class="token-initiative">{{localize "GRIMWILD.Combat.ActionCount"}}</div>
{{/if}}
</div>
{{/if}}
{{#each turnsOfType}}
Expand Down Expand Up @@ -47,8 +51,8 @@
{{#if (eq type "character")}}
<div class="token-resources">
<span class="resource resource-spark" data-action="toggleSpark" data-tooltip="{{localize 'GRIMWILD.Actor.Character.FIELDS.spark.label'}}"><i class="fas fa-bolt"></i>{{spark.value}}</span>
<span class="resource resource-bloodied {{#if bloodied.marked}}active{{/if}}" data-action="toggleHarm" data-harm="bloodied" data-tooltip="{{localize 'GRIMWILD.Damage.bloodied'}}"><i class="fas fa-droplet"></i></span>
<span class="resource resource-rattled {{#if rattled.marked}}active{{/if}}" data-action="toggleHarm" data-harm="rattled" data-tooltip="{{localize 'GRIMWILD.Damage.rattled'}}"><i class="fas fa-brain"></i></span>
<span class="resource resource-bloodied {{#if bloodied.marked}}active{{/if}}" data-action="toggleHarm" data-harm="bloodied" data-tooltip="{{localize 'GRIMWILD.Damage.bloodied'}}"><i class="fas fa-droplet"></i>{{#if @root.enableHarmPools}}{{bloodied.pool.diceNum}}{{/if}}</span>
<span class="resource resource-rattled {{#if rattled.marked}}active{{/if}}" data-action="toggleHarm" data-harm="rattled" data-tooltip="{{localize 'GRIMWILD.Damage.rattled'}}"><i class="fas fa-brain"></i>{{#if @root.enableHarmPools}}{{rattled.pool.diceNum}}{{/if}}</span>
</div>
{{/if}}
</div>
Expand Down
Loading