diff --git a/langs/en-ca.json b/langs/en-ca.json index 14b5d33..4df34e0 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -10,6 +10,10 @@ "name": "Players Can Manage Attributes", "hint": "This allows players who have edit access to a document to be able to edit what attributes those characters have via the attribute editor" }, + "initiativeFormula": { + "name": "Initiative Formula", + "hint": "The dice formula used for initiative, this can reference attributes on the actor. If the actor doesn't have the attribute it will be interpreted as 0." + }, "sheetDefaultHeight": { "name": "Default Actor Sheet Height", "hint": "The height that all actor sheets will open at unless overwridden for that sheet specifically. This setting will not affect already opened sheets." diff --git a/module/documents/Combatant.mjs b/module/documents/Combatant.mjs new file mode 100644 index 0000000..846b782 --- /dev/null +++ b/module/documents/Combatant.mjs @@ -0,0 +1,9 @@ +import { __ID__ } from "../consts.mjs"; + +const { Combatant } = foundry.documents; + +export class TAFCombatant extends Combatant { + _getInitiativeFormula() { + return game.settings.get(__ID__, `initiativeFormula`); + }; +}; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 9bdfc34..c225bd2 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -7,6 +7,7 @@ import { PlayerData } from "../data/Player.mjs"; // Documents import { TAFActor } from "../documents/Actor.mjs"; +import { TAFCombatant } from "../documents/Combatant.mjs"; import { TAFItem } from "../documents/Item.mjs"; import { TAFTokenDocument } from "../documents/Token.mjs"; @@ -25,6 +26,7 @@ Hooks.on(`init`, () => { CONFIG.Token.documentClass = TAFTokenDocument; CONFIG.Actor.documentClass = TAFActor; + CONFIG.Combatant.documentClass = TAFCombatant; CONFIG.Actor.dataModels.player = PlayerData; diff --git a/module/settings/world.mjs b/module/settings/world.mjs index 705ed22..a351c37 100644 --- a/module/settings/world.mjs +++ b/module/settings/world.mjs @@ -3,6 +3,16 @@ import { __ID__ } from "../consts.mjs"; const { NumberField, StringField } = foundry.data.fields; export function registerWorldSettings() { + + game.settings.register(__ID__, `initiativeFormula`, { + name: `taf.settings.initiativeFormula.name`, + hint: `taf.settings.initiativeFormula.hint`, + config: true, + type: String, + default: `1d20`, + scope: `world`, + }); + game.settings.register(__ID__, `canPlayersManageAttributes`, { name: `taf.settings.canPlayersManageAttributes.name`, hint: `taf.settings.canPlayersManageAttributes.hint`,