Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3029] Add 'concentration' object in actor system data #3086

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"DND5E.AdvancementTraitModeUpgradeHint": "Gain proficiency in a trait unless you already have it, otherwise gain expertise.",
"DND5E.AdvancementTraitType": "Trait Type",
"DND5E.Advantage": "Advantage",
"DND5E.AdvantageMode": "Advantage Mode",
"DND5E.Age": "Age",
"DND5E.Alignment": "Alignment",
"DND5E.AlignmentCE": "Chaotic Evil",
Expand Down Expand Up @@ -328,6 +329,9 @@
"DND5E.AttackPl": "Attacks",
"DND5E.AttackRoll": "Attack Roll",
"DND5E.Attributes": "Attributes",
"DND5E.AttrConcentration": {
"Limit": "Limit"
},
"DND5E.Automatic": "Automatic",
"DND5E.AutomaticValue": "Automatic ({value})",
"DND5E.Award": {
Expand Down Expand Up @@ -1023,6 +1027,8 @@
"DND5E.MaxCharacterLevelExceededWarn": "Character cannot be advanced past level {max}.",
"DND5E.MaxClassLevelExceededWarn": "Class cannot be advanced past level {max}.",
"DND5E.MaxClassLevelMinimumWarn": "Class must have at least one level.",
"DND5E.Maximum": "Maximum",
"DND5E.Minimum": "Minimum",
"DND5E.Modifier": "Modifier",
"DND5E.ModuleArtConfigH": "Configure which module-provided art should be used.",
"DND5E.ModuleArtConfigL": "Configure Art",
Expand Down
35 changes: 24 additions & 11 deletions module/data/actor/templates/attributes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FormulaField } from "../../fields.mjs";
import MovementField from "../../shared/movement-field.mjs";
import SensesField from "../../shared/senses-field.mjs";
import ActiveEffect5e from "../../../documents/active-effect.mjs";
import RollConfigField from "../../shared/roll-config-field.mjs";

/**
* Shared contents of the attributes schema between various actor types.
Expand All @@ -12,8 +13,8 @@ export default class AttributesFields {
*
* @type {object}
* @property {object} init
* @property {number} init.value Calculated initiative modifier.
* @property {number} init.bonus Fixed bonus provided to initiative rolls.
* @property {string} init.ability The ability used for initiative rolls.
* @property {string} init.bonus The bonus provided to initiative rolls.
* @property {object} movement
* @property {number} movement.burrow Actor burrowing speed.
* @property {number} movement.climb Actor climbing speed.
Expand All @@ -40,15 +41,24 @@ export default class AttributesFields {
*
* @type {object}
* @property {object} attunement
* @property {number} attunement.max Maximum number of attuned items.
* @property {number} attunement.max Maximum number of attuned items.
* @property {object} senses
* @property {number} senses.darkvision Creature's darkvision range.
* @property {number} senses.blindsight Creature's blindsight range.
* @property {number} senses.tremorsense Creature's tremorsense range.
* @property {number} senses.truesight Creature's truesight range.
* @property {string} senses.units Distance units used to measure senses.
* @property {string} senses.special Description of any special senses or restrictions.
* @property {string} spellcasting Primary spellcasting ability.
* @property {number} senses.darkvision Creature's darkvision range.
* @property {number} senses.blindsight Creature's blindsight range.
* @property {number} senses.tremorsense Creature's tremorsense range.
* @property {number} senses.truesight Creature's truesight range.
* @property {string} senses.units Distance units used to measure senses.
* @property {string} senses.special Description of any special senses or restrictions.
* @property {string} spellcasting Primary spellcasting ability.
* @property {number} exhaustion Creature's exhaustion level.
* @property {object} concentration
* @property {string} concentration.ability The ability used for concentration saving throws.
* @property {string} concentration.bonus The bonus provided to concentration saving throws.
* @property {number} concentration.limit The amount of items this actor can concentrate on.
* @property {number} concentration.mode The default advantage mode for this actor's concentration saving throws.
* @property {object} concentration.roll
* @property {number} concentration.roll.min The minimum the d20 can roll.
* @property {number} concentration.roll.max The maximum the d20 can roll.
*/
static get creature() {
return {
Expand All @@ -63,7 +73,10 @@ export default class AttributesFields {
}),
exhaustion: new foundry.data.fields.NumberField({
required: true, nullable: false, integer: true, min: 0, initial: 0, label: "DND5E.Exhaustion"
})
}),
concentration: new RollConfigField({
limit: new foundry.data.fields.NumberField({integer: true, min: 0, initial: 1, label: "DND5E.AttrConcentration.Limit"})
krbz999 marked this conversation as resolved.
Show resolved Hide resolved
}, {label: "DND5E.Concentration"})
};
}

Expand Down
1 change: 1 addition & 0 deletions module/data/shared/_module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export {default as CurrencyTemplate} from "./currency.mjs";
export {default as MovementField} from "./movement-field.mjs";
export {default as SensesField} from "./senses-field.mjs";
export {default as SourceField} from "./source-field.mjs";
export {default as RollConfigField} from "./roll-config-field.mjs";
24 changes: 24 additions & 0 deletions module/data/shared/roll-config-field.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {FormulaField} from "../fields.mjs";

const { StringField, NumberField, SchemaField } = foundry.data.fields;

/**
* Field for storing data for a specific type of roll.
*/
export default class RollConfigField extends foundry.data.fields.SchemaField {
constructor({roll={}, ...fields}={}, options={}) {
const opts = { initial: null, nullable: true, min: 1, max: 20, integer: true };
fields = {
ability: new StringField({required: true, label: "DND5E.AbilityModifier"}),
krbz999 marked this conversation as resolved.
Show resolved Hide resolved
bonus: new FormulaField({required: true, label: "DND5E.Bonus"}),
mode: new NumberField({choices: [-1, 0, 1], initial: 0, label: "DND5E.AdvantageMode"}),
roll: new SchemaField({
min: new NumberField({...opts, label: "DND5E.Minimum"}),
max: new NumberField({...opts, label: "DND5E.Maximum"}),
...roll
}),
...fields
};
super(fields, options);
}
}