Repository navigation
API
dxcufgb edited this page Nov 10, 2026
·
1 revision
const api = game.modules.get("dxcufgbs-player-bastions").api;| Member | What it does |
|---|---|
openDashboard() |
Opens the Bastion list |
openBastion(entryId, { tab }) |
Opens a Bastion's page |
openWizard(options) |
Opens the founding wizard (GM) |
allBastions() |
The Bastions' journal entries |
getBastion(entryOrIdOrActor) |
{ entry, record, stats, ctx }, or null
|
ownerActors(entryId) |
The owning characters |
siegeHoldout(entryId, forceKeyOrForce) |
{ days, reason, ... } for a preset force key (bandits, raiders, warband, giants, dragon, company, army) or your own force |
act(action, data) |
Runs an action (below). A GM runs it at once; a player's request is sent to the GM's client, which checks the player's rights |
runTurn(entryId, options) |
Runs a Bastion turn (GM) |
forceEvent(entryId, key) |
Applies one Bastion event (GM) |
buildMap(entryId) |
Draws or redraws the battle-map scene (GM) |
viewMap(entryId) |
Shows the battle-map scene |
mapPlan(entryId) |
The battle map as geometry, in squares |
runSelfTests() |
Runs the module's tests (Quench when active, else the built-in runner) |
core |
The pure engine: computeStats, holdout, quote, quoteDispatch, advanceTurn, the catalog and rules data and more |
Every change to a Bastion is an action. GM actions need a GM; owner actions need a player who owns the Bastion (or the GM).
| Action | Who | Data |
|---|---|---|
found |
GM |
{ answers } (the wizard's answers) |
updateRecord |
GM | { entryId, changes } |
moveMarker |
GM | { entryId, sceneUuid, x, y } |
deleteBastion |
GM | { entryId, confirm: "DELETE" } |
planProject |
owner | { entryId, opts: { expansionId, kind, size, count, featureId, rush } } |
removeProject |
owner |
{ entryId, projectId } (only your own unpaid plans; the GM any) |
fundProject |
owner | { entryId, projectId, amount, actorId, from } |
queueProject |
owner |
{ entryId, projectId, op }: add, remove, up, down, first, last
|
hireCrews |
owner |
{ entryId, crews, actorId, from }: the number of hired crews wanted; from is treasury, a character, or free (GM) |
construction |
GM |
{ entryId, projectId, action, extraCrews }: start, queue, pause, resume, cancel
|
finishProject / finishAllProjects
|
GM |
{ entryId, projectId } / { entryId }
|
deposit / claimDividend
|
owner |
{ entryId, actorId, amount } / { entryId }
|
hire |
owner | { entryId, guards, servants } |
setPresence / chooseMaintain / setStanding
|
owner |
{ entryId, presence } / { entryId, on } / { entryId, orders }
|
sendDispatch |
owner | { entryId, method, actorId, orders, gold, distance, slotLevel } |
setDispatchStatus |
GM | { entryId, dispatchId, status } |
buy |
owner | { entryId, index, actorId, payFrom } |
advanceTurn |
GM | { entryId, turns } |
longRest |
the character's owner |
{ actorUuid }: a long rest the character finished (sent by the module after a dnd5e long rest) |
countRest |
GM |
{ entryId }: "A long rest passed" |
startSiege / siegeDay / endSiege
|
GM |
{ entryId, forceKey, force } / { entryId } / { entryId, outcome }
|
resolveEvent |
owner | { entryId, eventId, choice, count } |
Actions resolve to { ok: true, ... } or { ok: false, reason }.
All with the module id as prefix, e.g. Hooks.on("dxcufgbs-player-bastions.postTurn", fn). Most pass the Bastion's journal entry first.
| Hook | Arguments |
|---|---|
founded |
entry |
projectStateChanged |
entry, project, from, to |
projectFinished |
{ entryId, projectId, completed, layoutChanged } (projectId is null for Finish all) |
postTurn |
{ entryId, report, event } |
restCounted |
{ entryId, counted, rests, completed, layoutChanged, turnDue } (long-rest clock) |
dispatchSent |
entry, ... |
eventRolled, eventResolved
|
entry, ... |
merchantArrived, visitorArrived
|
entry, ... |
siegeStarted, siegeDay, siegeEnded
|
entry, ... |
mapBuilt |
entry, scene, plan |
mapLookChanged |
{ entryId } |
bastionDeleted |
{ entryId, name }, just before a Bastion is deleted |
One journal entry per Bastion, in the module's folder. The Bastion is in the entry's flag flags.dxcufgbs-player-bastions.record; the owners' players get Observer. Rooms are native dnd5e facility items on the owners' sheets, flagged with the Bastion's id.
Dxcufgb's Workshop: every Foundry VTT project, video and changelog in one place · Support on Ko-fi · MIT License