Skip to content

Developers

The module exposes its API on the module entry once Foundry is ready:

const api = game.modules.get('mindful-encounters').api;
MethodDescription
toggleDone(tokenId, value, sceneId)Set a token’s Done state. Routed to the active GM when called by a player.
reportMoved(tokenId, distance, sceneId)Add to a token’s moved total for the turn. Negative values refund.
logAction(tokenId, delta, sceneId)Adjust a token’s action count for the turn, capped by the per-turn limit.
setIncluded(ids, scene)Set the list of token ids included in the turn. GM only.
includedTokenIds(scene)The token ids counted toward the turn. Falls back to player-owned, non-hidden tokens when no explicit set exists.
candidateTokens(scene, forGM)The tokens shown in the panel, sorted by group then name.
undoLast(token)Undo a token’s last recorded move leg and refund its budget.
forceAdvance(scene)Mark every included token Done and advance the turn. GM only.
HookArgumentsWhen
mindful-encounters.advanced{ scene, turnSeq, seconds }A dungeon turn has advanced and the clock has moved.
mindful-encounters.refreshnoneA setting changed that affects display. Re-render UI that reflects module state.
Hooks.on('mindful-encounters.advanced', ({ scene, turnSeq, seconds }) => {
console.log(`Turn ${turnSeq} on ${scene.name}, +${seconds}s`);
});

A speed adapter tells the module how to read an actor’s base speed. Register one to support a new system:

import { registerAdapter } from '/modules/mindful-encounters/scripts/adapters.mjs';
registerAdapter({
id: 'my-system',
supports: (actor) => actor?.type === 'character',
getBaseSpeed: (actor) => actor?.system?.speed ?? null,
unitLabel: () => 'ft'
});
FieldDescription
idA unique adapter id.
supports(actor)Returns true if this adapter handles the actor.
getBaseSpeed(actor)Returns the actor’s base speed in scene units, or null to fall back.
unitLabel()The distance unit label.

The most recently registered matching adapter wins. A generic adapter is always present as the final fallback. Register during the init hook.

State writes run through the GM client. Players send requests as queries the active GM answers: mindful-encounters.requestDone, mindful-encounters.reportMoved, and mindful-encounters.requestAction. The API methods route through these automatically, so call the API rather than the queries directly.

FlagLocationDescription
turnsceneTurn state: sequence, moved totals, Done states, actions, inclusion, shared total.
activesceneWhether budgeted movement is enabled on the scene.
overlandsceneWhether the scene uses the shared party budget.
partyBudgetsceneThe shared overland budget.
captokenA manual per-token budget that overrides the cap source.